From 7527592aaf4245749845500aca6a7fcc97eb2f17 Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Sat, 11 Aug 2012 23:30:00 -0400 Subject: [python] fix for new dict API - TDConvert returns a string - various c_str fixes (make copies) - cleanup .gitignore --- python/src/lattice.pxi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python/src/lattice.pxi') diff --git a/python/src/lattice.pxi b/python/src/lattice.pxi index 14864549..385a40be 100644 --- a/python/src/lattice.pxi +++ b/python/src/lattice.pxi @@ -28,7 +28,7 @@ cdef class Lattice: cdef unsigned i for i in range(arc_vector.size()): arc = &arc_vector[i] - label = unicode(TDConvert(arc.label), 'utf8') + label = unicode(TDConvert(arc.label).c_str(), 'utf8') arcs.append((label, arc.cost, arc.dist2next)) return tuple(arcs) @@ -47,7 +47,7 @@ cdef class Lattice: return self.lattice.size() def __str__(self): - return hypergraph.AsPLF(self.lattice[0], True).c_str() + return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) def __iter__(self): cdef unsigned i -- cgit v1.2.3 From 9c9213239263e8e8de2f154068cc3ad44e0c2100 Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Tue, 14 Aug 2012 22:50:37 -0400 Subject: [cdec.sa] Explicit feature names in grammar extractor output + sparse features in extractor + hg.intersect(string) + basestring = str|unicode --- python/pkg/cdec/sa/__init__.py | 2 +- python/pkg/cdec/sa/extractor.py | 8 +- python/pkg/cdec/sa/features.py | 8 +- python/src/_cdec.cpp | 3170 +-- python/src/_cdec.pyx | 4 +- python/src/grammar.pxi | 15 +- python/src/hypergraph.pxd | 6 +- python/src/hypergraph.pxi | 12 +- python/src/lattice.pxd | 5 +- python/src/lattice.pxi | 22 +- python/src/mteval.pxi | 2 +- python/src/sa/_sa.c | 44648 +++++++++++++++++++++----------------- python/src/sa/_sa.pxd | 34 +- python/src/sa/_sa.pyx | 1 + python/src/sa/features.pxi | 34 + python/src/sa/float_list.pxi | 4 - python/src/sa/int_list.pxi | 9 +- python/src/sa/rule.pxi | 72 +- python/src/sa/rulefactory.pxi | 38 +- 19 files changed, 26397 insertions(+), 21697 deletions(-) create mode 100644 python/src/sa/features.pxi (limited to 'python/src/lattice.pxi') diff --git a/python/pkg/cdec/sa/__init__.py b/python/pkg/cdec/sa/__init__.py index fd4a4148..ab8be809 100644 --- a/python/pkg/cdec/sa/__init__.py +++ b/python/pkg/cdec/sa/__init__.py @@ -1,4 +1,4 @@ from cdec.sa._sa import sym_fromstring,\ SuffixArray, DataArray, LCP, Precomputation, Alignment, BiLex,\ - HieroCachingRuleFactory, Sampler + HieroCachingRuleFactory, Sampler, Scorer from cdec.sa.extractor import GrammarExtractor diff --git a/python/pkg/cdec/sa/extractor.py b/python/pkg/cdec/sa/extractor.py index bb912e16..90cc4c51 100644 --- a/python/pkg/cdec/sa/extractor.py +++ b/python/pkg/cdec/sa/extractor.py @@ -57,8 +57,8 @@ class GrammarExtractor: # lexical weighting tables tt = cdec.sa.BiLex(from_binary=config['lex_file']) - self.models = (EgivenFCoherent, SampleCountF, CountEF, - MaxLexFgivenE(tt), MaxLexEgivenF(tt), IsSingletonF, IsSingletonFE) + scorer = cdec.sa.Scorer(EgivenFCoherent, SampleCountF, CountEF, + MaxLexFgivenE(tt), MaxLexEgivenF(tt), IsSingletonF, IsSingletonFE) fsarray = cdec.sa.SuffixArray(from_binary=config['f_sa_file']) edarray = cdec.sa.DataArray(from_binary=config['e_file']) @@ -67,7 +67,7 @@ class GrammarExtractor: # -1 = don't sample, use all data (VERY SLOW!) sampler = cdec.sa.Sampler(300, fsarray) - self.factory.configure(fsarray, edarray, sampler) + self.factory.configure(fsarray, edarray, sampler, scorer) def grammar(self, sentence): if isinstance(sentence, unicode): @@ -75,4 +75,4 @@ class GrammarExtractor: cnet = chain(('',), sentence.split(), ('',)) cnet = (cdec.sa.sym_fromstring(word, terminal=True) for word in cnet) cnet = tuple(((word, None, 1), ) for word in cnet) - return self.factory.input(cnet, self.models) + return self.factory.input(cnet) diff --git a/python/pkg/cdec/sa/features.py b/python/pkg/cdec/sa/features.py index 325b9e13..8fd370cc 100644 --- a/python/pkg/cdec/sa/features.py +++ b/python/pkg/cdec/sa/features.py @@ -20,7 +20,7 @@ def CoherenceProb(fphrase, ephrase, paircount, fcount, fsample_count): return -math.log10(fcount/fsample_count) def MaxLexEgivenF(ttable): - def feature(fphrase, ephrase, paircount, fcount, fsample_count): + def MaxLexEgivenF(fphrase, ephrase, paircount, fcount, fsample_count): fwords = fphrase.words fwords.append('NULL') def score(): @@ -28,10 +28,10 @@ def MaxLexEgivenF(ttable): maxScore = max(ttable.get_score(f, e, 0) for f in fwords) yield -math.log10(maxScore) if maxScore > 0 else MAXSCORE return sum(score()) - return feature + return MaxLexEgivenF def MaxLexFgivenE(ttable): - def feature(fphrase, ephrase, paircount, fcount, fsample_count): + def MaxLexFgivenE(fphrase, ephrase, paircount, fcount, fsample_count): ewords = ephrase.words ewords.append('NULL') def score(): @@ -39,7 +39,7 @@ def MaxLexFgivenE(ttable): maxScore = max(ttable.get_score(f, e, 1) for e in ewords) yield -math.log10(maxScore) if maxScore > 0 else MAXSCORE return sum(score()) - return feature + return MaxLexFgivenE def IsSingletonF(fphrase, ephrase, paircount, fcount, fsample_count): return (fcount == 1) diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp index dd812b52..1bd600f0 100644 --- a/python/src/_cdec.cpp +++ b/python/src/_cdec.cpp @@ -1,4 +1,4 @@ -/* Generated by Cython 0.17.beta1 on Sat Aug 11 23:26:15 2012 */ +/* Generated by Cython 0.17.beta1 on Tue Aug 14 22:47:23 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -303,6 +303,7 @@ #include "decoder/ff_register.h" #include "decoder/decoder.h" #include "observer.h" +#include "stdio.h" #include "decoder/kbest.h" #include "mteval/ns.h" #include "py_scorer.h" @@ -403,8 +404,10 @@ static const char *__pyx_f[] = { }; /*--- Type declarations ---*/ -struct __pyx_obj_5_cdec_Scorer; +struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector; struct __pyx_obj_5_cdec_NTRef; +struct __pyx_obj_5_cdec_Scorer; +struct __pyx_obj_4cdec_2sa_3_sa_IntList; struct __pyx_obj_4cdec_2sa_3_sa_Phrase; struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__; struct __pyx_obj_5_cdec_Grammar; @@ -423,6 +426,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot; struct __pyx_obj_5_cdec_Candidate; struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr; struct __pyx_obj_5_cdec_NT; +struct __pyx_obj_4cdec_2sa_3_sa_FloatList; struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__; struct __pyx_obj_5_cdec_HypergraphEdge; struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__; @@ -464,6 +468,33 @@ struct __pyx_opt_args_5_cdec_as_str { char *error_msg; }; +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":25 + * cdef void read_handle(self, FILE* f) + * + * cdef class FeatureVector: # <<<<<<<<<<<<<< + * cdef IntList names + * cdef FloatList values + */ +struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector { + PyObject_HEAD + struct __pyx_obj_4cdec_2sa_3_sa_IntList *names; + struct __pyx_obj_4cdec_2sa_3_sa_FloatList *values; +}; + + +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20 + * return '[%s]' % self.cat + * + * cdef class NTRef: # <<<<<<<<<<<<<< + * cdef public unsigned ref + * def __init__(self, unsigned ref): + */ +struct __pyx_obj_5_cdec_NTRef { + PyObject_HEAD + unsigned int ref; +}; + + /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":117 * return CandidateSet(self) * @@ -478,20 +509,26 @@ struct __pyx_obj_5_cdec_Scorer { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20 - * return '[%s]' % self.cat +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":12 + * cdef void read_handle(self, FILE* f) * - * cdef class NTRef: # <<<<<<<<<<<<<< - * cdef public unsigned ref - * def __init__(self, unsigned ref): + * cdef class IntList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment */ -struct __pyx_obj_5_cdec_NTRef { +struct __pyx_obj_4cdec_2sa_3_sa_IntList { PyObject_HEAD - unsigned int ref; + struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList *__pyx_vtab; + int size; + int increment; + int len; + int *arr; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":29 + * cdef FloatList values + * * cdef class Phrase: # <<<<<<<<<<<<<< * cdef int *syms * cdef int n, *varpos, n_vars @@ -522,7 +559,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":178 * super(MRule, self).__init__(lhs, rhs, e, scores, a) * * cdef class Grammar: # <<<<<<<<<<<<<< @@ -535,7 +572,7 @@ struct __pyx_obj_5_cdec_Grammar { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 * * def todot(self): * def lines(): # <<<<<<<<<<<<<< @@ -576,7 +613,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":126 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136 * * property edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -620,7 +657,7 @@ struct __pyx_obj_5_cdec_CandidateSet { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":132 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":142 * * property nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -636,7 +673,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47 * return TRule(lhs, f, e, scores, a) * * cdef class TRule: # <<<<<<<<<<<<<< @@ -649,11 +686,11 @@ struct __pyx_obj_5_cdec_TRule { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":7 +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":35 * cdef public int chunklen(self, int k) * * cdef class Rule: # <<<<<<<<<<<<<< - * cdef public int lhs + * cdef int lhs * cdef readonly Phrase f, e */ struct __pyx_obj_4cdec_2sa_3_sa_Rule { @@ -661,13 +698,13 @@ struct __pyx_obj_4cdec_2sa_3_sa_Rule { int lhs; struct __pyx_obj_4cdec_2sa_3_sa_Phrase *f; struct __pyx_obj_4cdec_2sa_3_sa_Phrase *e; - float *cscores; + struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector *scores; int n_scores; PyObject *word_alignments; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":166 * _phrase(self.f), _phrase(self.e), scores) * * cdef class MRule(TRule): # <<<<<<<<<<<<<< @@ -709,6 +746,14 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr { PyObject *(*__pyx_t_2)(PyObject *); }; + +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62 + * yield self[i] + * + * def todot(self): # <<<<<<<<<<<<<< + * def lines(): + * yield 'digraph lattice {' + */ struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot { PyObject_HEAD struct __pyx_obj_5_cdec_Lattice *__pyx_v_self; @@ -729,7 +774,7 @@ struct __pyx_obj_5_cdec_Candidate { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< @@ -760,6 +805,23 @@ struct __pyx_obj_5_cdec_NT { }; +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":3 + * from libc.stdio cimport FILE + * + * cdef class FloatList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment + */ +struct __pyx_obj_4cdec_2sa_3_sa_FloatList { + PyObject_HEAD + struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList *__pyx_vtab; + int size; + int increment; + int len; + float *arr; +}; + + /* "_cdec.pyx":46 * cdef DenseVector weights * @@ -773,7 +835,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":160 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":170 * return vector * * cdef class HypergraphEdge: # <<<<<<<<<<<<<< @@ -806,7 +868,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":226 * * property in_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -822,7 +884,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121 * * property a: * def __get__(self): # <<<<<<<<<<<<<< @@ -839,8 +901,8 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52 - * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 + * return unicode(str(self), 'utf8') * * def __iter__(self): # <<<<<<<<<<<<<< * cdef unsigned i @@ -869,7 +931,7 @@ struct __pyx_obj_5_cdec_Decoder { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":206 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 * raise NotImplemented('comparison not implemented for HypergraphEdge') * * cdef class HypergraphNode: # <<<<<<<<<<<<<< @@ -897,7 +959,7 @@ struct __pyx_obj_5_cdec_SparseVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":222 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":232 * * property out_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -960,7 +1022,7 @@ struct __pyx_obj_5_cdec_DenseVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184 * del self.grammar * * def __iter__(self): # <<<<<<<<<<<<<< @@ -1045,7 +1107,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":180 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190 * * property tail_nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -1061,7 +1123,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161 * self.rule.get().lhs_ = -TDConvert(lhs.cat) * * def __str__(self): # <<<<<<<<<<<<<< @@ -1183,7 +1245,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":204 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201 * self.grammar.get().SetGrammarName(string(name)) * * cdef class TextGrammar(Grammar): # <<<<<<<<<<<<<< @@ -1210,7 +1272,59 @@ struct __pyx_vtabstruct_5_cdec_Hypergraph { static struct __pyx_vtabstruct_5_cdec_Hypergraph *__pyx_vtabptr_5_cdec_Hypergraph; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":1 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":170 + * return vector + * + * cdef class HypergraphEdge: # <<<<<<<<<<<<<< + * cdef hypergraph.Hypergraph* hg + * cdef hypergraph.HypergraphEdge* edge + */ + +struct __pyx_vtabstruct_5_cdec_HypergraphEdge { + PyObject *(*init)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int); +}; +static struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtabptr_5_cdec_HypergraphEdge; + + +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":12 + * cdef void read_handle(self, FILE* f) + * + * cdef class IntList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment + */ + +struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList { + void (*set)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int, int); + void (*_append)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int); + void (*_extend)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, struct __pyx_obj_4cdec_2sa_3_sa_IntList *); + void (*_extend_arr)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, int *, int); + void (*_clear)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *); + void (*write_handle)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, FILE *); + void (*read_handle)(struct __pyx_obj_4cdec_2sa_3_sa_IntList *, FILE *); +}; +static struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList *__pyx_vtabptr_4cdec_2sa_3_sa_IntList; + + +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":3 + * from libc.stdio cimport FILE + * + * cdef class FloatList: # <<<<<<<<<<<<<< + * cdef int size + * cdef int increment + */ + +struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList { + void (*set)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, int, float); + void (*write_handle)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, FILE *); + void (*read_handle)(struct __pyx_obj_4cdec_2sa_3_sa_FloatList *, FILE *); +}; +static struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList *__pyx_vtabptr_4cdec_2sa_3_sa_FloatList; + + +/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":29 + * cdef FloatList values + * * cdef class Phrase: # <<<<<<<<<<<<<< * cdef int *syms * cdef int n, *varpos, n_vars @@ -1223,7 +1337,7 @@ struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase { static struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase *__pyx_vtabptr_4cdec_2sa_3_sa_Phrase; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":206 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 * raise NotImplemented('comparison not implemented for HypergraphEdge') * * cdef class HypergraphNode: # <<<<<<<<<<<<<< @@ -1235,20 +1349,6 @@ struct __pyx_vtabstruct_5_cdec_HypergraphNode { PyObject *(*init)(struct __pyx_obj_5_cdec_HypergraphNode *, Hypergraph *, unsigned int); }; static struct __pyx_vtabstruct_5_cdec_HypergraphNode *__pyx_vtabptr_5_cdec_HypergraphNode; - - -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":160 - * return vector - * - * cdef class HypergraphEdge: # <<<<<<<<<<<<<< - * cdef hypergraph.Hypergraph* hg - * cdef hypergraph.HypergraphEdge* edge - */ - -struct __pyx_vtabstruct_5_cdec_HypergraphEdge { - PyObject *(*init)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int); -}; -static struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtabptr_5_cdec_HypergraphEdge; #ifndef CYTHON_REFNANNY #define CYTHON_REFNANNY 0 #endif @@ -1333,22 +1433,6 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \ PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \ const char* function_name); /*proto*/ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len)) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) -#endif - static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) { if (likely(PyList_CheckExact(L))) { if (unlikely(PyList_Append(L, x) < 0)) return NULL; @@ -1713,7 +1797,12 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ /* Module declarations from 'decoder' */ +/* Module declarations from 'libc.stdio' */ + /* Module declarations from 'cdec.sa._sa' */ +static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_FloatList = 0; +static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_IntList = 0; +static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_FeatureVector = 0; static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_Phrase = 0; static PyTypeObject *__pyx_ptype_4cdec_2sa_3_sa_Rule = 0; static char *(*__pyx_f_4cdec_2sa_3_sa_sym_tostring)(int); /*proto*/ @@ -1787,6 +1876,7 @@ static PyObject *__pyx_builtin_range; static PyObject *__pyx_builtin_NotImplemented; static PyObject *__pyx_builtin_super; static PyObject *__pyx_builtin_ValueError; +static PyObject *__pyx_builtin_basestring; static PyObject *__pyx_builtin_eval; static PyObject *__pyx_builtin_enumerate; static PyObject *__pyx_builtin_IndexError; @@ -1866,15 +1956,16 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_c static PyObject *__pyx_pf_5_cdec_10Hypergraph_16kbest_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_22sample_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, struct __pyx_obj_5_cdec_Lattice *__pyx_v_lat); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_beam_alpha, PyObject *__pyx_v_density, PyObject *__pyx_v_kwargs); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static Py_ssize_t __pyx_pf_5_cdec_14HypergraphEdge___len__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __pyx_obj_5_cdec_HypergraphEdge *__pyx_v_self); /* proto */ @@ -1890,15 +1981,18 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __py static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_x, struct __pyx_obj_5_cdec_HypergraphNode *__pyx_v_y, int __pyx_v_op); /* proto */ -static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */ -static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index); /* proto */ -static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs); /* proto */ -static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp); /* proto */ +static void __pyx_pf_5_cdec_7Lattice_4__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index); /* proto */ +static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs); /* proto */ +static Py_ssize_t __pyx_pf_5_cdec_7Lattice_10__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_12__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_16__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_7Lattice_5todot_lines(PyObject *__pyx_self); /* proto */ -static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_9Candidate_5score___get__(struct __pyx_obj_5_cdec_Candidate *__pyx_v_self); /* proto */ @@ -1948,34 +2042,35 @@ static char __pyx_k_10[] = "[%d]"; static char __pyx_k_11[] = "%s=%s"; static char __pyx_k_12[] = "%s ||| %s ||| %s ||| %s"; static char __pyx_k_13[] = "the grammar should contain TRule objects"; -static char __pyx_k_15[] = "csplit_preserve_full_word"; -static char __pyx_k_16[] = "cannot reweight hypergraph with %s"; -static char __pyx_k_17[] = "comparison not implemented for HypergraphEdge"; -static char __pyx_k_19[] = "comparison not implemented for HypergraphNode"; -static char __pyx_k_22[] = "Cannot create lattice from %s"; -static char __pyx_k_23[] = "lattice index out of range"; -static char __pyx_k_27[] = "digraph lattice {"; - static char __pyx_k_28[] = "rankdir = LR;"; - static char __pyx_k_29[] = "node [shape=circle];"; - static char __pyx_k_30[] = "%d -> %d [label=\"%s\"];"; - static char __pyx_k_31[] = "\""; - static char __pyx_k_32[] = "\\\""; - static char __pyx_k_34[] = "%d [shape=doublecircle]"; -static char __pyx_k_35[] = "}"; -static char __pyx_k_38[] = "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi"; -static char __pyx_k_39[] = "\n"; -static char __pyx_k_41[] = "sufficient stats vector index out of range"; -static char __pyx_k_43[] = "candidate set index out of range"; -static char __pyx_k_45[] = "%s %s"; -static char __pyx_k_46[] = "%s = %s"; -static char __pyx_k_48[] = "formalism \"%s\" unknown"; -static char __pyx_k_49[] = "cannot initialize weights with %s"; -static char __pyx_k_50[] = "#"; -static char __pyx_k_53[] = "Cannot translate input type %s"; -static char __pyx_k_54[] = "cdec.sa._sa"; -static char __pyx_k_55[] = "*"; -static char __pyx_k_58[] = "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi"; -static char __pyx_k_64[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx"; +static char __pyx_k_15[] = "cannot intersect hypergraph with %s"; +static char __pyx_k_16[] = "csplit_preserve_full_word"; +static char __pyx_k_17[] = "cannot reweight hypergraph with %s"; +static char __pyx_k_18[] = "comparison not implemented for HypergraphEdge"; +static char __pyx_k_20[] = "comparison not implemented for HypergraphNode"; +static char __pyx_k_23[] = "cannot create lattice from %s"; +static char __pyx_k_24[] = "lattice index out of range"; +static char __pyx_k_28[] = "digraph lattice {"; + static char __pyx_k_29[] = "rankdir = LR;"; + static char __pyx_k_30[] = "node [shape=circle];"; + static char __pyx_k_31[] = "%d -> %d [label=\"%s\"];"; + static char __pyx_k_32[] = "\""; + static char __pyx_k_33[] = "\\\""; + static char __pyx_k_35[] = "%d [shape=doublecircle]"; +static char __pyx_k_36[] = "}"; +static char __pyx_k_39[] = "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi"; +static char __pyx_k_40[] = "\n"; +static char __pyx_k_42[] = "sufficient stats vector index out of range"; +static char __pyx_k_44[] = "candidate set index out of range"; +static char __pyx_k_46[] = "%s %s"; +static char __pyx_k_47[] = "%s = %s"; +static char __pyx_k_49[] = "formalism \"%s\" unknown"; +static char __pyx_k_50[] = "cannot initialize weights with %s"; +static char __pyx_k_51[] = "#"; +static char __pyx_k_54[] = "Cannot translate input type %s"; +static char __pyx_k_55[] = "cdec.sa._sa"; +static char __pyx_k_56[] = "*"; +static char __pyx_k_59[] = "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi"; +static char __pyx_k_65[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx"; static char __pyx_k__a[] = "a"; static char __pyx_k__e[] = "e"; static char __pyx_k__f[] = "f"; @@ -2055,13 +2150,14 @@ static char __pyx_k__evaluator[] = "evaluator"; static char __pyx_k__formalism[] = "formalism"; static char __pyx_k__IndexError[] = "IndexError"; static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k__alignments[] = "alignments"; +static char __pyx_k__basestring[] = "basestring"; static char __pyx_k__beam_alpha[] = "beam_alpha"; static char __pyx_k__config_str[] = "config_str"; static char __pyx_k__hypergraph[] = "hypergraph"; static char __pyx_k__set_silent[] = "set_silent"; static char __pyx_k__startswith[] = "startswith"; static char __pyx_k__ParseFailed[] = "ParseFailed"; -static char __pyx_k__PhraseModel_[] = "PhraseModel_"; static char __pyx_k___make_config[] = "_make_config"; static char __pyx_k__InvalidConfig[] = "InvalidConfig"; static char __pyx_k__NotImplemented[] = "NotImplemented"; @@ -2069,36 +2165,37 @@ static PyObject *__pyx_kp_s_10; static PyObject *__pyx_kp_s_11; static PyObject *__pyx_kp_s_12; static PyObject *__pyx_kp_s_13; -static PyObject *__pyx_n_s_15; -static PyObject *__pyx_kp_s_16; +static PyObject *__pyx_kp_s_15; +static PyObject *__pyx_n_s_16; static PyObject *__pyx_kp_s_17; -static PyObject *__pyx_kp_s_19; -static PyObject *__pyx_kp_s_22; +static PyObject *__pyx_kp_s_18; +static PyObject *__pyx_kp_s_20; static PyObject *__pyx_kp_s_23; -static PyObject *__pyx_kp_s_27; +static PyObject *__pyx_kp_s_24; static PyObject *__pyx_kp_s_28; static PyObject *__pyx_kp_s_29; static PyObject *__pyx_kp_s_3; static PyObject *__pyx_kp_s_30; static PyObject *__pyx_kp_s_31; static PyObject *__pyx_kp_s_32; -static PyObject *__pyx_kp_s_34; +static PyObject *__pyx_kp_s_33; static PyObject *__pyx_kp_s_35; -static PyObject *__pyx_kp_s_38; +static PyObject *__pyx_kp_s_36; static PyObject *__pyx_kp_s_39; static PyObject *__pyx_kp_s_4; -static PyObject *__pyx_kp_s_41; -static PyObject *__pyx_kp_s_43; -static PyObject *__pyx_kp_s_45; +static PyObject *__pyx_kp_s_40; +static PyObject *__pyx_kp_s_42; +static PyObject *__pyx_kp_s_44; static PyObject *__pyx_kp_s_46; -static PyObject *__pyx_kp_s_48; +static PyObject *__pyx_kp_s_47; static PyObject *__pyx_kp_s_49; static PyObject *__pyx_kp_s_50; -static PyObject *__pyx_kp_s_53; -static PyObject *__pyx_n_s_54; +static PyObject *__pyx_kp_s_51; +static PyObject *__pyx_kp_s_54; static PyObject *__pyx_n_s_55; -static PyObject *__pyx_kp_s_58; -static PyObject *__pyx_kp_s_64; +static PyObject *__pyx_n_s_56; +static PyObject *__pyx_kp_s_59; +static PyObject *__pyx_kp_s_65; static PyObject *__pyx_kp_s_7; static PyObject *__pyx_kp_s_8; static PyObject *__pyx_kp_s_9; @@ -2111,7 +2208,6 @@ static PyObject *__pyx_n_s__InvalidConfig; static PyObject *__pyx_n_s__KeyError; static PyObject *__pyx_n_s__NotImplemented; static PyObject *__pyx_n_s__ParseFailed; -static PyObject *__pyx_n_s__PhraseModel_; static PyObject *__pyx_n_s__TER; static PyObject *__pyx_n_s__TypeError; static PyObject *__pyx_n_s__ValueError; @@ -2127,6 +2223,8 @@ static PyObject *__pyx_n_s___make_config; static PyObject *__pyx_n_s___phrase; static PyObject *__pyx_n_s___sa; static PyObject *__pyx_n_s__a; +static PyObject *__pyx_n_s__alignments; +static PyObject *__pyx_n_s__basestring; static PyObject *__pyx_n_s__beam_alpha; static PyObject *__pyx_n_s__cat; static PyObject *__pyx_n_s__config; @@ -2193,35 +2291,34 @@ static PyObject *__pyx_n_s__weight; static PyObject *__pyx_n_s__yn; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; -static PyObject *__pyx_int_65536; static PyObject *__pyx_k_tuple_2; static PyObject *__pyx_k_tuple_5; static PyObject *__pyx_k_tuple_6; static PyObject *__pyx_k_tuple_14; -static PyObject *__pyx_k_tuple_18; -static PyObject *__pyx_k_tuple_20; +static PyObject *__pyx_k_tuple_19; static PyObject *__pyx_k_tuple_21; -static PyObject *__pyx_k_tuple_24; +static PyObject *__pyx_k_tuple_22; static PyObject *__pyx_k_tuple_25; static PyObject *__pyx_k_tuple_26; -static PyObject *__pyx_k_tuple_33; -static PyObject *__pyx_k_tuple_36; -static PyObject *__pyx_k_tuple_40; -static PyObject *__pyx_k_tuple_42; -static PyObject *__pyx_k_tuple_44; -static PyObject *__pyx_k_tuple_47; -static PyObject *__pyx_k_tuple_51; +static PyObject *__pyx_k_tuple_27; +static PyObject *__pyx_k_tuple_34; +static PyObject *__pyx_k_tuple_37; +static PyObject *__pyx_k_tuple_41; +static PyObject *__pyx_k_tuple_43; +static PyObject *__pyx_k_tuple_45; +static PyObject *__pyx_k_tuple_48; static PyObject *__pyx_k_tuple_52; -static PyObject *__pyx_k_tuple_56; -static PyObject *__pyx_k_tuple_59; +static PyObject *__pyx_k_tuple_53; +static PyObject *__pyx_k_tuple_57; static PyObject *__pyx_k_tuple_60; static PyObject *__pyx_k_tuple_61; static PyObject *__pyx_k_tuple_62; -static PyObject *__pyx_k_tuple_65; -static PyObject *__pyx_k_codeobj_37; -static PyObject *__pyx_k_codeobj_57; -static PyObject *__pyx_k_codeobj_63; -static PyObject *__pyx_k_codeobj_66; +static PyObject *__pyx_k_tuple_63; +static PyObject *__pyx_k_tuple_66; +static PyObject *__pyx_k_codeobj_38; +static PyObject *__pyx_k_codeobj_58; +static PyObject *__pyx_k_codeobj_64; +static PyObject *__pyx_k_codeobj_67; /* "_cdec.pyx":6 * cimport decoder @@ -5492,118 +5589,77 @@ static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *_ * return '[%d]' % self.ref * * cdef TRule convert_rule(_sa.Rule rule): # <<<<<<<<<<<<<< - * cdef unsigned i - * cdef lhs = _sa.sym_tocat(rule.lhs) + * lhs = _sa.sym_tocat(rule.lhs) + * scores = dict(rule.scores) */ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_obj_4cdec_2sa_3_sa_Rule *__pyx_v_rule) { - unsigned int __pyx_v_i; - PyObject *__pyx_v_lhs = 0; - PyObject *__pyx_v_scores = 0; + char *__pyx_v_lhs; + PyObject *__pyx_v_scores = NULL; PyObject *__pyx_v_f = NULL; PyObject *__pyx_v_e = NULL; int *__pyx_v_fsyms; + int __pyx_v_i; int *__pyx_v_esyms; - PyObject *__pyx_v_a = 0; - PyObject *__pyx_v_point = NULL; + PyObject *__pyx_v_a = NULL; struct __pyx_obj_5_cdec_TRule *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - unsigned int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; int __pyx_t_6; - int __pyx_t_7; - Py_ssize_t __pyx_t_8; - PyObject *(*__pyx_t_9)(PyObject *); - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("convert_rule", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":30 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":29 + * * cdef TRule convert_rule(_sa.Rule rule): - * cdef unsigned i - * cdef lhs = _sa.sym_tocat(rule.lhs) # <<<<<<<<<<<<<< - * cdef scores = {} - * for i in range(rule.n_scores): - */ - __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat(__pyx_v_rule->lhs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_v_lhs = ((PyObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":31 - * cdef unsigned i - * cdef lhs = _sa.sym_tocat(rule.lhs) - * cdef scores = {} # <<<<<<<<<<<<<< - * for i in range(rule.n_scores): - * scores['PhraseModel_'+str(i)] = rule.cscores[i] - */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_v_scores = ((PyObject *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":32 - * cdef lhs = _sa.sym_tocat(rule.lhs) - * cdef scores = {} - * for i in range(rule.n_scores): # <<<<<<<<<<<<<< - * scores['PhraseModel_'+str(i)] = rule.cscores[i] + * lhs = _sa.sym_tocat(rule.lhs) # <<<<<<<<<<<<<< + * scores = dict(rule.scores) * f, e = [], [] */ - __pyx_t_2 = __pyx_v_rule->n_scores; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_v_lhs = __pyx_f_4cdec_2sa_3_sa_sym_tocat(__pyx_v_rule->lhs); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":33 - * cdef scores = {} - * for i in range(rule.n_scores): - * scores['PhraseModel_'+str(i)] = rule.cscores[i] # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":30 + * cdef TRule convert_rule(_sa.Rule rule): + * lhs = _sa.sym_tocat(rule.lhs) + * scores = dict(rule.scores) # <<<<<<<<<<<<<< * f, e = [], [] * cdef int* fsyms = rule.f.syms */ - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_rule->cscores[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_n_s__PhraseModel_), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyObject_SetItem(__pyx_v_scores, __pyx_t_5, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_rule->scores)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_rule->scores)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_rule->scores)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_scores = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34 - * for i in range(rule.n_scores): - * scores['PhraseModel_'+str(i)] = rule.cscores[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":31 + * lhs = _sa.sym_tocat(rule.lhs) + * scores = dict(rule.scores) * f, e = [], [] # <<<<<<<<<<<<<< * cdef int* fsyms = rule.f.syms * for i in range(rule.f.n): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_v_f = __pyx_t_1; + __pyx_v_f = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_v_e = __pyx_t_1; __pyx_t_1 = 0; - __pyx_v_e = __pyx_t_5; - __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":35 - * scores['PhraseModel_'+str(i)] = rule.cscores[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":32 + * scores = dict(rule.scores) * f, e = [], [] * cdef int* fsyms = rule.f.syms # <<<<<<<<<<<<<< * for i in range(rule.f.n): @@ -5611,66 +5667,66 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_fsyms = __pyx_v_rule->f->syms; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":36 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":33 * f, e = [], [] * cdef int* fsyms = rule.f.syms * for i in range(rule.f.n): # <<<<<<<<<<<<<< * if _sa.sym_isvar(fsyms[i]): * f.append(NT(_sa.sym_tocat(fsyms[i]))) */ - __pyx_t_2 = __pyx_v_rule->f->n; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_t_3 = __pyx_v_rule->f->n; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34 * cdef int* fsyms = rule.f.syms * for i in range(rule.f.n): * if _sa.sym_isvar(fsyms[i]): # <<<<<<<<<<<<<< * f.append(NT(_sa.sym_tocat(fsyms[i]))) * else: */ - __pyx_t_6 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_fsyms[__pyx_v_i])); - if (__pyx_t_6) { + __pyx_t_5 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_fsyms[__pyx_v_i])); + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":35 * for i in range(rule.f.n): * if _sa.sym_isvar(fsyms[i]): * f.append(NT(_sa.sym_tocat(fsyms[i]))) # <<<<<<<<<<<<<< * else: * f.append(_sa.sym_tostring(fsyms[i])) */ - __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_7 = PyList_Append(__pyx_v_f, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L7; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_6 = PyList_Append(__pyx_v_f, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37 * f.append(NT(_sa.sym_tocat(fsyms[i]))) * else: * f.append(_sa.sym_tostring(fsyms[i])) # <<<<<<<<<<<<<< * cdef int* esyms = rule.e.syms * for i in range(rule.e.n): */ - __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_7 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_6 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; } - __pyx_L7:; + __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":41 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38 * else: * f.append(_sa.sym_tostring(fsyms[i])) * cdef int* esyms = rule.e.syms # <<<<<<<<<<<<<< @@ -5679,180 +5735,134 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_esyms = __pyx_v_rule->e->syms; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":42 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":39 * f.append(_sa.sym_tostring(fsyms[i])) * cdef int* esyms = rule.e.syms * for i in range(rule.e.n): # <<<<<<<<<<<<<< * if _sa.sym_isvar(esyms[i]): * e.append(NTRef(_sa.sym_getindex(esyms[i]))) */ - __pyx_t_2 = __pyx_v_rule->e->n; - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_t_3 = __pyx_v_rule->e->n; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40 * cdef int* esyms = rule.e.syms * for i in range(rule.e.n): * if _sa.sym_isvar(esyms[i]): # <<<<<<<<<<<<<< * e.append(NTRef(_sa.sym_getindex(esyms[i]))) * else: */ - __pyx_t_6 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_esyms[__pyx_v_i])); - if (__pyx_t_6) { + __pyx_t_5 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_esyms[__pyx_v_i])); + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":41 * for i in range(rule.e.n): * if _sa.sym_isvar(esyms[i]): * e.append(NTRef(_sa.sym_getindex(esyms[i]))) # <<<<<<<<<<<<<< * else: * e.append(_sa.sym_tostring(esyms[i])) */ - __pyx_t_5 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L10; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_6 = PyList_Append(__pyx_v_e, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L8; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":46 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43 * e.append(NTRef(_sa.sym_getindex(esyms[i]))) * else: * e.append(_sa.sym_tostring(esyms[i])) # <<<<<<<<<<<<<< - * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] + * a = list(rule.alignments()) * return TRule(lhs, f, e, scores, a) */ - __pyx_t_5 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_7 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_5)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_6 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; } - __pyx_L10:; + __pyx_L8:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44 * else: * e.append(_sa.sym_tostring(esyms[i])) - * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] # <<<<<<<<<<<<<< + * a = list(rule.alignments()) # <<<<<<<<<<<<<< * return TRule(lhs, f, e, scores, a) * */ - __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - if (PyList_CheckExact(__pyx_v_rule->word_alignments) || PyTuple_CheckExact(__pyx_v_rule->word_alignments)) { - __pyx_t_1 = __pyx_v_rule->word_alignments; __Pyx_INCREF(__pyx_t_1); __pyx_t_8 = 0; - __pyx_t_9 = NULL; - } else { - __pyx_t_8 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rule->word_alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; - } - for (;;) { - if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_8); __Pyx_INCREF(__pyx_t_4); __pyx_t_8++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_4 = __pyx_t_9(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF(__pyx_v_point); - __pyx_v_point = __pyx_t_4; - __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyNumber_Remainder(__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_11); - PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_4 = 0; - __pyx_t_10 = 0; - if (unlikely(__Pyx_PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_11))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; - } + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rule), __pyx_n_s__alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_INCREF(((PyObject *)__pyx_t_5)); - __pyx_v_a = ((PyObject *)__pyx_t_5); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_a = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":48 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":45 * e.append(_sa.sym_tostring(esyms[i])) - * cdef a = [(point/65536, point%65536) for point in rule.word_alignments] + * a = list(rule.alignments()) * return TRule(lhs, f, e, scores, a) # <<<<<<<<<<<<<< * * cdef class TRule: */ __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_lhs); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_lhs); - __Pyx_GIVEREF(__pyx_v_lhs); + __pyx_t_2 = PyBytes_FromString(__pyx_v_lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __Pyx_INCREF(((PyObject *)__pyx_v_f)); - PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_v_f)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_f)); __Pyx_GIVEREF(((PyObject *)__pyx_v_f)); __Pyx_INCREF(((PyObject *)__pyx_v_e)); - PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)__pyx_v_e)); + PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_v_e)); __Pyx_GIVEREF(((PyObject *)__pyx_v_e)); - __Pyx_INCREF(__pyx_v_scores); - PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_scores); - __Pyx_GIVEREF(__pyx_v_scores); - __Pyx_INCREF(__pyx_v_a); - PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_a); - __Pyx_GIVEREF(__pyx_v_a); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1); - __pyx_t_1 = 0; + __Pyx_INCREF(((PyObject *)__pyx_v_scores)); + PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_v_scores)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_scores)); + __Pyx_INCREF(((PyObject *)__pyx_v_a)); + PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_a)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_a)); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_2); + __pyx_t_2 = 0; goto __pyx_L0; __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); + __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("_cdec.convert_rule", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_lhs); __Pyx_XDECREF(__pyx_v_scores); __Pyx_XDECREF(__pyx_v_f); __Pyx_XDECREF(__pyx_v_e); __Pyx_XDECREF(__pyx_v_a); - __Pyx_XDECREF(__pyx_v_point); __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -5873,7 +5883,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__f,&__pyx_n_s__e,&__pyx_n_s__scores,&__pyx_n_s__a,0}; PyObject* values[5] = {0,0,0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":53 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50 * cdef shared_ptr[grammar.TRule]* rule * * def __init__(self, lhs, f, e, scores, a=None): # <<<<<<<<<<<<<< @@ -5901,17 +5911,17 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__f)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (kw_args > 0) { @@ -5920,7 +5930,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5941,7 +5951,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5962,75 +5972,75 @@ static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":54 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":51 * * def __init__(self, lhs, f, e, scores, a=None): * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) # <<<<<<<<<<<<<< * self.lhs = lhs * self.e = e */ - try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} __pyx_v_self->rule = new boost::shared_ptr(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":55 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":52 * def __init__(self, lhs, f, e, scores, a=None): * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) * self.lhs = lhs # <<<<<<<<<<<<<< * self.e = e * self.f = f */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":53 * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) * self.lhs = lhs * self.e = e # <<<<<<<<<<<<<< * self.f = f * self.scores = scores */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":54 * self.lhs = lhs * self.e = e * self.f = f # <<<<<<<<<<<<<< * self.scores = scores * if a: */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":55 * self.e = e * self.f = f * self.scores = scores # <<<<<<<<<<<<<< * if a: * self.a = a */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":59 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56 * self.f = f * self.scores = scores * if a: # <<<<<<<<<<<<<< * self.a = a * self.rule.get().ComputeArity() */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":60 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57 * self.scores = scores * if a: * self.a = a # <<<<<<<<<<<<<< * self.rule.get().ComputeArity() * */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58 * if a: * self.a = a * self.rule.get().ComputeArity() # <<<<<<<<<<<<<< @@ -6058,7 +6068,7 @@ static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":63 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":60 * self.rule.get().ComputeArity() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -6070,7 +6080,7 @@ static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5 __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61 * * def __dealloc__(self): * del self.rule # <<<<<<<<<<<<<< @@ -6093,7 +6103,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":67 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64 * * property arity: * def __get__(self): # <<<<<<<<<<<<<< @@ -6110,7 +6120,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_T int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":68 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":65 * property arity: * def __get__(self): * return self.rule.get().arity_ # <<<<<<<<<<<<<< @@ -6118,7 +6128,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_T * property f: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->rule->get()->arity_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->rule->get()->arity_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6147,7 +6157,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":68 * * property f: * def __get__(self): # <<<<<<<<<<<<<< @@ -6174,7 +6184,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":72 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":69 * property f: * def __get__(self): * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<< @@ -6183,19 +6193,19 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71 * cdef vector[WordID]* f_ = &self.rule.get().f_ * cdef WordID w * cdef f = [] # <<<<<<<<<<<<<< * cdef unsigned i * cdef int idx = 0 */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_f = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":76 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":73 * cdef f = [] * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6204,7 +6214,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74 * cdef unsigned i * cdef int idx = 0 * for i in range(f_.size()): # <<<<<<<<<<<<<< @@ -6215,7 +6225,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":78 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":75 * cdef int idx = 0 * for i in range(f_.size()): * w = f_[0][i] # <<<<<<<<<<<<<< @@ -6224,7 +6234,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_w = ((__pyx_v_f_[0])[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":79 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":76 * for i in range(f_.size()): * w = f_[0][i] * if w < 0: # <<<<<<<<<<<<<< @@ -6234,7 +6244,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __pyx_t_4 = (__pyx_v_w < 0); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77 * w = f_[0][i] * if w < 0: * idx += 1 # <<<<<<<<<<<<<< @@ -6243,18 +6253,18 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":78 * if w < 0: * idx += 1 * f.append(NT(TDConvert(-w).c_str(), idx)) # <<<<<<<<<<<<<< * else: * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) */ - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); @@ -6262,10 +6272,10 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __Pyx_GIVEREF(__pyx_t_5); __pyx_t_1 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -6273,28 +6283,28 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80 * f.append(NT(TDConvert(-w).c_str(), idx)) * else: * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) # <<<<<<<<<<<<<< * return f * */ - __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6)); __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -6302,7 +6312,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81 * else: * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) * return f # <<<<<<<<<<<<<< @@ -6340,7 +6350,7 @@ static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":86 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83 * return f * * def __set__(self, f): # <<<<<<<<<<<<<< @@ -6365,7 +6375,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84 * * def __set__(self, f): * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<< @@ -6374,17 +6384,17 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":88 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":85 * def __set__(self, f): * cdef vector[WordID]* f_ = &self.rule.get().f_ * f_.resize(len(f)) # <<<<<<<<<<<<<< * cdef unsigned i * cdef int idx = 0 */ - __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87 * f_.resize(len(f)) * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6393,25 +6403,25 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":91 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":88 * cdef unsigned i * cdef int idx = 0 * for i in range(len(f)): # <<<<<<<<<<<<<< * if isinstance(f[i], NT): * f_[0][i] = -TDConvert(f[i].cat) */ - __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":92 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":89 * cdef int idx = 0 * for i in range(len(f)): * if isinstance(f[i], NT): # <<<<<<<<<<<<<< * f_[0][i] = -TDConvert(f[i].cat) * else: */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)); __Pyx_INCREF(__pyx_t_4); @@ -6420,35 +6430,35 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":93 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90 * for i in range(len(f)): * if isinstance(f[i], NT): * f_[0][i] = -TDConvert(f[i].cat) # <<<<<<<<<<<<<< * else: - * f_[0][i] = TDConvert(as_str(f[i])) + * f_[0][i] = TDConvert(as_str(f[i])) */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; ((__pyx_v_f_[0])[__pyx_v_i]) = (-TD::Convert(((char *)__pyx_t_6))); goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":95 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":92 * f_[0][i] = -TDConvert(f[i].cat) * else: - * f_[0][i] = TDConvert(as_str(f[i])) # <<<<<<<<<<<<<< + * f_[0][i] = TDConvert(as_str(f[i])) # <<<<<<<<<<<<<< * * property e: */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - ((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_t_3, NULL))); + ((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __pyx_L5:; @@ -6477,7 +6487,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":95 * * property e: * def __get__(self): # <<<<<<<<<<<<<< @@ -6504,7 +6514,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":99 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":96 * property e: * def __get__(self): * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<< @@ -6513,19 +6523,19 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98 * cdef vector[WordID]* e_ = &self.rule.get().e_ * cdef WordID w * cdef e = [] # <<<<<<<<<<<<<< * cdef unsigned i * cdef int idx = 0 */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_e = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":103 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":100 * cdef e = [] * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6534,7 +6544,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":104 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101 * cdef unsigned i * cdef int idx = 0 * for i in range(e_.size()): # <<<<<<<<<<<<<< @@ -6545,7 +6555,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":105 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":102 * cdef int idx = 0 * for i in range(e_.size()): * w = e_[0][i] # <<<<<<<<<<<<<< @@ -6554,7 +6564,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_w = ((__pyx_v_e_[0])[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":106 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":103 * for i in range(e_.size()): * w = e_[0][i] * if w < 1: # <<<<<<<<<<<<<< @@ -6564,7 +6574,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule __pyx_t_4 = (__pyx_v_w < 1); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":104 * w = e_[0][i] * if w < 1: * idx += 1 # <<<<<<<<<<<<<< @@ -6573,24 +6583,24 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":105 * if w < 1: * idx += 1 * e.append(NTRef(1-w)) # <<<<<<<<<<<<<< * else: * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) */ - __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -6598,28 +6608,28 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":110 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107 * e.append(NTRef(1-w)) * else: * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) # <<<<<<<<<<<<<< * return e * */ - __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -6627,7 +6637,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108 * else: * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) * return e # <<<<<<<<<<<<<< @@ -6665,7 +6675,7 @@ static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":113 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":110 * return e * * def __set__(self, e): # <<<<<<<<<<<<<< @@ -6689,7 +6699,7 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":114 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111 * * def __set__(self, e): * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<< @@ -6698,35 +6708,35 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":115 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":112 * def __set__(self, e): * cdef vector[WordID]* e_ = &self.rule.get().e_ * e_.resize(len(e)) # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(len(e)): */ - __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_e_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":117 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":114 * e_.resize(len(e)) * cdef unsigned i * for i in range(len(e)): # <<<<<<<<<<<<<< * if isinstance(e[i], NTRef): * e_[0][i] = 1-e[i].ref */ - __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":118 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":115 * cdef unsigned i * for i in range(len(e)): * if isinstance(e[i], NTRef): # <<<<<<<<<<<<<< * e_[0][i] = 1-e[i].ref * else: */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)); __Pyx_INCREF(__pyx_t_4); @@ -6735,38 +6745,38 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":119 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":116 * for i in range(len(e)): * if isinstance(e[i], NTRef): * e_[0][i] = 1-e[i].ref # <<<<<<<<<<<<<< * else: - * e_[0][i] = TDConvert(as_str(e[i])) + * e_[0][i] = TDConvert(as_str(e[i])) */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; ((__pyx_v_e_[0])[__pyx_v_i]) = __pyx_t_6; goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":118 * e_[0][i] = 1-e[i].ref * else: - * e_[0][i] = TDConvert(as_str(e[i])) # <<<<<<<<<<<<<< + * e_[0][i] = TDConvert(as_str(e[i])) # <<<<<<<<<<<<<< * * property a: */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - ((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL))); + ((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_L5:; @@ -6796,7 +6806,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121 * * property a: * def __get__(self): # <<<<<<<<<<<<<< @@ -6822,7 +6832,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -6859,9 +6869,9 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":126 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":123 * def __get__(self): * cdef unsigned i * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ # <<<<<<<<<<<<<< @@ -6870,7 +6880,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ */ __pyx_cur_scope->__pyx_v_a = (&__pyx_cur_scope->__pyx_v_self->rule->get()->a_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":127 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124 * cdef unsigned i * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ * for i in range(a.size()): # <<<<<<<<<<<<<< @@ -6881,18 +6891,18 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":128 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":125 * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ * for i in range(a.size()): * yield (a[0][i].s_, a[0][i].t_) # <<<<<<<<<<<<<< * * def __set__(self, a): */ - __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); @@ -6912,7 +6922,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -6940,7 +6950,7 @@ static int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":130 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":127 * yield (a[0][i].s_, a[0][i].t_) * * def __set__(self, a): # <<<<<<<<<<<<<< @@ -6969,7 +6979,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":131 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":128 * * def __set__(self, a): * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ # <<<<<<<<<<<<<< @@ -6978,35 +6988,35 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_a_ = (&__pyx_v_self->rule->get()->a_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":129 * def __set__(self, a): * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ * a_.resize(len(a)) # <<<<<<<<<<<<<< * cdef unsigned i * cdef int s, t */ - __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_a_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":135 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132 * cdef unsigned i * cdef int s, t * for i in range(len(a)): # <<<<<<<<<<<<<< * s, t = a[i] * a_[0][i] = grammar.AlignmentPoint(s, t) */ - __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":136 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":133 * cdef int s, t * for i in range(len(a)): * s, t = a[i] # <<<<<<<<<<<<<< * a_[0][i] = grammar.AlignmentPoint(s, t) * */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; @@ -7018,7 +7028,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -7031,14 +7041,14 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; - __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; @@ -7046,7 +7056,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_unpacking_done; @@ -7054,17 +7064,17 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } - __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_s = __pyx_t_8; __pyx_v_t = __pyx_t_9; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":137 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":134 * for i in range(len(a)): * s, t = a[i] * a_[0][i] = grammar.AlignmentPoint(s, t) # <<<<<<<<<<<<<< @@ -7099,7 +7109,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":137 * * property scores: * def __get__(self): # <<<<<<<<<<<<<< @@ -7117,20 +7127,20 @@ static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":141 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":138 * property scores: * def __get__(self): * cdef SparseVector scores = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * scores.vector = new FastSparseVector[double](self.rule.get().scores_) * return scores */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_scores = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":142 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":139 * def __get__(self): * cdef SparseVector scores = SparseVector.__new__(SparseVector) * scores.vector = new FastSparseVector[double](self.rule.get().scores_) # <<<<<<<<<<<<<< @@ -7139,7 +7149,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_ */ __pyx_v_scores->vector = new FastSparseVector(__pyx_v_self->rule->get()->scores_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140 * cdef SparseVector scores = SparseVector.__new__(SparseVector) * scores.vector = new FastSparseVector[double](self.rule.get().scores_) * return scores # <<<<<<<<<<<<<< @@ -7175,7 +7185,7 @@ static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":145 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":142 * return scores * * def __set__(self, scores): # <<<<<<<<<<<<<< @@ -7205,7 +7215,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":146 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143 * * def __set__(self, scores): * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ # <<<<<<<<<<<<<< @@ -7214,7 +7224,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_scores_ = (&__pyx_v_self->rule->get()->scores_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":147 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":144 * def __set__(self, scores): * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ * scores_.clear() # <<<<<<<<<<<<<< @@ -7223,23 +7233,23 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_scores_->clear(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":150 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":147 * cdef int fid * cdef float fval * for fname, fval in scores.items(): # <<<<<<<<<<<<<< - * fid = FDConvert(as_str(fname)) + * fid = FDConvert(as_str(fname)) * if fid < 0: raise KeyError(fname) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -7250,21 +7260,21 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_2 = __pyx_t_4(__pyx_t_1); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7280,7 +7290,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -7293,14 +7303,14 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -7308,7 +7318,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; @@ -7316,51 +7326,51 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_v_fname); __pyx_v_fname = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_fval = __pyx_t_9; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":151 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":148 * cdef float fval * for fname, fval in scores.items(): - * fid = FDConvert(as_str(fname)) # <<<<<<<<<<<<<< + * fid = FDConvert(as_str(fname)) # <<<<<<<<<<<<<< * if fid < 0: raise KeyError(fname) * scores_.set_value(fid, fval) */ - __pyx_v_fid = FD::Convert(((char *)__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL))); + __pyx_v_fid = FD::Convert(__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":152 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":149 * for fname, fval in scores.items(): - * fid = FDConvert(as_str(fname)) + * fid = FDConvert(as_str(fname)) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * scores_.set_value(fid, fval) * */ __pyx_t_10 = (__pyx_v_fid < 0); if (__pyx_t_10) { - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_fname); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fname); __Pyx_GIVEREF(__pyx_v_fname); - __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L7; } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153 - * fid = FDConvert(as_str(fname)) + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":150 + * fid = FDConvert(as_str(fname)) * if fid < 0: raise KeyError(fname) * scores_.set_value(fid, fval) # <<<<<<<<<<<<<< * @@ -7397,7 +7407,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":156 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153 * * property lhs: * def __get__(self): # <<<<<<<<<<<<<< @@ -7415,7 +7425,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":157 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":154 * property lhs: * def __get__(self): * return NT(TDConvert(-self.rule.get().lhs_).c_str()) # <<<<<<<<<<<<<< @@ -7423,14 +7433,14 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu * def __set__(self, lhs): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -7461,7 +7471,7 @@ static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":159 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":156 * return NT(TDConvert(-self.rule.get().lhs_).c_str()) * * def __set__(self, lhs): # <<<<<<<<<<<<<< @@ -7483,7 +7493,7 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_lhs); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":160 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":157 * * def __set__(self, lhs): * if not isinstance(lhs, NT): # <<<<<<<<<<<<<< @@ -7497,19 +7507,19 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":158 * def __set__(self, lhs): * if not isinstance(lhs, NT): * lhs = NT(lhs) # <<<<<<<<<<<<<< * self.rule.get().lhs_ = -TDConvert(lhs.cat) * */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_lhs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_lhs); __Pyx_GIVEREF(__pyx_v_lhs); - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_v_lhs); @@ -7519,16 +7529,16 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":159 * if not isinstance(lhs, NT): * lhs = NT(lhs) * self.rule.get().lhs_ = -TDConvert(lhs.cat) # <<<<<<<<<<<<<< * * def __str__(self): */ - __pyx_t_4 = PyObject_GetAttr(__pyx_v_lhs, __pyx_n_s__cat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_GetAttr(__pyx_v_lhs, __pyx_n_s__cat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v_self->rule->get()->lhs_ = (-TD::Convert(((char *)__pyx_t_5))); @@ -7557,7 +7567,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self) { } static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< @@ -7583,7 +7593,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self) { __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_7__str___2generator19, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_7__str___2generator19, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -7619,15 +7629,15 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -7638,21 +7648,21 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_1 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7663,7 +7673,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_feat = __pyx_t_1; __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; @@ -7682,7 +7692,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj __Pyx_XGOTREF(__pyx_t_2); __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; __pyx_t_4 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetNone(PyExc_StopIteration); @@ -7699,7 +7709,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161 * self.rule.get().lhs_ = -TDConvert(lhs.cat) * * def __str__(self): # <<<<<<<<<<<<<< @@ -7731,30 +7741,30 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":165 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< * return '%s ||| %s ||| %s ||| %s' % (self.lhs, * _phrase(self.f), _phrase(self.e), scores) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __pyx_pf_5_cdec_5TRule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_pf_5_cdec_5TRule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_scores = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":166 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":163 * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) * return '%s ||| %s ||| %s ||| %s' % (self.lhs, # <<<<<<<<<<<<<< @@ -7762,43 +7772,43 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":167 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164 * scores = ' '.join('%s=%s' % feat for feat in self.scores) * return '%s ||| %s ||| %s ||| %s' % (self.lhs, * _phrase(self.f), _phrase(self.e), scores) # <<<<<<<<<<<<<< * * cdef class MRule(TRule): */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -7812,7 +7822,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_r = ((PyObject *)__pyx_t_3); @@ -7851,7 +7861,7 @@ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,&__pyx_n_s__a,0}; PyObject* values[4] = {0,0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":170 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":167 * * cdef class MRule(TRule): * def __init__(self, lhs, rhs, scores, a=None): # <<<<<<<<<<<<<< @@ -7878,12 +7888,12 @@ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rhs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (kw_args > 0) { @@ -7892,7 +7902,7 @@ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7911,7 +7921,7 @@ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -7940,7 +7950,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":168 * cdef class MRule(TRule): * def __init__(self, lhs, rhs, scores, a=None): * cdef unsigned i = 1 # <<<<<<<<<<<<<< @@ -7949,19 +7959,19 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ */ __pyx_v_i = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169 * def __init__(self, lhs, rhs, scores, a=None): * cdef unsigned i = 1 * e = [] # <<<<<<<<<<<<<< * for s in rhs: * if isinstance(s, NT): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":170 * cdef unsigned i = 1 * e = [] * for s in rhs: # <<<<<<<<<<<<<< @@ -7972,7 +7982,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __pyx_t_1 = __pyx_v_rhs; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -7982,21 +7992,21 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -8006,7 +8016,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __pyx_v_s = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":174 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171 * e = [] * for s in rhs: * if isinstance(s, NT): # <<<<<<<<<<<<<< @@ -8019,27 +8029,27 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172 * for s in rhs: * if isinstance(s, NT): * e.append(NTRef(i)) # <<<<<<<<<<<<<< * i += 1 * else: */ - __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173 * if isinstance(s, NT): * e.append(NTRef(i)) * i += 1 # <<<<<<<<<<<<<< @@ -8051,27 +8061,27 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":178 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175 * i += 1 * else: * e.append(s) # <<<<<<<<<<<<<< * super(MRule, self).__init__(lhs, rhs, e, scores, a) * */ - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L5:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":179 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176 * else: * e.append(s) * super(MRule, self).__init__(lhs, rhs, e, scores, a) # <<<<<<<<<<<<<< * * cdef class Grammar: */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule))); @@ -8079,13 +8089,13 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_lhs); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_lhs); @@ -8102,7 +8112,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_INCREF(__pyx_v_a); PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_a); __Pyx_GIVEREF(__pyx_v_a); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -8132,7 +8142,7 @@ static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181 * cdef shared_ptr[grammar.Grammar]* grammar * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -8144,7 +8154,7 @@ static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":185 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":182 * * def __dealloc__(self): * del self.grammar # <<<<<<<<<<<<<< @@ -8168,7 +8178,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":187 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184 * del self.grammar * * def __iter__(self): # <<<<<<<<<<<<<< @@ -8194,7 +8204,7 @@ static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Gram __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -8229,9 +8239,9 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":188 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":185 * * def __iter__(self): * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<< @@ -8240,7 +8250,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_root = __pyx_cur_scope->__pyx_v_self->grammar->get()->GetRoot(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":186 * def __iter__(self): * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() * cdef grammar.const_RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<< @@ -8249,7 +8259,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_rbin = __pyx_cur_scope->__pyx_v_root->GetRules(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189 * cdef TRule trule * cdef unsigned i * for i in range(rbin.GetNumRules()): # <<<<<<<<<<<<<< @@ -8260,23 +8270,23 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":193 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":190 * cdef unsigned i * for i in range(rbin.GetNumRules()): * trule = TRule.__new__(TRule) # <<<<<<<<<<<<<< * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) * yield trule */ - __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule)); __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule)); __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":194 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":191 * for i in range(rbin.GetNumRules()): * trule = TRule.__new__(TRule) * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) # <<<<<<<<<<<<<< @@ -8285,7 +8295,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_trule->rule = new boost::shared_ptr(__pyx_cur_scope->__pyx_v_rbin->GetIthRule(__pyx_cur_scope->__pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192 * trule = TRule.__new__(TRule) * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) * yield trule # <<<<<<<<<<<<<< @@ -8304,7 +8314,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -8330,7 +8340,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_4name_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195 * * property name: * def __get__(self): # <<<<<<<<<<<<<< @@ -8348,21 +8358,21 @@ static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":196 * property name: * def __get__(self): * str(self.grammar.get().GetGrammarName().c_str()) # <<<<<<<<<<<<<< * * def __set__(self, name): */ - __pyx_t_1 = PyBytes_FromString(__pyx_v_self->grammar->get()->GetGrammarName().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_v_self->grammar->get()->GetGrammarName().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -8391,7 +8401,7 @@ static int __pyx_pw_5_cdec_7Grammar_4name_3__set__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198 * str(self.grammar.get().GetGrammarName().c_str()) * * def __set__(self, name): # <<<<<<<<<<<<<< @@ -8408,14 +8418,14 @@ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Gramm int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":202 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199 * * def __set__(self, name): * self.grammar.get().SetGrammarName(string(name)) # <<<<<<<<<<<<<< * * cdef class TextGrammar(Grammar): */ - __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->grammar->get()->SetGrammarName(std::string(((char *)__pyx_t_1))); __pyx_r = 0; @@ -8453,7 +8463,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -8464,7 +8474,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -8475,7 +8485,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":205 +/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":202 * * cdef class TextGrammar(Grammar): * def __cinit__(self, rules): # <<<<<<<<<<<<<< @@ -8500,7 +8510,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":206 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":203 * cdef class TextGrammar(Grammar): * def __cinit__(self, rules): * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) # <<<<<<<<<<<<<< @@ -8509,7 +8519,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG */ __pyx_v_self->__pyx_base.grammar = new boost::shared_ptr(new TextGrammar()); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":207 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":204 * def __cinit__(self, rules): * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) * cdef grammar.TextGrammar* _g = self.grammar.get() # <<<<<<<<<<<<<< @@ -8518,7 +8528,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG */ __pyx_v__g = ((TextGrammar *)__pyx_v_self->__pyx_base.grammar->get()); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":208 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":205 * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) * cdef grammar.TextGrammar* _g = self.grammar.get() * for trule in rules: # <<<<<<<<<<<<<< @@ -8529,7 +8539,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_t_1 = __pyx_v_rules; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -8539,21 +8549,21 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -8563,7 +8573,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_v_trule = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":206 * cdef grammar.TextGrammar* _g = self.grammar.get() * for trule in rules: * if isinstance(trule, _sa.Rule): # <<<<<<<<<<<<<< @@ -8576,17 +8586,17 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":210 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":207 * for trule in rules: * if isinstance(trule, _sa.Rule): * trule = convert_rule(trule) # <<<<<<<<<<<<<< * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') */ - if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = __pyx_v_trule; __Pyx_INCREF(__pyx_t_4); - __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_v_trule); @@ -8595,7 +8605,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG goto __pyx_L5; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":211 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":208 * if isinstance(trule, _sa.Rule): * trule = convert_rule(trule) * elif not isinstance(trule, TRule): # <<<<<<<<<<<<<< @@ -8609,22 +8619,22 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_t_7 = (!__pyx_t_5); if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209 * trule = convert_rule(trule) * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<< * _g.AddRule(( trule).rule[0]) */ - __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":213 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":210 * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') * _g.AddRule(( trule).rule[0]) # <<<<<<<<<<<<<< @@ -10217,7 +10227,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject * finally: * del trees # <<<<<<<<<<<<<< * - * def intersect(self, Lattice lat): + * def intersect(self, inp): */ /*finally:*/ { int __pyx_why; @@ -10261,17 +10271,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_lat); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_lat) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /*proto*/ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_inp) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("intersect (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lat), __pyx_ptype_5_cdec_Lattice, 1, "lat", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_25intersect(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_lat)); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_25intersect(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_inp)); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -10279,41 +10284,128 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":101 * del trees * - * def intersect(self, Lattice lat): # <<<<<<<<<<<<<< - * return hypergraph.Intersect(lat.lattice[0], self.hg) - * + * def intersect(self, inp): # <<<<<<<<<<<<<< + * cdef Lattice lat + * if isinstance(inp, Lattice): */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, struct __pyx_obj_5_cdec_Lattice *__pyx_v_lat) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_inp) { + struct __pyx_obj_5_cdec_Lattice *__pyx_v_lat = 0; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("intersect", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":102 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":103 + * def intersect(self, inp): + * cdef Lattice lat + * if isinstance(inp, Lattice): # <<<<<<<<<<<<<< + * lat = inp + * elif isinstance(inp, basestring): + */ + __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_inp, __pyx_t_1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":104 + * cdef Lattice lat + * if isinstance(inp, Lattice): + * lat = inp # <<<<<<<<<<<<<< + * elif isinstance(inp, basestring): + * lat = Lattice(inp) + */ + __Pyx_INCREF(((PyObject *)((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_inp))); + __pyx_v_lat = ((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_inp); + goto __pyx_L3; + } + + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":105 + * if isinstance(inp, Lattice): + * lat = inp + * elif isinstance(inp, basestring): # <<<<<<<<<<<<<< + * lat = Lattice(inp) + * else: + */ + __pyx_t_1 = __pyx_builtin_basestring; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_inp, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":106 + * lat = inp + * elif isinstance(inp, basestring): + * lat = Lattice(inp) # <<<<<<<<<<<<<< + * else: + * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) + */ + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_inp); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_inp); + __Pyx_GIVEREF(__pyx_v_inp); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_lat = ((struct __pyx_obj_5_cdec_Lattice *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":108 + * lat = Lattice(inp) + * else: + * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) # <<<<<<<<<<<<<< + * return hypergraph.Intersect(lat.lattice[0], self.hg) * - * def intersect(self, Lattice lat): + */ + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L3:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":109 + * else: + * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) * return hypergraph.Intersect(lat.lattice[0], self.hg) # <<<<<<<<<<<<<< * * def prune(self, beam_alpha=0, density=0, **kwargs): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_3 = __Pyx_PyBool_FromLong(HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_cdec.Hypergraph.intersect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_lat); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; @@ -10358,7 +10450,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, Py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "prune") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "prune") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -10373,7 +10465,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("prune", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("prune", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; __Pyx_AddTraceback("_cdec.Hypergraph.prune", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -10386,7 +10478,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":104 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":111 * return hypergraph.Intersect(lat.lattice[0], self.hg) * * def prune(self, beam_alpha=0, density=0, **kwargs): # <<<<<<<<<<<<<< @@ -10406,7 +10498,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prune", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":105 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":112 * * def prune(self, beam_alpha=0, density=0, **kwargs): * cdef hypergraph.EdgeMask* preserve_mask = NULL # <<<<<<<<<<<<<< @@ -10415,17 +10507,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy */ __pyx_v_preserve_mask = NULL; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":106 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113 * def prune(self, beam_alpha=0, density=0, **kwargs): * cdef hypergraph.EdgeMask* preserve_mask = NULL * if 'csplit_preserve_full_word' in kwargs: # <<<<<<<<<<<<<< * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True */ - __pyx_t_1 = ((PyDict_Contains(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s_15)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyDict_Contains(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s_16)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":107 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":114 * cdef hypergraph.EdgeMask* preserve_mask = NULL * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) # <<<<<<<<<<<<<< @@ -10434,7 +10526,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy */ __pyx_v_preserve_mask = new std::vector(__pyx_v_self->hg->edges_.size()); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":108 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":115 * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True # <<<<<<<<<<<<<< @@ -10446,18 +10538,18 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":109 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":116 * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) # <<<<<<<<<<<<<< * if preserve_mask: * del preserve_mask */ - __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_beam_alpha); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_density); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_beam_alpha); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_density); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->hg->PruneInsideOutside(__pyx_t_2, __pyx_t_3, __pyx_v_preserve_mask, 0, 1.0, 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":110 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":117 * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) * if preserve_mask: # <<<<<<<<<<<<<< @@ -10467,7 +10559,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy __pyx_t_1 = (__pyx_v_preserve_mask != 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":111 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":118 * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) * if preserve_mask: * del preserve_mask # <<<<<<<<<<<<<< @@ -10501,7 +10593,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_30lattice(PyObject *__pyx_v_self, return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":120 * del preserve_mask * * def lattice(self): # TODO direct hg -> lattice conversion in cdec # <<<<<<<<<<<<<< @@ -10521,37 +10613,37 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("lattice", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":114 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":121 * * def lattice(self): # TODO direct hg -> lattice conversion in cdec * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() # <<<<<<<<<<<<<< * return Lattice(eval(plf)) * */ - __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_plf = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":115 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":122 * def lattice(self): # TODO direct hg -> lattice conversion in cdec * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() * return Lattice(eval(plf)) # <<<<<<<<<<<<<< * - * def reweight(self, weights): + * def plf(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); if (((PyObject *)__pyx_v_plf)) { - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__plf), ((PyObject *)__pyx_v_plf)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__plf), ((PyObject *)__pyx_v_plf)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (((PyObject *)__pyx_v_self)) { - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_plf)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_plf)); @@ -10562,15 +10654,15 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_ __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -10593,25 +10685,89 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_ } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_32reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_32reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("reweight (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_31reweight(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_weights)); + __Pyx_RefNannySetupContext("plf (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_31plf(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":117 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":124 * return Lattice(eval(plf)) * + * def plf(self): # <<<<<<<<<<<<<< + * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) + * + */ + +static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("plf", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":125 + * + * def plf(self): + * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) # <<<<<<<<<<<<<< + * + * def reweight(self, weights): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Hypergraph.plf", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reweight (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_33reweight(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self), ((PyObject *)__pyx_v_weights)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":127 + * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) + * * def reweight(self, weights): # <<<<<<<<<<<<<< * if isinstance(weights, SparseVector): * self.hg.Reweight(( weights).vector[0]) */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -10622,7 +10778,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec int __pyx_clineno = 0; __Pyx_RefNannySetupContext("reweight", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":118 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":128 * * def reweight(self, weights): * if isinstance(weights, SparseVector): # <<<<<<<<<<<<<< @@ -10635,7 +10791,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":119 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":129 * def reweight(self, weights): * if isinstance(weights, SparseVector): * self.hg.Reweight(( weights).vector[0]) # <<<<<<<<<<<<<< @@ -10646,7 +10802,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":120 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":130 * if isinstance(weights, SparseVector): * self.hg.Reweight(( weights).vector[0]) * elif isinstance(weights, DenseVector): # <<<<<<<<<<<<<< @@ -10659,7 +10815,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":121 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":131 * self.hg.Reweight(( weights).vector[0]) * elif isinstance(weights, DenseVector): * self.hg.Reweight(( weights).vector[0]) # <<<<<<<<<<<<<< @@ -10671,26 +10827,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31reweight(struct __pyx_obj_5_cdec } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":123 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":133 * self.hg.Reweight(( weights).vector[0]) * else: * raise TypeError('cannot reweight hypergraph with %s' % type(weights)) # <<<<<<<<<<<<<< * * property edges: */ - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_16), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -10719,7 +10875,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":126 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136 * * property edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -10745,7 +10901,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_ __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5edges_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5edges_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -10781,9 +10937,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_Generator return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":128 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":138 * def __get__(self): * cdef unsigned i * for i in range(self.hg.edges_.size()): # <<<<<<<<<<<<<< @@ -10794,16 +10950,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_Generator for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":129 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":139 * cdef unsigned i * for i in range(self.hg.edges_.size()): * yield HypergraphEdge().init(self.hg, i) # <<<<<<<<<<<<<< * * property nodes: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -10818,7 +10974,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_Generator __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -10846,7 +11002,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":132 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":142 * * property nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -10872,7 +11028,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_ __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -10908,9 +11064,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_Generato return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":134 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":144 * def __get__(self): * cdef unsigned i * for i in range(self.hg.nodes_.size()): # <<<<<<<<<<<<<< @@ -10921,16 +11077,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_Generato for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":135 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":145 * cdef unsigned i * for i in range(self.hg.nodes_.size()): * yield HypergraphNode().init(self.hg, i) # <<<<<<<<<<<<<< * * property goal: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -10945,7 +11101,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_Generato __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -10972,7 +11128,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_4goal_1__get__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":138 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":148 * * property goal: * def __get__(self): # <<<<<<<<<<<<<< @@ -10990,7 +11146,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_c int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":139 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":149 * property goal: * def __get__(self): * return HypergraphNode().init(self.hg, self.hg.GoalNode()) # <<<<<<<<<<<<<< @@ -10998,9 +11154,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_c * property npaths: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->hg->GoalNode()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->hg->GoalNode()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -11031,7 +11187,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_6npaths_1__get__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":142 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":152 * * property npaths: * def __get__(self): # <<<<<<<<<<<<<< @@ -11048,7 +11204,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":143 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":153 * property npaths: * def __get__(self): * return self.hg.NumberOfPaths() # <<<<<<<<<<<<<< @@ -11056,7 +11212,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 * def inside_outside(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->hg->NumberOfPaths()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->hg->NumberOfPaths()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11075,17 +11231,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_34inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_cdec_10Hypergraph_34inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("inside_outside (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_10Hypergraph_33inside_outside(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_10Hypergraph_35inside_outside(((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":145 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":155 * return self.hg.NumberOfPaths() * * def inside_outside(self): # <<<<<<<<<<<<<< @@ -11093,7 +11249,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_34inside_outside(PyObject *__pyx_v * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) */ -static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { +static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { FastSparseVector *__pyx_v_result; prob_t __pyx_v_z; struct __pyx_obj_5_cdec_SparseVector *__pyx_v_vector = 0; @@ -11109,7 +11265,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("inside_outside", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":146 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":156 * * def inside_outside(self): * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() # <<<<<<<<<<<<<< @@ -11118,7 +11274,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ __pyx_v_result = new FastSparseVector(); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":147 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":157 * def inside_outside(self): * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) # <<<<<<<<<<<<<< @@ -11127,7 +11283,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ __pyx_v_z = InsideOutside, EdgeFeaturesAndProbWeightFunction>((__pyx_v_self->hg[0]), __pyx_v_result); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":148 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":158 * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z # <<<<<<<<<<<<<< @@ -11136,20 +11292,20 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ (__pyx_v_result[0]) /= __pyx_v_z; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":149 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":159 * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * vector.vector = new FastSparseVector[double]() * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":150 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":160 * result[0] /= z * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double]() # <<<<<<<<<<<<<< @@ -11158,7 +11314,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ __pyx_v_vector->vector = new FastSparseVector(); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":151 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":161 * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double]() * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) # <<<<<<<<<<<<<< @@ -11167,7 +11323,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ __pyx_v_it = new FastSparseVector::const_iterator((__pyx_v_result[0]), 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":153 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":163 * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) * cdef unsigned i * for i in range(result.size()): # <<<<<<<<<<<<<< @@ -11178,7 +11334,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":154 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":164 * cdef unsigned i * for i in range(result.size()): * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) # <<<<<<<<<<<<<< @@ -11187,7 +11343,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ __pyx_v_vector->vector->set_value((__pyx_v_it[0]).operator->()->first, log((__pyx_v_it[0]).operator->()->second)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":155 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":165 * for i in range(result.size()): * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) * pinc(it[0]) # ++it # <<<<<<<<<<<<<< @@ -11197,7 +11353,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ (++(__pyx_v_it[0])); } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":156 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":166 * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) * pinc(it[0]) # ++it * del it # <<<<<<<<<<<<<< @@ -11206,7 +11362,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ delete __pyx_v_it; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":157 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167 * pinc(it[0]) # ++it * del it * del result # <<<<<<<<<<<<<< @@ -11215,7 +11371,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ */ delete __pyx_v_result; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":158 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":168 * del it * del result * return vector # <<<<<<<<<<<<<< @@ -11240,7 +11396,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33inside_outside(struct __pyx_obj_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":165 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":175 * cdef public TRule trule * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<< @@ -11257,7 +11413,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":166 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":176 * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg # <<<<<<<<<<<<<< @@ -11266,7 +11422,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->hg = __pyx_v_hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":177 * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg * self.edge = &hg.edges_[i] # <<<<<<<<<<<<<< @@ -11275,23 +11431,23 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->edge = (&(__pyx_v_hg->edges_[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":168 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":178 * self.hg = hg * self.edge = &hg.edges_[i] * self.trule = TRule.__new__(TRule) # <<<<<<<<<<<<<< * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) * return self */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->trule); __Pyx_DECREF(((PyObject *)__pyx_v_self->trule)); __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":169 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":179 * self.edge = &hg.edges_[i] * self.trule = TRule.__new__(TRule) * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) # <<<<<<<<<<<<<< @@ -11300,7 +11456,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->trule->rule = new boost::shared_ptr(__pyx_v_self->edge->rule_); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":170 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":180 * self.trule = TRule.__new__(TRule) * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) * return self # <<<<<<<<<<<<<< @@ -11335,7 +11491,7 @@ static Py_ssize_t __pyx_pw_5_cdec_14HypergraphEdge_1__len__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":172 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":182 * return self * * def __len__(self): # <<<<<<<<<<<<<< @@ -11348,7 +11504,7 @@ static Py_ssize_t __pyx_pf_5_cdec_14HypergraphEdge___len__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":173 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":183 * * def __len__(self): * return self.edge.tail_nodes_.size() # <<<<<<<<<<<<<< @@ -11375,7 +11531,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":176 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":186 * * property head_node: * def __get__(self): # <<<<<<<<<<<<<< @@ -11393,7 +11549,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":177 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":187 * property head_node: * def __get__(self): * return HypergraphNode().init(self.hg, self.edge.head_node_) # <<<<<<<<<<<<<< @@ -11401,9 +11557,9 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py * property tail_nodes: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->edge->head_node_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->edge->head_node_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -11435,7 +11591,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":180 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190 * * property tail_nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -11461,7 +11617,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __ __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -11497,9 +11653,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__py return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":182 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":192 * def __get__(self): * cdef unsigned i * for i in range(self.edge.tail_nodes_.size()): # <<<<<<<<<<<<<< @@ -11510,16 +11666,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__py for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":183 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193 * cdef unsigned i * for i in range(self.edge.tail_nodes_.size()): * yield HypergraphNode().init(self.hg, self.edge.tail_nodes_[i]) # <<<<<<<<<<<<<< * * property span: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->edge->tail_nodes_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->edge->tail_nodes_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -11534,7 +11690,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__py __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11561,7 +11717,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":186 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":196 * * property span: * def __get__(self): # <<<<<<<<<<<<<< @@ -11580,7 +11736,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":187 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":197 * property span: * def __get__(self): * return (self.edge.i_, self.edge.j_) # <<<<<<<<<<<<<< @@ -11588,11 +11744,11 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj * property feature_values: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->edge->i_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->edge->i_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->edge->j_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->edge->j_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __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); @@ -11629,7 +11785,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(PyOb return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":200 * * property feature_values: * def __get__(self): # <<<<<<<<<<<<<< @@ -11647,20 +11803,20 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":191 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":201 * property feature_values: * def __get__(self): * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * vector.vector = new FastSparseVector[double](self.edge.feature_values_) * return vector */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":192 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":202 * def __get__(self): * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double](self.edge.feature_values_) # <<<<<<<<<<<<<< @@ -11669,7 +11825,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc */ __pyx_v_vector->vector = new FastSparseVector(__pyx_v_self->edge->feature_values_); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203 * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double](self.edge.feature_values_) * return vector # <<<<<<<<<<<<<< @@ -11705,7 +11861,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":196 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":206 * * property prob: * def __get__(self): # <<<<<<<<<<<<<< @@ -11722,7 +11878,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":197 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":207 * property prob: * def __get__(self): * return self.edge.edge_prob_.as_float() # <<<<<<<<<<<<<< @@ -11730,7 +11886,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->edge->edge_prob_.as_float()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->edge->edge_prob_.as_float()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11754,8 +11910,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphEdge, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphEdge, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphEdge, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphEdge, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_x), ((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_y), ((int)__pyx_v_op)); goto __pyx_L0; __pyx_L1_error:; @@ -11765,7 +11921,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":199 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":209 * return self.edge.edge_prob_.as_float() * * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): # <<<<<<<<<<<<<< @@ -11783,7 +11939,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":202 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":212 * if op == 2: # == * return x.edge == y.edge * elif op == 3: # != # <<<<<<<<<<<<<< @@ -11792,7 +11948,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":200 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":210 * * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -11801,7 +11957,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":201 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":211 * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): * if op == 2: # == * return x.edge == y.edge # <<<<<<<<<<<<<< @@ -11809,14 +11965,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->edge == __pyx_v_y->edge)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->edge == __pyx_v_y->edge)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; break; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":202 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":212 * if op == 2: # == * return x.edge == y.edge * elif op == 3: # != # <<<<<<<<<<<<<< @@ -11825,7 +11981,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":213 * return x.edge == y.edge * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< @@ -11833,11 +11989,11 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11845,18 +12001,18 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":204 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":214 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<< * * cdef class HypergraphNode: */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_18), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -11881,7 +12037,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(PyObject *__py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":163 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":173 * cdef hypergraph.Hypergraph* hg * cdef hypergraph.HypergraphEdge* edge * cdef public TRule trule # <<<<<<<<<<<<<< @@ -11923,7 +12079,7 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_2__set__(struct __pyx_obj_5_c const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5_cdec_TRule))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5_cdec_TRule))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->trule); @@ -11966,7 +12122,7 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(struct __pyx_obj_5_c return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":210 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":220 * cdef hypergraph.HypergraphNode* node * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<< @@ -11979,7 +12135,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":211 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":221 * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg # <<<<<<<<<<<<<< @@ -11988,7 +12144,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->hg = __pyx_v_hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":212 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":222 * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg * self.node = &hg.nodes_[i] # <<<<<<<<<<<<<< @@ -11997,7 +12153,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->node = (&(__pyx_v_hg->nodes_[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":213 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":223 * self.hg = hg * self.node = &hg.nodes_[i] * return self # <<<<<<<<<<<<<< @@ -12028,7 +12184,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(PyObject *_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":226 * * property in_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -12054,7 +12210,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(struct __pyx __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -12090,9 +12246,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_G return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":218 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":228 * def __get__(self): * cdef unsigned i * for i in range(self.node.in_edges_.size()): # <<<<<<<<<<<<<< @@ -12103,16 +12259,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_G for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":219 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":229 * cdef unsigned i * for i in range(self.node.in_edges_.size()): * yield HypergraphEdge().init(self.hg, self.node.in_edges_[i]) # <<<<<<<<<<<<<< * * property out_edges: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->in_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->in_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -12127,7 +12283,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_G __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -12155,7 +12311,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":222 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":232 * * property out_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -12181,7 +12337,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __py __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -12217,9 +12373,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":224 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":234 * def __get__(self): * cdef unsigned i * for i in range(self.node.out_edges_.size()): # <<<<<<<<<<<<<< @@ -12230,16 +12386,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":225 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":235 * cdef unsigned i * for i in range(self.node.out_edges_.size()): * yield HypergraphEdge().init(self.hg, self.node.out_edges_[i]) # <<<<<<<<<<<<<< * * property span: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->out_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->out_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -12254,7 +12410,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_ __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -12281,7 +12437,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_4span_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":228 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":238 * * property span: * def __get__(self): # <<<<<<<<<<<<<< @@ -12299,7 +12455,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":229 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":239 * property span: * def __get__(self): * return next(self.in_edges).span # <<<<<<<<<<<<<< @@ -12307,12 +12463,12 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj * property cat: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__in_edges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__in_edges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__span); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__span); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -12343,7 +12499,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_3cat_1__get__(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":232 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":242 * * property cat: * def __get__(self): # <<<<<<<<<<<<<< @@ -12361,7 +12517,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":233 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":243 * property cat: * def __get__(self): * if self.node.cat_: # <<<<<<<<<<<<<< @@ -12370,7 +12526,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ */ if (__pyx_v_self->node->cat_) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":234 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":244 * def __get__(self): * if self.node.cat_: * return str(TDConvert(-self.node.cat_).c_str()) # <<<<<<<<<<<<<< @@ -12378,14 +12534,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->node->cat_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->node->cat_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -12414,8 +12570,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphNode, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphNode, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphNode, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphNode, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_14HypergraphNode___richcmp__(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_x), ((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_y), ((int)__pyx_v_op)); goto __pyx_L0; __pyx_L1_error:; @@ -12425,7 +12581,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":236 +/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":246 * return str(TDConvert(-self.node.cat_).c_str()) * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): # <<<<<<<<<<<<<< @@ -12443,7 +12599,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":239 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":249 * if op == 2: # == * return x.node == y.node * elif op == 3: # != # <<<<<<<<<<<<<< @@ -12452,7 +12608,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":237 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":247 * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -12461,7 +12617,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":238 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":248 * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): * if op == 2: # == * return x.node == y.node # <<<<<<<<<<<<<< @@ -12469,14 +12625,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->node == __pyx_v_y->node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 238; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->node == __pyx_v_y->node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; break; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":239 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":249 * if op == 2: # == * return x.node == y.node * elif op == 3: # != # <<<<<<<<<<<<<< @@ -12485,18 +12641,18 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":240 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":250 * return x.node == y.node * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< * raise NotImplemented('comparison not implemented for HypergraphNode') */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -12504,16 +12660,16 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":241 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":251 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphNode') # <<<<<<<<<<<<<< */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -12530,10 +12686,51 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 /* Python wrapper */ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_inp = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; + __pyx_r = __pyx_pf_5_cdec_7Lattice___cinit__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":6 + * cdef lattice.Lattice* lattice + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self.lattice = new lattice.Lattice() + * + */ + +static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":7 + * + * def __cinit__(self): + * self.lattice = new lattice.Lattice() # <<<<<<<<<<<<<< + * + * def __init__(self, inp): + */ + __pyx_v_self->lattice = new Lattice(); + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_inp = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__inp,0}; PyObject* values[1] = {0}; @@ -12552,7 +12749,7 @@ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -12563,26 +12760,26 @@ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_cdec.Lattice.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Lattice.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_7Lattice___cinit__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), __pyx_v_inp); + __pyx_r = __pyx_pf_5_cdec_7Lattice_2__init__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), __pyx_v_inp); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":6 - * cdef lattice.Lattice* lattice +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":9 + * self.lattice = new lattice.Lattice() * - * def __cinit__(self, inp): # <<<<<<<<<<<<<< + * def __init__(self, inp): # <<<<<<<<<<<<<< * if isinstance(inp, tuple): - * self.lattice = new lattice.Lattice(len(inp)) + * self.lattice.resize(len(inp)) */ -static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp) { +static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp) { PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_arcs = NULL; int __pyx_r; @@ -12598,14 +12795,14 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); + __Pyx_RefNannySetupContext("__init__", 0); __Pyx_INCREF(__pyx_v_inp); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":7 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":10 * - * def __cinit__(self, inp): + * def __init__(self, inp): * if isinstance(inp, tuple): # <<<<<<<<<<<<<< - * self.lattice = new lattice.Lattice(len(inp)) + * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): */ __pyx_t_1 = ((PyObject *)((PyObject*)(&PyTuple_Type))); @@ -12614,19 +12811,19 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":8 - * def __cinit__(self, inp): + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":11 + * def __init__(self, inp): * if isinstance(inp, tuple): - * self.lattice = new lattice.Lattice(len(inp)) # <<<<<<<<<<<<<< + * self.lattice.resize(len(inp)) # <<<<<<<<<<<<<< * for i, arcs in enumerate(inp): * self[i] = arcs */ - __pyx_t_3 = PyObject_Length(__pyx_v_inp); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->lattice = new Lattice(__pyx_t_3); + __pyx_t_3 = PyObject_Length(__pyx_v_inp); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->lattice->resize(__pyx_t_3); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":9 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":12 * if isinstance(inp, tuple): - * self.lattice = new lattice.Lattice(len(inp)) + * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): # <<<<<<<<<<<<<< * self[i] = arcs * else: @@ -12637,7 +12834,7 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __pyx_t_4 = __pyx_v_inp; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; } @@ -12647,21 +12844,21 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_4)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_6 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -12673,20 +12870,20 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF(__pyx_v_i); __pyx_v_i = __pyx_t_1; - __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":10 - * self.lattice = new lattice.Lattice(len(inp)) + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":13 + * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): * self[i] = arcs # <<<<<<<<<<<<<< * else: * if isinstance(inp, unicode): */ - if (PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_i, __pyx_v_arcs) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_i, __pyx_v_arcs) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -12694,7 +12891,7 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":12 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":15 * self[i] = arcs * else: * if isinstance(inp, unicode): # <<<<<<<<<<<<<< @@ -12707,16 +12904,16 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":13 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":16 * else: * if isinstance(inp, unicode): * inp = inp.encode('utf8') # <<<<<<<<<<<<<< * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) + * raise TypeError('cannot create lattice from %s' % type(inp)) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_inp, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_inp, __pyx_n_s__encode); 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_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_v_inp); @@ -12726,12 +12923,12 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ } __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":14 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":17 * if isinstance(inp, unicode): * inp = inp.encode('utf8') * if not isinstance(inp, str): # <<<<<<<<<<<<<< - * raise TypeError('Cannot create lattice from %s' % type(inp)) - * self.lattice = new lattice.Lattice() + * raise TypeError('cannot create lattice from %s' % type(inp)) + * lattice.ConvertTextOrPLF(string(inp), self.lattice) */ __pyx_t_4 = ((PyObject *)((PyObject*)(&PyString_Type))); __Pyx_INCREF(__pyx_t_4); @@ -12740,48 +12937,39 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __pyx_t_7 = (!__pyx_t_2); if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":15 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":18 * inp = inp.encode('utf8') * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) # <<<<<<<<<<<<<< - * self.lattice = new lattice.Lattice() - * lattice.ConvertTextToLattice(string(inp), self.lattice) + * raise TypeError('cannot create lattice from %s' % type(inp)) # <<<<<<<<<<<<<< + * lattice.ConvertTextOrPLF(string(inp), self.lattice) + * */ - __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L7; } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":16 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":19 * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) - * self.lattice = new lattice.Lattice() # <<<<<<<<<<<<<< - * lattice.ConvertTextToLattice(string(inp), self.lattice) - * - */ - __pyx_v_self->lattice = new Lattice(); - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":17 - * raise TypeError('Cannot create lattice from %s' % type(inp)) - * self.lattice = new lattice.Lattice() - * lattice.ConvertTextToLattice(string(inp), self.lattice) # <<<<<<<<<<<<<< + * raise TypeError('cannot create lattice from %s' % type(inp)) + * lattice.ConvertTextOrPLF(string(inp), self.lattice) # <<<<<<<<<<<<<< * * def __dealloc__(self): */ - __pyx_t_8 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - LatticeTools::ConvertTextToLattice(std::string(((char *)__pyx_t_8)), __pyx_v_self->lattice); + __pyx_t_8 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + LatticeTools::ConvertTextOrPLF(std::string(((char *)__pyx_t_8)), __pyx_v_self->lattice); } __pyx_L3:; @@ -12791,7 +12979,7 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_cdec.Lattice.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Lattice.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_i); @@ -12802,27 +12990,27 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ } /* Python wrapper */ -static void __pyx_pw_5_cdec_7Lattice_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pw_5_cdec_7Lattice_3__dealloc__(PyObject *__pyx_v_self) { +static void __pyx_pw_5_cdec_7Lattice_5__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_5_cdec_7Lattice_5__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_pf_5_cdec_7Lattice_2__dealloc__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_pf_5_cdec_7Lattice_4__dealloc__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":19 - * lattice.ConvertTextToLattice(string(inp), self.lattice) +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":21 + * lattice.ConvertTextOrPLF(string(inp), self.lattice) * * def __dealloc__(self): # <<<<<<<<<<<<<< * del self.lattice * */ -static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static void __pyx_pf_5_cdec_7Lattice_4__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":20 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":22 * * def __dealloc__(self): * del self.lattice # <<<<<<<<<<<<<< @@ -12835,14 +13023,14 @@ static void __pyx_pf_5_cdec_7Lattice_2__dealloc__(CYTHON_UNUSED struct __pyx_obj } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/ -static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) { +static PyObject *__pyx_pw_5_cdec_7Lattice_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_7__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) { int __pyx_v_index; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); assert(__pyx_arg_index); { - __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -12850,12 +13038,12 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, P __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_7Lattice_4__getitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_6__getitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":22 +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24 * del self.lattice * * def __getitem__(self, int index): # <<<<<<<<<<<<<< @@ -12863,7 +13051,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5__getitem__(PyObject *__pyx_v_self, P * raise IndexError('lattice index out of range') */ -static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index) { +static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index) { PyObject *__pyx_v_arcs = NULL; std::vector __pyx_v_arc_vector; LatticeArc *__pyx_v_arc; @@ -12885,7 +13073,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":23 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":25 * * def __getitem__(self, int index): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -12894,41 +13082,41 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L */ __pyx_t_1 = (0 <= __pyx_v_index); if (__pyx_t_1) { - __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = (__pyx_v_index < __pyx_t_2); } __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":25 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":27 * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') * arcs = [] # <<<<<<<<<<<<<< * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] * cdef lattice.LatticeArc* arc */ - __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_v_arcs = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":28 * raise IndexError('lattice index out of range') * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] # <<<<<<<<<<<<<< @@ -12937,7 +13125,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L */ __pyx_v_arc_vector = ((__pyx_v_self->lattice[0])[__pyx_v_index]); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":29 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":31 * cdef lattice.LatticeArc* arc * cdef unsigned i * for i in range(arc_vector.size()): # <<<<<<<<<<<<<< @@ -12948,7 +13136,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":30 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":32 * cdef unsigned i * for i in range(arc_vector.size()): * arc = &arc_vector[i] # <<<<<<<<<<<<<< @@ -12957,16 +13145,16 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L */ __pyx_v_arc = (&(__pyx_v_arc_vector[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":31 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":33 * for i in range(arc_vector.size()): * arc = &arc_vector[i] * label = unicode(TDConvert(arc.label).c_str(), 'utf8') # <<<<<<<<<<<<<< * arcs.append((label, arc.cost, arc.dist2next)) * return tuple(arcs) */ - __pyx_t_4 = PyBytes_FromString(TD::Convert(__pyx_v_arc->label).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyBytes_FromString(TD::Convert(__pyx_v_arc->label).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); @@ -12974,25 +13162,25 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_XDECREF(((PyObject *)__pyx_v_label)); __pyx_v_label = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":32 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":34 * arc = &arc_vector[i] * label = unicode(TDConvert(arc.label).c_str(), 'utf8') * arcs.append((label, arc.cost, arc.dist2next)) # <<<<<<<<<<<<<< * return tuple(arcs) * */ - __pyx_t_4 = PyFloat_FromDouble(__pyx_v_arc->cost); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_arc->cost); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = PyInt_FromLong(__pyx_v_arc->dist2next); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyInt_FromLong(__pyx_v_arc->dist2next); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_v_label)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_v_label)); @@ -13003,11 +13191,11 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L __Pyx_GIVEREF(__pyx_t_7); __pyx_t_4 = 0; __pyx_t_7 = 0; - __pyx_t_9 = PyList_Append(__pyx_v_arcs, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyList_Append(__pyx_v_arcs, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":33 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":35 * label = unicode(TDConvert(arc.label).c_str(), 'utf8') * arcs.append((label, arc.cost, arc.dist2next)) * return tuple(arcs) # <<<<<<<<<<<<<< @@ -13015,7 +13203,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L * def __setitem__(self, int index, tuple arcs): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = ((PyObject *)PyList_AsTuple(__pyx_v_arcs)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = ((PyObject *)PyList_AsTuple(__pyx_v_arcs)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); __pyx_r = ((PyObject *)__pyx_t_8); __pyx_t_8 = 0; @@ -13038,14 +13226,14 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_4__getitem__(struct __pyx_obj_5_cdec_L } /* Python wrapper */ -static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs); /*proto*/ -static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs) { +static int __pyx_pw_5_cdec_7Lattice_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs); /*proto*/ +static int __pyx_pw_5_cdec_7Lattice_9__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_arcs) { int __pyx_v_index; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); assert(__pyx_arg_index); { - __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -13053,8 +13241,8 @@ static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObjec __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arcs), (&PyTuple_Type), 1, "arcs", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_5_cdec_7Lattice_6__setitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index), ((PyObject*)__pyx_v_arcs)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_arcs), (&PyTuple_Type), 1, "arcs", 1))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_5_cdec_7Lattice_8__setitem__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self), ((int)__pyx_v_index), ((PyObject*)__pyx_v_arcs)); goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -13063,7 +13251,7 @@ static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":35 +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37 * return tuple(arcs) * * def __setitem__(self, int index, tuple arcs): # <<<<<<<<<<<<<< @@ -13071,7 +13259,7 @@ static int __pyx_pw_5_cdec_7Lattice_7__setitem__(PyObject *__pyx_v_self, PyObjec * raise IndexError('lattice index out of range') */ -static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs) { +static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, int __pyx_v_index, PyObject *__pyx_v_arcs) { LatticeArc *__pyx_v_arc; PyObject *__pyx_v_label = NULL; PyObject *__pyx_v_cost = NULL; @@ -13096,7 +13284,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":36 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":38 * * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -13105,29 +13293,29 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice */ __pyx_t_1 = (0 <= __pyx_v_index); if (__pyx_t_1) { - __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = (__pyx_v_index < __pyx_t_2); } __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39 * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41 * raise IndexError('lattice index out of range') * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: # <<<<<<<<<<<<<< @@ -13136,7 +13324,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice */ if (unlikely(((PyObject *)__pyx_v_arcs) == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_4 = ((PyObject *)__pyx_v_arcs); __Pyx_INCREF(__pyx_t_4); __pyx_t_2 = 0; for (;;) { @@ -13144,7 +13332,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; @@ -13156,7 +13344,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -13172,15 +13360,15 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); #else - __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; @@ -13190,7 +13378,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_GOTREF(__pyx_t_7); index = 2; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L7_unpacking_done; @@ -13198,7 +13386,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XDECREF(__pyx_v_label); @@ -13211,7 +13399,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __pyx_v_dist2next = __pyx_t_8; __pyx_t_8 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":40 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":42 * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: * if isinstance(label, unicode): # <<<<<<<<<<<<<< @@ -13224,16 +13412,16 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43 * for (label, cost, dist2next) in arcs: * if isinstance(label, unicode): * label = label.encode('utf8') # <<<<<<<<<<<<<< * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) */ - __pyx_t_5 = PyObject_GetAttr(__pyx_v_label, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_GetAttr(__pyx_v_label, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_27), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_v_label); @@ -13243,19 +13431,19 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice } __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":42 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44 * if isinstance(label, unicode): * label = label.encode('utf8') * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) # <<<<<<<<<<<<<< * self.lattice[0][index].push_back(arc[0]) * del arc */ - __pyx_t_11 = PyBytes_AsString(__pyx_v_label); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyBytes_AsString(__pyx_v_label); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_arc = new LatticeArc(TD::Convert(((char *)__pyx_t_11)), __pyx_t_12, __pyx_t_13); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":45 * label = label.encode('utf8') * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) # <<<<<<<<<<<<<< @@ -13264,7 +13452,7 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice */ ((__pyx_v_self->lattice[0])[__pyx_v_index]).push_back((__pyx_v_arc[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46 * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) * del arc # <<<<<<<<<<<<<< @@ -13295,17 +13483,17 @@ static int __pyx_pf_5_cdec_7Lattice_6__setitem__(struct __pyx_obj_5_cdec_Lattice } /* Python wrapper */ -static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self); /*proto*/ -static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self) { +static Py_ssize_t __pyx_pw_5_cdec_7Lattice_11__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_5_cdec_7Lattice_11__len__(PyObject *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_8__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_10__len__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46 +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":48 * del arc * * def __len__(self): # <<<<<<<<<<<<<< @@ -13313,12 +13501,12 @@ static Py_ssize_t __pyx_pw_5_cdec_7Lattice_9__len__(PyObject *__pyx_v_self) { * */ -static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static Py_ssize_t __pyx_pf_5_cdec_7Lattice_10__len__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":47 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49 * * def __len__(self): * return self.lattice.size() # <<<<<<<<<<<<<< @@ -13335,25 +13523,89 @@ static Py_ssize_t __pyx_pf_5_cdec_7Lattice_8__len__(struct __pyx_obj_5_cdec_Latt } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_7Lattice_11__str__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_5_cdec_7Lattice_11__str__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_5_cdec_7Lattice_13__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_13__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_7Lattice_12__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":51 + * return self.lattice.size() + * + * def __str__(self): # <<<<<<<<<<<<<< + * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) + * + */ + +static PyObject *__pyx_pf_5_cdec_7Lattice_12__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__str__", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52 + * + * def __str__(self): + * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) # <<<<<<<<<<<<<< + * + * def __unicode__(self): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __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 = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Lattice.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_7Lattice_15__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_15__unicode__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_10__str__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__unicode__ (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_7Lattice_14__unicode__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49 - * return self.lattice.size() - * - * def __str__(self): # <<<<<<<<<<<<<< +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54 * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) * + * def __unicode__(self): # <<<<<<<<<<<<<< + * return unicode(str(self), 'utf8') + * */ -static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -13361,28 +13613,37 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Latt int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__str__", 0); + __Pyx_RefNannySetupContext("__unicode__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":50 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":55 * - * def __str__(self): - * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) # <<<<<<<<<<<<<< + * def __unicode__(self): + * return unicode(str(self), 'utf8') # <<<<<<<<<<<<<< * * def __iter__(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 50; __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 = 50; __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 = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__utf8)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); @@ -13390,35 +13651,35 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_10__str__(struct __pyx_obj_5_cdec_Latt __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("_cdec.Lattice.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Lattice.__unicode__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Lattice_14generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_5_cdec_7Lattice_13__iter__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_5_cdec_7Lattice_17__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_17__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_12__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_16__iter__(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52 - * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 + * return unicode(str(self), 'utf8') * * def __iter__(self): # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(len(self)): */ -static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static PyObject *__pyx_pf_5_cdec_7Lattice_16__iter__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -13436,7 +13697,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lat __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_14generator14, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_18generator14, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -13454,7 +13715,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_12__iter__(struct __pyx_obj_5_cdec_Lat return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Lattice_14generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; @@ -13471,27 +13732,27 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_14generator14(__pyx_GeneratorObject *_ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59 * def __iter__(self): * cdef unsigned i * for i in range(len(self)): # <<<<<<<<<<<<<< * yield self[i] * */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":55 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":60 * cdef unsigned i * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< * * def todot(self): */ - __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -13505,7 +13766,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_14generator14(__pyx_GeneratorObject *_ __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -13521,12 +13782,12 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_14generator14(__pyx_GeneratorObject *_ } /* Python wrapper */ -static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5_cdec_7Lattice_16todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_5_cdec_7Lattice_20todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_20todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("todot (wrapper)", 0); - __pyx_r = __pyx_pf_5_cdec_7Lattice_15todot(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __pyx_r = __pyx_pf_5_cdec_7Lattice_19todot(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -13544,7 +13805,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5todot_1lines(PyObject *__pyx_self, CY return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 * * def todot(self): * def lines(): # <<<<<<<<<<<<<< @@ -13570,7 +13831,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_5todot_lines(PyObject *__pyx_self) { __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_5todot_2generator20, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_5todot_2generator20, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -13619,86 +13880,86 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64 * def todot(self): * def lines(): * yield 'digraph lattice {' # <<<<<<<<<<<<<< * yield 'rankdir = LR;' * yield 'node [shape=circle];' */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_27)); - __pyx_r = ((PyObject *)__pyx_kp_s_27); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_28)); + __pyx_r = ((PyObject *)__pyx_kp_s_28); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L4_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":60 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":65 * def lines(): * yield 'digraph lattice {' * yield 'rankdir = LR;' # <<<<<<<<<<<<<< * yield 'node [shape=circle];' * for i in range(len(self)): */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_28)); - __pyx_r = ((PyObject *)__pyx_kp_s_28); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_29)); + __pyx_r = ((PyObject *)__pyx_kp_s_29); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 2; return __pyx_r; __pyx_L5_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":61 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":66 * yield 'digraph lattice {' * yield 'rankdir = LR;' * yield 'node [shape=circle];' # <<<<<<<<<<<<<< * for i in range(len(self)): * for label, weight, delta in self[i]: */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_29)); - __pyx_r = ((PyObject *)__pyx_kp_s_29); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_30)); + __pyx_r = ((PyObject *)__pyx_kp_s_30); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 3; return __pyx_r; __pyx_L6_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67 * yield 'rankdir = LR;' * yield 'node [shape=circle];' * for i in range(len(self)): # <<<<<<<<<<<<<< * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) */ - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; } @@ -13709,21 +13970,21 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_1 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -13735,20 +13996,20 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_cur_scope->__pyx_v_i = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":68 * yield 'node [shape=circle];' * for i in range(len(self)): * for label, weight, delta in self[i]: # <<<<<<<<<<<<<< * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i); if (!__pyx_t_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_5 = __pyx_t_1; __Pyx_INCREF(__pyx_t_5); __pyx_t_6 = 0; __pyx_t_7 = NULL; } else { - __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = Py_TYPE(__pyx_t_5)->tp_iternext; } @@ -13759,21 +14020,21 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_1 = __pyx_t_7(__pyx_t_5); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -13789,7 +14050,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -13805,15 +14066,15 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_INCREF(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); #else - __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; - __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext; @@ -13823,7 +14084,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_GOTREF(__pyx_t_9); index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_12 = NULL; __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; goto __pyx_L12_unpacking_done; @@ -13831,7 +14092,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __pyx_t_12 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L12_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_label); @@ -13850,21 +14111,21 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_cur_scope->__pyx_v_delta = __pyx_t_10; __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":69 * for i in range(len(self)): * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) # <<<<<<<<<<<<<< * yield '%d [shape=doublecircle]' % len(self) * yield '}' */ - __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_i, __pyx_cur_scope->__pyx_v_delta); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_i, __pyx_cur_scope->__pyx_v_delta); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_label, __pyx_n_s__replace); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_label, __pyx_n_s__replace); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_cur_scope->__pyx_v_i); @@ -13875,7 +14136,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_GIVEREF(__pyx_t_9); __pyx_t_1 = 0; __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_30), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __pyx_r = ((PyObject *)__pyx_t_9); @@ -13904,13 +14165,13 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_XGOTREF(__pyx_t_5); __pyx_t_6 = __pyx_cur_scope->__pyx_t_4; __pyx_t_7 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":65 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":70 * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) # <<<<<<<<<<<<<< @@ -13919,11 +14180,11 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj */ __pyx_t_3 = ((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_3); - __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_35), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = ((PyObject *)__pyx_t_5); @@ -13934,23 +14195,24 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_generator->resume_label = 5; return __pyx_r; __pyx_L14_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":66 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":71 * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) * yield '}' # <<<<<<<<<<<<<< * return '\n'.join(lines()).encode('utf8') + * */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_35)); - __pyx_r = ((PyObject *)__pyx_kp_s_35); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_36)); + __pyx_r = ((PyObject *)__pyx_kp_s_36); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 6; return __pyx_r; __pyx_L15_resume_from_yield:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; @@ -13970,7 +14232,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62 * yield self[i] * * def todot(self): # <<<<<<<<<<<<<< @@ -13978,7 +14240,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj * yield 'digraph lattice {' */ -static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { +static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *__pyx_cur_scope; PyObject *__pyx_v_lines = 0; PyObject *__pyx_r = NULL; @@ -14000,41 +14262,43 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattic __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 * * def todot(self): * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_cdec_7Lattice_5todot_1lines, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s___cdec, ((PyObject *)__pyx_k_codeobj_37)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_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_38)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_lines = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":72 * yield '%d [shape=doublecircle]' % len(self) * yield '}' * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<< + * + * def as_hypergraph(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_39), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_40), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_v_lines, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_v_lines, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -14057,6 +14321,113 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_15todot(struct __pyx_obj_5_cdec_Lattic return __pyx_r; } +/* Python wrapper */ +static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("as_hypergraph (wrapper)", 0); + __pyx_r = __pyx_pf_5_cdec_7Lattice_21as_hypergraph(((struct __pyx_obj_5_cdec_Lattice *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":74 + * return '\n'.join(lines()).encode('utf8') + * + * def as_hypergraph(self): # <<<<<<<<<<<<<< + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + * result.hg = new hypergraph.Hypergraph() + */ + +static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { + struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_result = 0; + PyObject *__pyx_v_plf = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + char *__pyx_t_3; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("as_hypergraph", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":75 + * + * def as_hypergraph(self): + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) # <<<<<<<<<<<<<< + * result.hg = new hypergraph.Hypergraph() + * cdef bytes plf = str(self) + */ + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_Hypergraph)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_Hypergraph)))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_result = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":76 + * def as_hypergraph(self): + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + * result.hg = new hypergraph.Hypergraph() # <<<<<<<<<<<<<< + * cdef bytes plf = str(self) + * hypergraph.ReadFromPLF(string(plf), result.hg) + */ + __pyx_v_result->hg = new Hypergraph(); + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":77 + * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + * result.hg = new hypergraph.Hypergraph() + * cdef bytes plf = str(self) # <<<<<<<<<<<<<< + * hypergraph.ReadFromPLF(string(plf), result.hg) + * return result + */ + __pyx_t_1 = PyTuple_New(1); 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_INCREF(((PyObject *)__pyx_v_self)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_plf = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":78 + * result.hg = new hypergraph.Hypergraph() + * cdef bytes plf = str(self) + * hypergraph.ReadFromPLF(string(plf), result.hg) # <<<<<<<<<<<<<< + * return result + */ + __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_plf)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + HypergraphIO::ReadFromPLF(std::string(__pyx_t_3), __pyx_v_result->hg); + + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":79 + * cdef bytes plf = str(self) + * hypergraph.ReadFromPLF(string(plf), result.hg) + * return result # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + __pyx_r = ((PyObject *)__pyx_v_result); + goto __pyx_L0; + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_cdec.Lattice.as_hypergraph", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_result); + __Pyx_XDECREF(__pyx_v_plf); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":3 * cimport mteval * @@ -14842,7 +15213,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj * return self.stats[0][index] * */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -15287,7 +15658,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_44), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -15969,7 +16340,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj * del self.name * * def __call__(self, refs): # <<<<<<<<<<<<<< - * if isinstance(refs, unicode) or isinstance(refs, str): + * if isinstance(refs, basestring): * refs = [refs] */ @@ -15982,12 +16353,10 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - Py_ssize_t __pyx_t_5; - PyObject *(*__pyx_t_6)(PyObject *); - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -15997,28 +16366,19 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":130 * * def __call__(self, refs): - * if isinstance(refs, unicode) or isinstance(refs, str): # <<<<<<<<<<<<<< + * if isinstance(refs, basestring): # <<<<<<<<<<<<<< * refs = [refs] * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() */ - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); + __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_refs, __pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_refs, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!__pyx_t_2) { - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_refs, __pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (__pyx_t_4) { + if (__pyx_t_2) { /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":131 * def __call__(self, refs): - * if isinstance(refs, unicode) or isinstance(refs, str): + * if isinstance(refs, basestring): * refs = [refs] # <<<<<<<<<<<<<< * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() * cdef vector[WordID]* refv @@ -16036,7 +16396,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":132 - * if isinstance(refs, unicode) or isinstance(refs, str): + * if isinstance(refs, basestring): * refs = [refs] * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() # <<<<<<<<<<<<<< * cdef vector[WordID]* refv @@ -16052,42 +16412,42 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score * ConvertSentence(string(as_str(ref.strip())), refv) */ if (PyList_CheckExact(__pyx_v_refs) || PyTuple_CheckExact(__pyx_v_refs)) { - __pyx_t_1 = __pyx_v_refs; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0; - __pyx_t_6 = NULL; + __pyx_t_1 = __pyx_v_refs; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; + __pyx_t_4 = NULL; } else { - __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext; + __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; } for (;;) { - if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break; + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; #else - __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif - } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; #else - __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { - __pyx_t_7 = __pyx_t_6(__pyx_t_1); - if (unlikely(!__pyx_t_7)) { + __pyx_t_5 = __pyx_t_4(__pyx_t_1); + if (unlikely(!__pyx_t_5)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); else {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } - __Pyx_GOTREF(__pyx_t_7); + __Pyx_GOTREF(__pyx_t_5); } __Pyx_XDECREF(__pyx_v_ref); - __pyx_v_ref = __pyx_t_7; - __pyx_t_7 = 0; + __pyx_v_ref = __pyx_t_5; + __pyx_t_5 = 0; /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":135 * cdef vector[WordID]* refv @@ -16105,13 +16465,13 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score * refsv.push_back(refv[0]) * del refv */ - __pyx_t_7 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __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; + __pyx_t_5 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + TD::ConvertSentence(std::string(__pyx_f_5_cdec_as_str(__pyx_t_6, NULL)), __pyx_v_refv); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":137 * refv = new vector[WordID]() @@ -16188,8 +16548,8 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -17253,7 +17613,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_cur_scope->__pyx_v_info); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_info); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_info); - __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_7)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -17649,7 +18009,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_kv = __pyx_t_3; __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_cur_scope->__pyx_v_kv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), __pyx_cur_scope->__pyx_v_kv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __pyx_r = ((PyObject *)__pyx_t_3); __pyx_t_3 = 0; @@ -17741,7 +18101,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_formalism = __pyx_t_3; @@ -17806,7 +18166,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__InvalidConfig); 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_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), __pyx_v_formalism); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_v_formalism); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); @@ -17831,7 +18191,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) */ - __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_39), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_40), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_6 = __pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); @@ -18246,7 +18606,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De * * property formalism: */ - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_50), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __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 = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); @@ -18495,7 +18855,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_52), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} @@ -18671,7 +19031,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ } /*finally:*/ { if (__pyx_t_3) { - __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_52, NULL); + __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_53, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); @@ -18724,7 +19084,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO * * def translate(self, sentence, grammar=None): # <<<<<<<<<<<<<< * cdef bytes input_str - * if isinstance(sentence, unicode) or isinstance(sentence, str): + * if isinstance(sentence, basestring): */ values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -18782,10 +19142,8 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - char *__pyx_t_6; + PyObject *__pyx_t_3 = NULL; + char *__pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -18794,47 +19152,38 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec /* "_cdec.pyx":99 * def translate(self, sentence, grammar=None): * cdef bytes input_str - * if isinstance(sentence, unicode) or isinstance(sentence, str): # <<<<<<<<<<<<<< + * if isinstance(sentence, basestring): # <<<<<<<<<<<<<< * input_str = as_str(sentence.strip()) * elif isinstance(sentence, Lattice): */ - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); + __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_sentence, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!__pyx_t_2) { - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (__pyx_t_4) { + if (__pyx_t_2) { /* "_cdec.pyx":100 * cdef bytes input_str - * if isinstance(sentence, unicode) or isinstance(sentence, str): + * if isinstance(sentence, basestring): * input_str = as_str(sentence.strip()) # <<<<<<<<<<<<<< * elif isinstance(sentence, Lattice): * input_str = str(sentence) # PLF format */ __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyBytes_FromString(__pyx_f_5_cdec_as_str(__pyx_t_5, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_input_str = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L3; } /* "_cdec.pyx":101 - * if isinstance(sentence, unicode) or isinstance(sentence, str): + * if isinstance(sentence, basestring): * input_str = as_str(sentence.strip()) * elif isinstance(sentence, Lattice): # <<<<<<<<<<<<<< * input_str = str(sentence) # PLF format @@ -18842,9 +19191,9 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec */ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)); __Pyx_INCREF(__pyx_t_1); - __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); + __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_sentence, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_4) { + if (__pyx_t_2) { /* "_cdec.pyx":102 * input_str = as_str(sentence.strip()) @@ -18858,12 +19207,12 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec __Pyx_INCREF(__pyx_v_sentence); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sentence); __Pyx_GIVEREF(__pyx_v_sentence); - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_input_str = ((PyObject*)__pyx_t_5); - __pyx_t_5 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_input_str = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; goto __pyx_L3; } /*else*/ { @@ -18873,20 +19222,20 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec * else: * raise TypeError('Cannot translate input type %s' % type(sentence)) # <<<<<<<<<<<<<< * if grammar: - * if isinstance(grammar, str) or isinstance(grammar, unicode): + * if isinstance(grammar, basestring): */ - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __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 = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -18895,37 +19244,28 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec * else: * raise TypeError('Cannot translate input type %s' % type(sentence)) * if grammar: # <<<<<<<<<<<<<< - * if isinstance(grammar, str) or isinstance(grammar, unicode): + * if isinstance(grammar, basestring): * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) */ - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_4) { + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_2) { /* "_cdec.pyx":106 * raise TypeError('Cannot translate input type %s' % type(sentence)) * if grammar: - * if isinstance(grammar, str) or isinstance(grammar, unicode): # <<<<<<<<<<<<<< + * if isinstance(grammar, basestring): # <<<<<<<<<<<<<< * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) * else: */ - __pyx_t_5 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_5); - __pyx_t_4 = __Pyx_TypeCheck(__pyx_v_grammar, __pyx_t_5); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!__pyx_t_4) { - __pyx_t_5 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_5); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_grammar, __pyx_t_5); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_4; - } - if (__pyx_t_3) { + __pyx_t_3 = __pyx_builtin_basestring; + __Pyx_INCREF(__pyx_t_3); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_grammar, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_2) { /* "_cdec.pyx":107 * if grammar: - * if isinstance(grammar, str) or isinstance(grammar, unicode): + * if isinstance(grammar, basestring): * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) # <<<<<<<<<<<<<< * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) @@ -18942,14 +19282,14 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec * cdef decoder.BasicObserver observer = decoder.BasicObserver() * self.dec.Decode(string(input_str), &observer) */ - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_grammar); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_grammar); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_grammar); __Pyx_GIVEREF(__pyx_v_grammar); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_self->dec->AddSupplementalGrammar((((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_t_1)->__pyx_base.grammar[0])); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } @@ -18974,8 +19314,8 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec * if observer.hypergraph == NULL: * raise ParseFailed() */ - __pyx_t_6 = PyBytes_AsString(((PyObject *)__pyx_v_input_str)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->dec->Decode(std::string(__pyx_t_6), (&__pyx_v_observer)); + __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_input_str)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->dec->Decode(std::string(__pyx_t_4), (&__pyx_v_observer)); /* "_cdec.pyx":112 * cdef decoder.BasicObserver observer = decoder.BasicObserver() @@ -18984,8 +19324,8 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec * raise ParseFailed() * cdef Hypergraph hg = Hypergraph() */ - __pyx_t_3 = (__pyx_v_observer.hypergraph == NULL); - if (__pyx_t_3) { + __pyx_t_2 = (__pyx_v_observer.hypergraph == NULL); + if (__pyx_t_2) { /* "_cdec.pyx":113 * self.dec.Decode(string(input_str), &observer) @@ -18996,11 +19336,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec */ __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_Raise(__pyx_t_3, 0, 0, 0); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } @@ -19013,10 +19353,10 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) * return hg */ - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_3); + __pyx_t_3 = 0; /* "_cdec.pyx":115 * raise ParseFailed() @@ -19040,7 +19380,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("_cdec.Decoder.translate", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -20704,8 +21044,9 @@ static PyMethodDef __pyx_methods_5_cdec_Hypergraph[] = { {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_26intersect, METH_O, __Pyx_DOCSTR(0)}, {__Pyx_NAMESTR("prune"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_28prune, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, {__Pyx_NAMESTR("lattice"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_30lattice, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("reweight"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_32reweight, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("inside_outside"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_34inside_outside, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("plf"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_32plf, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("reweight"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_34reweight, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("inside_outside"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_36inside_outside, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; @@ -21303,10 +21644,10 @@ static PyTypeObject __pyx_type_5_cdec_HypergraphNode = { #endif }; -static PyObject *__pyx_tp_new_5_cdec_Lattice(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_5_cdec_Lattice(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - if (__pyx_pw_5_cdec_7Lattice_1__cinit__(o, a, k) < 0) { + if (__pyx_pw_5_cdec_7Lattice_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { Py_DECREF(o); o = 0; } return o; @@ -21317,7 +21658,7 @@ static void __pyx_tp_dealloc_5_cdec_Lattice(PyObject *o) { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); - __pyx_pw_5_cdec_7Lattice_3__dealloc__(o); + __pyx_pw_5_cdec_7Lattice_5__dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); @@ -21334,7 +21675,7 @@ static PyObject *__pyx_sq_item_5_cdec_Lattice(PyObject *o, Py_ssize_t i) { static int __pyx_mp_ass_subscript_5_cdec_Lattice(PyObject *o, PyObject *i, PyObject *v) { if (v) { - return __pyx_pw_5_cdec_7Lattice_7__setitem__(o, i, v); + return __pyx_pw_5_cdec_7Lattice_9__setitem__(o, i, v); } else { PyErr_Format(PyExc_NotImplementedError, @@ -21344,7 +21685,9 @@ static int __pyx_mp_ass_subscript_5_cdec_Lattice(PyObject *o, PyObject *i, PyObj } static PyMethodDef __pyx_methods_5_cdec_Lattice[] = { - {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_16todot, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("__unicode__"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_15__unicode__, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_20todot, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("as_hypergraph"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_22as_hypergraph, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; @@ -21407,7 +21750,7 @@ static PyNumberMethods __pyx_tp_as_number_Lattice = { }; static PySequenceMethods __pyx_tp_as_sequence_Lattice = { - __pyx_pw_5_cdec_7Lattice_9__len__, /*sq_length*/ + __pyx_pw_5_cdec_7Lattice_11__len__, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ __pyx_sq_item_5_cdec_Lattice, /*sq_item*/ @@ -21420,8 +21763,8 @@ static PySequenceMethods __pyx_tp_as_sequence_Lattice = { }; static PyMappingMethods __pyx_tp_as_mapping_Lattice = { - __pyx_pw_5_cdec_7Lattice_9__len__, /*mp_length*/ - __pyx_pw_5_cdec_7Lattice_5__getitem__, /*mp_subscript*/ + __pyx_pw_5_cdec_7Lattice_11__len__, /*mp_length*/ + __pyx_pw_5_cdec_7Lattice_7__getitem__, /*mp_subscript*/ __pyx_mp_ass_subscript_5_cdec_Lattice, /*mp_ass_subscript*/ }; @@ -21466,7 +21809,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = { &__pyx_tp_as_mapping_Lattice, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - __pyx_pw_5_cdec_7Lattice_11__str__, /*tp_str*/ + __pyx_pw_5_cdec_7Lattice_13__str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ &__pyx_tp_as_buffer_Lattice, /*tp_as_buffer*/ @@ -21476,7 +21819,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = { 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - __pyx_pw_5_cdec_7Lattice_13__iter__, /*tp_iter*/ + __pyx_pw_5_cdec_7Lattice_17__iter__, /*tp_iter*/ 0, /*tp_iternext*/ __pyx_methods_5_cdec_Lattice, /*tp_methods*/ 0, /*tp_members*/ @@ -21486,7 +21829,7 @@ static PyTypeObject __pyx_type_5_cdec_Lattice = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_5_cdec_7Lattice_3__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5_cdec_Lattice, /*tp_new*/ 0, /*tp_free*/ @@ -28074,36 +28417,37 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0}, {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0}, {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0}, - {&__pyx_n_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 1}, - {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0}, + {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0}, + {&__pyx_n_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 1}, {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0}, - {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0}, - {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0}, + {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, + {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0}, {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0}, - {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0}, + {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0}, {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0}, {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0}, {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0}, {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0}, {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0}, - {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0}, + {&__pyx_kp_s_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_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0}, + {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0}, {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0}, {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, - {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0}, - {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0}, - {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0}, + {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0}, + {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0}, + {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0}, {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0}, - {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0}, + {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0}, {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0}, {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0}, - {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0}, - {&__pyx_n_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 1}, + {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0}, + {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0}, {&__pyx_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1}, - {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0}, - {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0}, + {&__pyx_n_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 1}, + {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0}, + {&__pyx_kp_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 0}, {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0}, {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0}, @@ -28116,7 +28460,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1}, {&__pyx_n_s__NotImplemented, __pyx_k__NotImplemented, sizeof(__pyx_k__NotImplemented), 0, 0, 1, 1}, {&__pyx_n_s__ParseFailed, __pyx_k__ParseFailed, sizeof(__pyx_k__ParseFailed), 0, 0, 1, 1}, - {&__pyx_n_s__PhraseModel_, __pyx_k__PhraseModel_, sizeof(__pyx_k__PhraseModel_), 0, 0, 1, 1}, {&__pyx_n_s__TER, __pyx_k__TER, sizeof(__pyx_k__TER), 0, 0, 1, 1}, {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1}, {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, @@ -28132,6 +28475,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s___phrase, __pyx_k___phrase, sizeof(__pyx_k___phrase), 0, 0, 1, 1}, {&__pyx_n_s___sa, __pyx_k___sa, sizeof(__pyx_k___sa), 0, 0, 1, 1}, {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1}, + {&__pyx_n_s__alignments, __pyx_k__alignments, sizeof(__pyx_k__alignments), 0, 0, 1, 1}, + {&__pyx_n_s__basestring, __pyx_k__basestring, sizeof(__pyx_k__basestring), 0, 0, 1, 1}, {&__pyx_n_s__beam_alpha, __pyx_k__beam_alpha, sizeof(__pyx_k__beam_alpha), 0, 0, 1, 1}, {&__pyx_n_s__cat, __pyx_k__cat, sizeof(__pyx_k__cat), 0, 0, 1, 1}, {&__pyx_n_s__config, __pyx_k__config, sizeof(__pyx_k__config), 0, 0, 1, 1}, @@ -28204,11 +28549,12 @@ static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_NotImplemented = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_basestring = __Pyx_GetName(__pyx_b, __pyx_n_s__basestring); if (!__pyx_builtin_basestring) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; @@ -28261,153 +28607,155 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":212 + /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209 * trule = convert_rule(trule) * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<< * _g.AddRule(( trule).rule[0]) */ - __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_14); __Pyx_INCREF(((PyObject *)__pyx_kp_s_13)); PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":204 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":214 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<< * * cdef class HypergraphNode: */ - __pyx_k_tuple_18 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_18)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_18); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_17)); - PyTuple_SET_ITEM(__pyx_k_tuple_18, 0, ((PyObject *)__pyx_kp_s_17)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_18)); + __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_19); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); + PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":241 + /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":251 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphNode') # <<<<<<<<<<<<<< */ - __pyx_k_tuple_20 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_20); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_19)); - PyTuple_SET_ITEM(__pyx_k_tuple_20, 0, ((PyObject *)__pyx_kp_s_19)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_19)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20)); + __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_21); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_20)); + PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_s_20)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":13 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":16 * else: * if isinstance(inp, unicode): * inp = inp.encode('utf8') # <<<<<<<<<<<<<< * if not isinstance(inp, str): - * raise TypeError('Cannot create lattice from %s' % type(inp)) + * raise TypeError('cannot create lattice from %s' % type(inp)) */ - __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_21); + __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_22); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] */ - __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_24); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_23)); - PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24)); + __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_25); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_24)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((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":37 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39 * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: */ - __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_25); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_23)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_kp_s_23)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); + __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_26); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_24)); + PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_kp_s_24)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43 * for (label, cost, dist2next) in arcs: * if isinstance(label, unicode): * label = label.encode('utf8') # <<<<<<<<<<<<<< * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) */ - __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_26); + __pyx_k_tuple_27 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_27); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":69 * for i in range(len(self)): * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) # <<<<<<<<<<<<<< * yield '%d [shape=doublecircle]' % len(self) * yield '}' */ - __pyx_k_tuple_33 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_33); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_31)); - PyTuple_SET_ITEM(__pyx_k_tuple_33, 0, ((PyObject *)__pyx_kp_s_31)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31)); + __pyx_k_tuple_34 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_34); __Pyx_INCREF(((PyObject *)__pyx_kp_s_32)); - PyTuple_SET_ITEM(__pyx_k_tuple_33, 1, ((PyObject *)__pyx_kp_s_32)); + PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_kp_s_32)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_33)); + PyTuple_SET_ITEM(__pyx_k_tuple_34, 1, ((PyObject *)__pyx_kp_s_33)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":58 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 * * def todot(self): * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ - __pyx_k_tuple_36 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_36)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_36); + __pyx_k_tuple_37 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_37); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 0, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__label)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 1, ((PyObject *)__pyx_n_s__label)); + PyTuple_SET_ITEM(__pyx_k_tuple_37, 1, ((PyObject *)__pyx_n_s__label)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__label)); __Pyx_INCREF(((PyObject *)__pyx_n_s__weight)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 2, ((PyObject *)__pyx_n_s__weight)); + PyTuple_SET_ITEM(__pyx_k_tuple_37, 2, ((PyObject *)__pyx_n_s__weight)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__weight)); __Pyx_INCREF(((PyObject *)__pyx_n_s__delta)); - PyTuple_SET_ITEM(__pyx_k_tuple_36, 3, ((PyObject *)__pyx_n_s__delta)); + PyTuple_SET_ITEM(__pyx_k_tuple_37, 3, ((PyObject *)__pyx_n_s__delta)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__delta)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_36)); - __pyx_k_codeobj_37 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_36, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_38, __pyx_n_s__lines, 58, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_37)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37)); + __pyx_k_codeobj_38 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_39, __pyx_n_s__lines, 63, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_38)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67 + /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":72 * yield '%d [shape=doublecircle]' % len(self) * yield '}' * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<< + * + * def as_hypergraph(self): */ - __pyx_k_tuple_40 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_40); + __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_41); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_40, 0, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41)); /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":50 * def __getitem__(self, int index): @@ -28416,12 +28764,12 @@ static int __Pyx_InitCachedConstants(void) { * return self.stats[0][index] * */ - __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_42); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_41)); - PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_41)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42)); + __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_43); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_42)); + PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_42)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43)); /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84 * def __getitem__(self,int k): @@ -28430,12 +28778,12 @@ static int __Pyx_InitCachedConstants(void) { * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] */ - __pyx_k_tuple_44 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_44); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_43)); - PyTuple_SET_ITEM(__pyx_k_tuple_44, 0, ((PyObject *)__pyx_kp_s_43)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44)); + __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_45); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_44)); + PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_s_44)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45)); /* "_cdec.pyx":53 * """ @@ -28444,15 +28792,15 @@ static int __Pyx_InitCachedConstants(void) { * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): */ - __pyx_k_tuple_47 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_47); + __pyx_k_tuple_48 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_48); __Pyx_INCREF(((PyObject *)__pyx_n_s__formalism)); - PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_n_s__formalism)); + PyTuple_SET_ITEM(__pyx_k_tuple_48, 0, ((PyObject *)__pyx_n_s__formalism)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__formalism)); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_47, 1, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_48, 1, Py_None); __Pyx_GIVEREF(Py_None); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48)); /* "_cdec.pyx":93 * with open(weights) as fp: @@ -28461,12 +28809,12 @@ static int __Pyx_InitCachedConstants(void) { * fname, value = line.split() * self.weights[fname.strip()] = float(value) */ - __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_51); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_50)); - PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_s_50)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51)); + __pyx_k_tuple_52 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_52); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_51)); + PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, ((PyObject *)__pyx_kp_s_51)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52)); /* "_cdec.pyx":91 * @@ -28475,18 +28823,18 @@ static int __Pyx_InitCachedConstants(void) { * for line in fp: * if line.strip().startswith('#'): continue */ - __pyx_k_tuple_52 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_52); + __pyx_k_tuple_53 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_53); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_53, 0, Py_None); __Pyx_GIVEREF(Py_None); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 1, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_53, 1, Py_None); __Pyx_GIVEREF(Py_None); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 2, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_53, 2, Py_None); __Pyx_GIVEREF(Py_None); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53)); /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa @@ -28495,19 +28843,19 @@ static int __Pyx_InitCachedConstants(void) { * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) * */ - __pyx_k_tuple_56 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_56)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_56); + __pyx_k_tuple_57 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_57); __Pyx_INCREF(((PyObject *)__pyx_n_s__phrase)); - PyTuple_SET_ITEM(__pyx_k_tuple_56, 0, ((PyObject *)__pyx_n_s__phrase)); + PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_n_s__phrase)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__phrase)); __Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr)); - PyTuple_SET_ITEM(__pyx_k_tuple_56, 1, ((PyObject *)__pyx_n_s__genexpr)); + PyTuple_SET_ITEM(__pyx_k_tuple_57, 1, ((PyObject *)__pyx_n_s__genexpr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr)); - PyTuple_SET_ITEM(__pyx_k_tuple_56, 2, ((PyObject *)__pyx_n_s__genexpr)); + PyTuple_SET_ITEM(__pyx_k_tuple_57, 2, ((PyObject *)__pyx_n_s__genexpr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_56)); - __pyx_k_codeobj_57 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_56, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_58, __pyx_n_s___phrase, 5, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_57)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57)); + __pyx_k_codeobj_58 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_59, __pyx_n_s___phrase, 5, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_58)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":189 * return [] @@ -28516,12 +28864,12 @@ static int __Pyx_InitCachedConstants(void) { * TER = Scorer('TER') * CER = Scorer('CER') */ - __pyx_k_tuple_59 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_59); + __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_60); __Pyx_INCREF(((PyObject *)__pyx_n_s__IBM_BLEU)); - PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__IBM_BLEU)); + PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__IBM_BLEU)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IBM_BLEU)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190 * @@ -28529,24 +28877,24 @@ static int __Pyx_InitCachedConstants(void) { * TER = Scorer('TER') # <<<<<<<<<<<<<< * CER = Scorer('CER') */ - __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_60); + __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_61); __Pyx_INCREF(((PyObject *)__pyx_n_s__TER)); - PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__TER)); + PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__TER)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191 * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') * CER = Scorer('CER') # <<<<<<<<<<<<<< */ - __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_61); + __pyx_k_tuple_62 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_62)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_62); __Pyx_INCREF(((PyObject *)__pyx_n_s__CER)); - PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__CER)); + PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__CER)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CER)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_62)); /* "_cdec.pyx":28 * class ParseFailed(Exception): pass @@ -28555,13 +28903,13 @@ static int __Pyx_InitCachedConstants(void) { * SetSilent(yn) * */ - __pyx_k_tuple_62 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_62); + __pyx_k_tuple_63 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_63); __Pyx_INCREF(((PyObject *)__pyx_n_s__yn)); - PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__yn)); + PyTuple_SET_ITEM(__pyx_k_tuple_63, 0, ((PyObject *)__pyx_n_s__yn)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__yn)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_62)); - __pyx_k_codeobj_63 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_62, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_64, __pyx_n_s__set_silent, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63)); + __pyx_k_codeobj_64 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_65, __pyx_n_s__set_silent, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "_cdec.pyx":31 * SetSilent(yn) @@ -28570,25 +28918,25 @@ static int __Pyx_InitCachedConstants(void) { * for key, value in config.items(): * if isinstance(value, dict): */ - __pyx_k_tuple_65 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_65); + __pyx_k_tuple_66 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_66); __Pyx_INCREF(((PyObject *)__pyx_n_s__config)); - PyTuple_SET_ITEM(__pyx_k_tuple_65, 0, ((PyObject *)__pyx_n_s__config)); + PyTuple_SET_ITEM(__pyx_k_tuple_66, 0, ((PyObject *)__pyx_n_s__config)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__config)); __Pyx_INCREF(((PyObject *)__pyx_n_s__key)); - PyTuple_SET_ITEM(__pyx_k_tuple_65, 1, ((PyObject *)__pyx_n_s__key)); + PyTuple_SET_ITEM(__pyx_k_tuple_66, 1, ((PyObject *)__pyx_n_s__key)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__key)); __Pyx_INCREF(((PyObject *)__pyx_n_s__value)); - PyTuple_SET_ITEM(__pyx_k_tuple_65, 2, ((PyObject *)__pyx_n_s__value)); + PyTuple_SET_ITEM(__pyx_k_tuple_66, 2, ((PyObject *)__pyx_n_s__value)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__value)); __Pyx_INCREF(((PyObject *)__pyx_n_s__name)); - PyTuple_SET_ITEM(__pyx_k_tuple_65, 3, ((PyObject *)__pyx_n_s__name)); + PyTuple_SET_ITEM(__pyx_k_tuple_66, 3, ((PyObject *)__pyx_n_s__name)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name)); __Pyx_INCREF(((PyObject *)__pyx_n_s__info)); - PyTuple_SET_ITEM(__pyx_k_tuple_65, 4, ((PyObject *)__pyx_n_s__info)); + PyTuple_SET_ITEM(__pyx_k_tuple_66, 4, ((PyObject *)__pyx_n_s__info)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__info)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_65)); - __pyx_k_codeobj_66 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_65, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_64, __pyx_n_s___make_config, 31, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_66)); + __pyx_k_codeobj_67 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_65, __pyx_n_s___make_config, 31, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -28600,7 +28948,6 @@ static int __Pyx_InitGlobals(void) { if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - __pyx_int_65536 = PyInt_FromLong(65536); if (unlikely(!__pyx_int_65536)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; __pyx_L1_error:; return -1; @@ -28689,19 +29036,19 @@ PyMODINIT_FUNC PyInit__cdec(void) if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_NTRef = &__pyx_type_5_cdec_NTRef; - if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_TRule = &__pyx_type_5_cdec_TRule; __pyx_type_5_cdec_MRule.tp_base = __pyx_ptype_5_cdec_TRule; - if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_MRule = &__pyx_type_5_cdec_MRule; - if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Grammar = &__pyx_type_5_cdec_Grammar; __pyx_type_5_cdec_TextGrammar.tp_base = __pyx_ptype_5_cdec_Grammar; - if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_TextGrammar = &__pyx_type_5_cdec_TextGrammar; __pyx_vtabptr_5_cdec_Hypergraph = &__pyx_vtable_5_cdec_Hypergraph; __pyx_vtable_5_cdec_Hypergraph._rng = (MT19937 *(*)(struct __pyx_obj_5_cdec_Hypergraph *))__pyx_f_5_cdec_10Hypergraph__rng; @@ -28711,15 +29058,15 @@ PyMODINIT_FUNC PyInit__cdec(void) __pyx_ptype_5_cdec_Hypergraph = &__pyx_type_5_cdec_Hypergraph; __pyx_vtabptr_5_cdec_HypergraphEdge = &__pyx_vtable_5_cdec_HypergraphEdge; __pyx_vtable_5_cdec_HypergraphEdge.init = (PyObject *(*)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int))__pyx_f_5_cdec_14HypergraphEdge_init; - if (PyType_Ready(&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphEdge.tp_dict, __pyx_vtabptr_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HypergraphEdge", (PyObject *)&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphEdge.tp_dict, __pyx_vtabptr_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HypergraphEdge", (PyObject *)&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_HypergraphEdge = &__pyx_type_5_cdec_HypergraphEdge; __pyx_vtabptr_5_cdec_HypergraphNode = &__pyx_vtable_5_cdec_HypergraphNode; __pyx_vtable_5_cdec_HypergraphNode.init = (PyObject *(*)(struct __pyx_obj_5_cdec_HypergraphNode *, Hypergraph *, unsigned int))__pyx_f_5_cdec_14HypergraphNode_init; - if (PyType_Ready(&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphNode.tp_dict, __pyx_vtabptr_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HypergraphNode", (PyObject *)&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphNode.tp_dict, __pyx_vtabptr_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HypergraphNode", (PyObject *)&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_HypergraphNode = &__pyx_type_5_cdec_HypergraphNode; if (PyType_Ready(&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "Lattice", (PyObject *)&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -28753,13 +29100,13 @@ PyMODINIT_FUNC PyInit__cdec(void) __pyx_ptype_5_cdec___pyx_scope_struct_2__phrase = &__pyx_type_5_cdec___pyx_scope_struct_2__phrase; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_3_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_3_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_3_genexpr; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_4___get__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_4___get__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_4___get__ = &__pyx_type_5_cdec___pyx_scope_struct_4___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_5___str__ = &__pyx_type_5_cdec___pyx_scope_struct_5___str__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_6_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_6_genexpr; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_7___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_7___iter__; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_kbest) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_8_kbest = &__pyx_type_5_cdec___pyx_scope_struct_8_kbest; @@ -28771,21 +29118,21 @@ PyMODINIT_FUNC PyInit__cdec(void) __pyx_ptype_5_cdec___pyx_scope_struct_11_sample = &__pyx_type_5_cdec___pyx_scope_struct_11_sample; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_12_sample_trees = &__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_13___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_13___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_13___get__ = &__pyx_type_5_cdec___pyx_scope_struct_13___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_14___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_14___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_14___get__ = &__pyx_type_5_cdec___pyx_scope_struct_14___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_15___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_15___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_15___get__ = &__pyx_type_5_cdec___pyx_scope_struct_15___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_16___get__ = &__pyx_type_5_cdec___pyx_scope_struct_16___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_17___get__ = &__pyx_type_5_cdec___pyx_scope_struct_17___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_18___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_18___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_18___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_18___iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_19_todot) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_19_todot) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_19_todot = &__pyx_type_5_cdec___pyx_scope_struct_19_todot; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_20_lines) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_20_lines) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_20_lines = &__pyx_type_5_cdec___pyx_scope_struct_20_lines; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_21___iter__) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_21___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_21___iter__; @@ -28798,9 +29145,14 @@ PyMODINIT_FUNC PyInit__cdec(void) if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_25_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_25_genexpr; /*--- Type import code ---*/ - __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_FloatList = __Pyx_ImportType("cdec.sa._sa", "FloatList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FloatList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_FloatList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_FloatList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_IntList = __Pyx_ImportType("cdec.sa._sa", "IntList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_IntList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_IntList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_FeatureVector = __Pyx_ImportType("cdec.sa._sa", "FeatureVector", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FeatureVector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("cdec.sa._sa"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -28820,10 +29172,10 @@ PyMODINIT_FUNC PyInit__cdec(void) */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_n_s_55)); - PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_55)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_55)); - __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_54), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(((PyObject *)__pyx_n_s_56)); + PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_56)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s_56)); + __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_55), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_s___sa, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -28848,7 +29200,7 @@ PyMODINIT_FUNC PyInit__cdec(void) * TER = Scorer('TER') * CER = Scorer('CER') */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -28859,7 +29211,7 @@ PyMODINIT_FUNC PyInit__cdec(void) * TER = Scorer('TER') # <<<<<<<<<<<<<< * CER = Scorer('CER') */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -28869,7 +29221,7 @@ PyMODINIT_FUNC PyInit__cdec(void) * TER = Scorer('TER') * CER = Scorer('CER') # <<<<<<<<<<<<<< */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_62), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; diff --git a/python/src/_cdec.pyx b/python/src/_cdec.pyx index 5cdf8eb3..6c6c8eee 100644 --- a/python/src/_cdec.pyx +++ b/python/src/_cdec.pyx @@ -96,14 +96,14 @@ cdef class Decoder: def translate(self, sentence, grammar=None): cdef bytes input_str - if isinstance(sentence, unicode) or isinstance(sentence, str): + if isinstance(sentence, basestring): input_str = as_str(sentence.strip()) elif isinstance(sentence, Lattice): input_str = str(sentence) # PLF format else: raise TypeError('Cannot translate input type %s' % type(sentence)) if grammar: - if isinstance(grammar, str) or isinstance(grammar, unicode): + if isinstance(grammar, basestring): self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) else: self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) diff --git a/python/src/grammar.pxi b/python/src/grammar.pxi index 05351290..b05d07a0 100644 --- a/python/src/grammar.pxi +++ b/python/src/grammar.pxi @@ -26,11 +26,8 @@ cdef class NTRef: return '[%d]' % self.ref cdef TRule convert_rule(_sa.Rule rule): - cdef unsigned i - cdef lhs = _sa.sym_tocat(rule.lhs) - cdef scores = {} - for i in range(rule.n_scores): - scores['PhraseModel_'+str(i)] = rule.cscores[i] + lhs = _sa.sym_tocat(rule.lhs) + scores = dict(rule.scores) f, e = [], [] cdef int* fsyms = rule.f.syms for i in range(rule.f.n): @@ -44,7 +41,7 @@ cdef TRule convert_rule(_sa.Rule rule): e.append(NTRef(_sa.sym_getindex(esyms[i]))) else: e.append(_sa.sym_tostring(esyms[i])) - cdef a = [(point/65536, point%65536) for point in rule.word_alignments] + a = list(rule.alignments()) return TRule(lhs, f, e, scores, a) cdef class TRule: @@ -92,7 +89,7 @@ cdef class TRule: if isinstance(f[i], NT): f_[0][i] = -TDConvert(f[i].cat) else: - f_[0][i] = TDConvert(as_str(f[i])) + f_[0][i] = TDConvert(as_str(f[i])) property e: def __get__(self): @@ -118,7 +115,7 @@ cdef class TRule: if isinstance(e[i], NTRef): e_[0][i] = 1-e[i].ref else: - e_[0][i] = TDConvert(as_str(e[i])) + e_[0][i] = TDConvert(as_str(e[i])) property a: def __get__(self): @@ -148,7 +145,7 @@ cdef class TRule: cdef int fid cdef float fval for fname, fval in scores.items(): - fid = FDConvert(as_str(fname)) + fid = FDConvert(as_str(fname)) if fid < 0: raise KeyError(fname) scores_.set_value(fid, fval) diff --git a/python/src/hypergraph.pxd b/python/src/hypergraph.pxd index 1ddc2e5d..acab7244 100644 --- a/python/src/hypergraph.pxd +++ b/python/src/hypergraph.pxd @@ -31,6 +31,7 @@ cdef extern from "decoder/hg.h": ctypedef HypergraphNode const_HypergraphNode "const Hypergraph::Node" cdef cppclass Hypergraph: + Hypergraph() Hypergraph(Hypergraph) nogil vector[HypergraphNode] nodes_ vector[HypergraphEdge] edges_ @@ -57,10 +58,13 @@ cdef extern from "decoder/viterbi.h": string JoshuaVisualizationString(Hypergraph& hg) nogil cdef extern from "decoder/hg_io.h" namespace "HypergraphIO": + # Hypergraph JSON I/O bint ReadFromJSON(istream* inp, Hypergraph* out) bint WriteToJSON(Hypergraph& hg, bint remove_rules, ostream* out) - void ReadFromPLF(string& inp, Hypergraph* out, int line) + # Hypergraph PLF I/O + void ReadFromPLF(string& inp, Hypergraph* out) string AsPLF(Hypergraph& hg, bint include_global_parentheses) + # Lattice PLF I/O void PLFtoLattice(string& plf, Lattice* pl) string AsPLF(Lattice& lat, bint include_global_parentheses) diff --git a/python/src/hypergraph.pxi b/python/src/hypergraph.pxi index 1edff3cb..bb6141df 100644 --- a/python/src/hypergraph.pxi +++ b/python/src/hypergraph.pxi @@ -98,7 +98,14 @@ cdef class Hypergraph: finally: del trees - def intersect(self, Lattice lat): + def intersect(self, inp): + cdef Lattice lat + if isinstance(inp, Lattice): + lat = inp + elif isinstance(inp, basestring): + lat = Lattice(inp) + else: + raise TypeError('cannot intersect hypergraph with %s' % type(inp)) return hypergraph.Intersect(lat.lattice[0], self.hg) def prune(self, beam_alpha=0, density=0, **kwargs): @@ -114,6 +121,9 @@ cdef class Hypergraph: cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() return Lattice(eval(plf)) + def plf(self): + return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) + def reweight(self, weights): if isinstance(weights, SparseVector): self.hg.Reweight(( weights).vector[0]) diff --git a/python/src/lattice.pxd b/python/src/lattice.pxd index 3a4bc22f..8ad710e5 100644 --- a/python/src/lattice.pxd +++ b/python/src/lattice.pxd @@ -12,10 +12,9 @@ cdef extern from "decoder/lattice.h": cdef cppclass Lattice(vector): # (vector[vector[LatticeArc]]) Lattice() - Lattice(unsigned t) - Lattice(unsigned t, vector[LatticeArc]& v) bint IsSentence() vector[LatticeArc]& operator[](unsigned) + void resize(unsigned) cdef extern from "decoder/lattice.h" namespace "LatticeTools": - void ConvertTextToLattice(string& text, Lattice* pl) + void ConvertTextOrPLF(string& text, Lattice* pl) diff --git a/python/src/lattice.pxi b/python/src/lattice.pxi index 385a40be..57e340d2 100644 --- a/python/src/lattice.pxi +++ b/python/src/lattice.pxi @@ -3,18 +3,20 @@ cimport lattice cdef class Lattice: cdef lattice.Lattice* lattice - def __cinit__(self, inp): + def __cinit__(self): + self.lattice = new lattice.Lattice() + + def __init__(self, inp): if isinstance(inp, tuple): - self.lattice = new lattice.Lattice(len(inp)) + self.lattice.resize(len(inp)) for i, arcs in enumerate(inp): self[i] = arcs else: if isinstance(inp, unicode): inp = inp.encode('utf8') if not isinstance(inp, str): - raise TypeError('Cannot create lattice from %s' % type(inp)) - self.lattice = new lattice.Lattice() - lattice.ConvertTextToLattice(string(inp), self.lattice) + raise TypeError('cannot create lattice from %s' % type(inp)) + lattice.ConvertTextOrPLF(string(inp), self.lattice) def __dealloc__(self): del self.lattice @@ -49,6 +51,9 @@ cdef class Lattice: def __str__(self): return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) + def __unicode__(self): + return unicode(str(self), 'utf8') + def __iter__(self): cdef unsigned i for i in range(len(self)): @@ -65,3 +70,10 @@ cdef class Lattice: yield '%d [shape=doublecircle]' % len(self) yield '}' return '\n'.join(lines()).encode('utf8') + + def as_hypergraph(self): + cdef Hypergraph result = Hypergraph.__new__(Hypergraph) + result.hg = new hypergraph.Hypergraph() + cdef bytes plf = str(self) + hypergraph.ReadFromPLF(string(plf), result.hg) + return result diff --git a/python/src/mteval.pxi b/python/src/mteval.pxi index f1b6b5d1..00355f96 100644 --- a/python/src/mteval.pxi +++ b/python/src/mteval.pxi @@ -127,7 +127,7 @@ cdef class Scorer: del self.name def __call__(self, refs): - if isinstance(refs, unicode) or isinstance(refs, str): + if isinstance(refs, basestring): refs = [refs] cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() cdef vector[WordID]* refv diff --git a/python/src/sa/_sa.c b/python/src/sa/_sa.c index 0f9b0d22..2dfd212b 100644 --- a/python/src/sa/_sa.c +++ b/python/src/sa/_sa.c @@ -1,4 +1,4 @@ -/* Generated by Cython 0.17.beta1 on Sat Jul 28 17:07:03 2012 */ +/* Generated by Cython 0.17.beta1 on Tue Aug 14 22:38:21 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -375,40 +375,50 @@ static const char *__pyx_f[] = { "rulefactory.pxi", "lcp.pxi", "sym.pxi", - "_sa.pxd", "precomputation.pxi", "suffix_array.pxi", + "features.pxi", "str_map.pxi", }; /*--- Type declarations ---*/ struct __pyx_obj_3_sa_HieroCachingRuleFactory; -struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats; +struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__; +struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats; +struct __pyx_obj_3_sa___pyx_scope_struct_11_input; struct __pyx_obj_3_sa_IntList; struct __pyx_obj_3_sa_VEBIterator; struct __pyx_obj_3_sa_BiLex; -struct __pyx_obj_3_sa_VEB; +struct __pyx_obj_3_sa_TrieNode; struct __pyx_obj_3_sa_LCP; struct __pyx_obj_3_sa_DataArray; struct __pyx_obj_3_sa_BitSetIterator; -struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext; struct __pyx_obj_3_sa_Precomputation; +struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__; struct __pyx_obj_3_sa_SuffixArray; -struct __pyx_obj_3_sa___pyx_scope_struct_4_input; struct __pyx_obj_3_sa_Alphabet; struct __pyx_obj_3_sa_Rule; +struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr; +struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr; struct __pyx_obj_3_sa_PhraseLocation; -struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__; +struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext; +struct __pyx_obj_3_sa_FeatureVector; +struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments; +struct __pyx_obj_3_sa_Scorer; struct __pyx_obj_3_sa_Alignment; struct __pyx_obj_3_sa_BitSet; struct __pyx_obj_3_sa_Sampler; +struct __pyx_obj_3_sa___pyx_scope_struct_9___str__; struct __pyx_obj_3_sa_StringMap; -struct __pyx_obj_3_sa_TrieNode; +struct __pyx_obj_3_sa_VEB; struct __pyx_obj_3_sa_ExtendedTrieNode; struct __pyx_obj_3_sa_TrieMap; +struct __pyx_obj_3_sa_DefaultScorer; struct __pyx_obj_3_sa_Phrase; +struct __pyx_obj_3_sa___pyx_scope_struct____iter__; struct __pyx_obj_3_sa_TrieTable; -struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr; +struct __pyx_obj_3_sa___pyx_scope_struct_5___str__; +struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr; struct __pyx_obj_3_sa_FloatList; struct __pyx_t_3_sa__node; struct __pyx_t_3_sa__BitSet; @@ -490,7 +500,7 @@ struct __pyx_t_3_sa__Trie_Node { int arr_len; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":48 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":50 * * # linked list structure for storing matches in BaselineRuleFactory * cdef struct match_node: # <<<<<<<<<<<<<< @@ -502,7 +512,7 @@ struct __pyx_t_3_sa_match_node { struct __pyx_t_3_sa_match_node *next; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":145 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":146 * * # struct used to encapsulate a single matching * cdef struct Matching: # <<<<<<<<<<<<<< @@ -517,7 +527,7 @@ struct __pyx_t_3_sa_Matching { int size; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":201 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":202 * * * cdef class HieroCachingRuleFactory: # <<<<<<<<<<<<<< @@ -529,6 +539,7 @@ struct __pyx_obj_3_sa_HieroCachingRuleFactory { struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *__pyx_vtab; struct __pyx_obj_3_sa_TrieTable *rules; struct __pyx_obj_3_sa_Sampler *sampler; + struct __pyx_obj_3_sa_Scorer *scorer; int max_chunks; int max_target_chunks; int max_length; @@ -565,6 +576,21 @@ struct __pyx_obj_3_sa_HieroCachingRuleFactory { }; +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":141 + * return self.syms[i] + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i from 0 <= i < self.n: + */ +struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ { + PyObject_HEAD + int __pyx_v_i; + struct __pyx_obj_3_sa_Phrase *__pyx_v_self; + int __pyx_t_0; +}; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/lcp.pxi":36 * logger.info("LCP array completed") * @@ -572,7 +598,7 @@ struct __pyx_obj_3_sa_HieroCachingRuleFactory { * """Note: the output of this function is not exact. In * particular, the frequency associated with each word is */ -struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats { +struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats { PyObject_HEAD int __pyx_v_N; int __pyx_v_freq; @@ -596,8 +622,90 @@ struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":9 - * from libc.string cimport memset, memcpy +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":923 + * return sorted(result); + * + * def input(self, fwords): # <<<<<<<<<<<<<< + * '''When this function is called on the RuleFactory, + * it looks up all of the rules that can be used to translate + */ +struct __pyx_obj_3_sa___pyx_scope_struct_11_input { + PyObject_HEAD + PyObject *__pyx_v_alignment; + PyObject *__pyx_v_als; + PyObject *__pyx_v_alslist; + int __pyx_v_alt; + int __pyx_v_alt_id; + int __pyx_v_arity; + struct __pyx_obj_3_sa_IntList *__pyx_v_chunklen; + PyObject *__pyx_v_count; + PyObject *__pyx_v_currcount; + PyObject *__pyx_v_e; + PyObject *__pyx_v_elist; + PyObject *__pyx_v_extract; + PyObject *__pyx_v_extract_start; + PyObject *__pyx_v_extract_stop; + PyObject *__pyx_v_extracts; + PyObject *__pyx_v_f; + PyObject *__pyx_v_fcount; + int __pyx_v_flen; + PyObject *__pyx_v_fphrases; + PyObject *__pyx_v_frontier; + PyObject *__pyx_v_frontier_nodes; + PyObject *__pyx_v_fwords; + struct __pyx_obj_3_sa_Phrase *__pyx_v_hiero_phrase; + long __pyx_v_hit; + int __pyx_v_i; + PyObject *__pyx_v_is_shadow_path; + int __pyx_v_j; + int __pyx_v_k; + PyObject *__pyx_v_key; + int __pyx_v_lookup_required; + struct __pyx_t_3_sa_Matching __pyx_v_matching; + PyObject *__pyx_v_new_frontier; + PyObject *__pyx_v_new_node; + PyObject *__pyx_v_next_states; + PyObject *__pyx_v_node; + PyObject *__pyx_v_nodes_isteps_away_buffer; + int __pyx_v_nualt; + int __pyx_v_num_samples; + int __pyx_v_num_subpatterns; + PyObject *__pyx_v_pathlen; + PyObject *__pyx_v_phrase; + struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_phrase_location; + PyObject *__pyx_v_prefix; + PyObject *__pyx_v_reachable_buffer; + PyObject *__pyx_v_sa_range; + struct __pyx_obj_3_sa_IntList *__pyx_v_sample; + struct __pyx_obj_3_sa_FeatureVector *__pyx_v_scores; + struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self; + PyObject *__pyx_v_spanlen; + float __pyx_v_start_time; + PyObject *__pyx_v_stop_time; + PyObject *__pyx_v_suffix_link; + int __pyx_v_suffix_link_xcat; + PyObject *__pyx_v_suffix_link_xcat_index; + PyObject *__pyx_v_word_id; + int __pyx_v_x1; + int __pyx_v_xcat; + PyObject *__pyx_v_xcat_index; + PyObject *__pyx_v_xnode; + PyObject *__pyx_v_xroot; + Py_ssize_t __pyx_t_0; + PyObject *__pyx_t_1; + Py_ssize_t __pyx_t_2; + int __pyx_t_3; + PyObject *__pyx_t_4; + PyObject *__pyx_t_5; + int __pyx_t_6; + Py_ssize_t __pyx_t_7; + Py_ssize_t __pyx_t_8; + Py_ssize_t __pyx_t_9; +}; + + +/* "_sa.pxd":12 + * cdef void read_handle(self, FILE* f) * * cdef class IntList: # <<<<<<<<<<<<<< * cdef int size @@ -648,17 +756,16 @@ struct __pyx_obj_3_sa_BiLex { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/veb.pxi":354 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":20 + * cdef int EPSILON = sym_fromstring('*EPS*', True) * + * cdef class TrieNode: # <<<<<<<<<<<<<< + * cdef public children * - * cdef class VEB: # <<<<<<<<<<<<<< - * cdef _VEB* veb - * cdef int _findsucc(self, int i) */ -struct __pyx_obj_3_sa_VEB { +struct __pyx_obj_3_sa_TrieNode { PyObject_HEAD - struct __pyx_vtabstruct_3_sa_VEB *__pyx_vtab; - struct __pyx_t_3_sa__VEB *veb; + PyObject *children; }; @@ -709,20 +816,6 @@ struct __pyx_obj_3_sa_BitSetIterator { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/data_array.pxi":71 - * self.read_text_data(fp) - * - * def read_bitext(self, char* filename, int side): # <<<<<<<<<<<<<< - * with gzip_or_text(filename) as fp: - * data = (line.split(' ||| ')[side] for line in fp) - */ -struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext { - PyObject_HEAD - PyObject *__pyx_v_fp; - int __pyx_v_side; -}; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":188 * * @@ -744,6 +837,22 @@ struct __pyx_obj_3_sa_Precomputation { }; +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":15 + * self.values.append(value) + * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef unsigned i + * for i in range(self.names.len): + */ +struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ { + PyObject_HEAD + unsigned int __pyx_v_i; + struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self; + int __pyx_t_0; + unsigned int __pyx_t_1; +}; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/suffix_array.pxi":6 * from libc.stdio cimport FILE, fclose, fopen * @@ -760,92 +869,6 @@ struct __pyx_obj_3_sa_SuffixArray { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":919 - * return sorted(result); - * - * def input(self, fwords, models): # <<<<<<<<<<<<<< - * '''When this function is called on the RuleFactory, - * it looks up all of the rules that can be used to translate - */ -struct __pyx_obj_3_sa___pyx_scope_struct_4_input { - PyObject_HEAD - PyObject *__pyx_v_alignment; - PyObject *__pyx_v_als; - PyObject *__pyx_v_alslist; - int __pyx_v_alt; - int __pyx_v_alt_id; - int __pyx_v_arity; - struct __pyx_obj_3_sa_IntList *__pyx_v_chunklen; - PyObject *__pyx_v_count; - PyObject *__pyx_v_currcount; - PyObject *__pyx_v_e; - PyObject *__pyx_v_elist; - PyObject *__pyx_v_extract; - PyObject *__pyx_v_extract_start; - PyObject *__pyx_v_extract_stop; - PyObject *__pyx_v_extracts; - PyObject *__pyx_v_f; - PyObject *__pyx_v_f_margin; - PyObject *__pyx_v_fals; - PyObject *__pyx_v_fcount; - int __pyx_v_flen; - PyObject *__pyx_v_fphrases; - PyObject *__pyx_v_frontier; - PyObject *__pyx_v_frontier_nodes; - PyObject *__pyx_v_fwords; - struct __pyx_obj_3_sa_Phrase *__pyx_v_hiero_phrase; - long __pyx_v_hit; - int __pyx_v_i; - PyObject *__pyx_v_is_shadow_path; - int __pyx_v_j; - int __pyx_v_k; - PyObject *__pyx_v_key; - int __pyx_v_lookup_required; - struct __pyx_t_3_sa_Matching __pyx_v_matching; - PyObject *__pyx_v_model; - PyObject *__pyx_v_models; - PyObject *__pyx_v_new_frontier; - PyObject *__pyx_v_new_node; - PyObject *__pyx_v_next_states; - PyObject *__pyx_v_node; - PyObject *__pyx_v_nodes_isteps_away_buffer; - int __pyx_v_nualt; - int __pyx_v_num_samples; - int __pyx_v_num_subpatterns; - PyObject *__pyx_v_pathlen; - PyObject *__pyx_v_phrase; - struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_phrase_location; - PyObject *__pyx_v_prefix; - PyObject *__pyx_v_reachable_buffer; - PyObject *__pyx_v_sa_range; - struct __pyx_obj_3_sa_IntList *__pyx_v_sample; - PyObject *__pyx_v_scores; - struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self; - PyObject *__pyx_v_spanlen; - float __pyx_v_start_time; - PyObject *__pyx_v_stop_time; - PyObject *__pyx_v_suffix_link; - int __pyx_v_suffix_link_xcat; - PyObject *__pyx_v_suffix_link_xcat_index; - PyObject *__pyx_v_word_id; - int __pyx_v_x1; - int __pyx_v_xcat; - PyObject *__pyx_v_xcat_index; - PyObject *__pyx_v_xnode; - PyObject *__pyx_v_xroot; - Py_ssize_t __pyx_t_0; - PyObject *__pyx_t_1; - Py_ssize_t __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4; - PyObject *__pyx_t_5; - int __pyx_t_6; - Py_ssize_t __pyx_t_7; - Py_ssize_t __pyx_t_8; - Py_ssize_t __pyx_t_9; -}; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/sym.pxi":7 * cdef int INDEX_MASK = (1<= 3 - value = PyDict_GetItemWithError(d, key); - if (unlikely(!value)) { - if (unlikely(PyErr_Occurred())) - return NULL; - if (unlikely(PyDict_SetItem(d, key, default_value) == -1)) - return NULL; - value = default_value; - } - Py_INCREF(value); -#else - if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) { - value = PyDict_GetItem(d, key); - if (unlikely(!value)) { - if (unlikely(PyDict_SetItem(d, key, default_value) == -1)) - return NULL; - value = default_value; - } - Py_INCREF(value); - } else { - PyObject *m; - m = __Pyx_GetAttrString(d, "setdefault"); - if (!m) return NULL; - value = PyObject_CallFunctionObjArgs(m, key, default_value, NULL); - Py_DECREF(m); - } -#endif - return value; -} - static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/ +static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name); + #include static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ @@ -1793,6 +1959,48 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int #define __Pyx_PyString_Equals __Pyx_PyBytes_Equals #endif +#define __Pyx_CyFunction_USED 1 +#include +#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 *); @@ -1892,10 +2100,11 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ /* Module declarations from 'libc.math' */ /* Module declarations from '_sa' */ -static PyTypeObject *__pyx_ptype_3_sa_Phrase = 0; -static PyTypeObject *__pyx_ptype_3_sa_Rule = 0; static PyTypeObject *__pyx_ptype_3_sa_FloatList = 0; static PyTypeObject *__pyx_ptype_3_sa_IntList = 0; +static PyTypeObject *__pyx_ptype_3_sa_FeatureVector = 0; +static PyTypeObject *__pyx_ptype_3_sa_Phrase = 0; +static PyTypeObject *__pyx_ptype_3_sa_Rule = 0; static PyTypeObject *__pyx_ptype_3_sa_StringMap = 0; static PyTypeObject *__pyx_ptype_3_sa_DataArray = 0; static PyTypeObject *__pyx_ptype_3_sa_Alignment = 0; @@ -1909,23 +2118,33 @@ static PyTypeObject *__pyx_ptype_3_sa_Alphabet = 0; static PyTypeObject *__pyx_ptype_3_sa_TrieMap = 0; static PyTypeObject *__pyx_ptype_3_sa_Precomputation = 0; static PyTypeObject *__pyx_ptype_3_sa_SuffixArray = 0; +static PyTypeObject *__pyx_ptype_3_sa_Scorer = 0; +static PyTypeObject *__pyx_ptype_3_sa_DefaultScorer = 0; static PyTypeObject *__pyx_ptype_3_sa_TrieNode = 0; static PyTypeObject *__pyx_ptype_3_sa_ExtendedTrieNode = 0; static PyTypeObject *__pyx_ptype_3_sa_TrieTable = 0; static PyTypeObject *__pyx_ptype_3_sa_PhraseLocation = 0; static PyTypeObject *__pyx_ptype_3_sa_Sampler = 0; static PyTypeObject *__pyx_ptype_3_sa_HieroCachingRuleFactory = 0; -static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct__read_bitext = 0; -static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_1_genexpr = 0; -static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_2_compute_stats = 0; -static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_3___iter__ = 0; -static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_4_input = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct____iter__ = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_1_read_bitext = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_2_genexpr = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_3_compute_stats = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_4___iter__ = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_5___str__ = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_6_genexpr = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_7_alignments = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_8___iter__ = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_9___str__ = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_10_genexpr = 0; +static PyTypeObject *__pyx_ptype_3_sa___pyx_scope_struct_11_input = 0; static int __pyx_v_3_sa_MIN_BOTTOM_SIZE; static int __pyx_v_3_sa_MIN_BOTTOM_BITS; static int __pyx_v_3_sa_LOWER_MASK[32]; static int __pyx_v_3_sa_INDEX_SHIFT; static int __pyx_v_3_sa_INDEX_MASK; static struct __pyx_obj_3_sa_Alphabet *__pyx_v_3_sa_ALPHABET = 0; +static struct __pyx_obj_3_sa_StringMap *__pyx_v_3_sa_FD = 0; static int __pyx_v_3_sa_PRECOMPUTE; static int __pyx_v_3_sa_MERGE; static int __pyx_v_3_sa_BAEZA_YATES; @@ -1977,7 +2196,6 @@ static PyObject *__pyx_builtin_Exception; static PyObject *__pyx_builtin_zip; static PyObject *__pyx_builtin_StopIteration; static PyObject *__pyx_builtin_cmp; -static PyObject *__pyx_builtin_ValueError; static PyObject *__pyx_builtin_sorted; static PyObject *__pyx_pf_3_sa_gzip_or_text(CYTHON_UNUSED PyObject *__pyx_self, char *__pyx_v_filename); /* proto */ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *__pyx_v_self, int __pyx_v_size, int __pyx_v_increment, int __pyx_v_initial_len); /* proto */ @@ -1996,14 +2214,15 @@ static PyObject *__pyx_pf_3_sa_7IntList_8_doquicksort(struct __pyx_obj_3_sa_IntL static PyObject *__pyx_pf_3_sa_7IntList_10sort(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_3_sa_7IntList_12reset(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ static void __pyx_pf_3_sa_7IntList_14__dealloc__(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ -static int __pyx_pf_3_sa_7IntList_18__setitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val); /* proto */ -static Py_ssize_t __pyx_pf_3_sa_7IntList_20__len__(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_3_sa_7IntList_22getSize(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_3_sa_7IntList_24append(struct __pyx_obj_3_sa_IntList *__pyx_v_self, int __pyx_v_val); /* proto */ -static PyObject *__pyx_pf_3_sa_7IntList_26extend(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_other); /* proto */ -static PyObject *__pyx_pf_3_sa_7IntList_28write(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename); /* proto */ -static PyObject *__pyx_pf_3_sa_7IntList_30read(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_16__iter__(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_19__getitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_index); /* proto */ +static int __pyx_pf_3_sa_7IntList_21__setitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val); /* proto */ +static Py_ssize_t __pyx_pf_3_sa_7IntList_23__len__(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_25getSize(struct __pyx_obj_3_sa_IntList *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_27append(struct __pyx_obj_3_sa_IntList *__pyx_v_self, int __pyx_v_val); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_29extend(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_other); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_31write(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename); /* proto */ +static PyObject *__pyx_pf_3_sa_7IntList_33read(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename); /* proto */ static int __pyx_pf_3_sa_9StringMap___cinit__(struct __pyx_obj_3_sa_StringMap *__pyx_v_self); /* proto */ static void __pyx_pf_3_sa_9StringMap_2__dealloc__(struct __pyx_obj_3_sa_StringMap *__pyx_v_self); /* proto */ static int __pyx_pf_3_sa_9DataArray___cinit__(struct __pyx_obj_3_sa_DataArray *__pyx_v_self, PyObject *__pyx_v_from_binary, PyObject *__pyx_v_from_text, PyObject *__pyx_v_side, int __pyx_v_use_sent_id); /* proto */ @@ -2086,24 +2305,17 @@ static PyObject *__pyx_pf_3_sa_6Phrase_28__iter__(struct __pyx_obj_3_sa_Phrase * static PyObject *__pyx_pf_3_sa_6Phrase_31subst(struct __pyx_obj_3_sa_Phrase *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_children); /* proto */ static PyObject *__pyx_pf_3_sa_6Phrase_5words___get__(struct __pyx_obj_3_sa_Phrase *__pyx_v_self); /* proto */ static int __pyx_pf_3_sa_4Rule___cinit__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, int __pyx_v_lhs, struct __pyx_obj_3_sa_Phrase *__pyx_v_f, struct __pyx_obj_3_sa_Phrase *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_word_alignments); /* proto */ -static void __pyx_pf_3_sa_4Rule_2__dealloc__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static Py_hash_t __pyx_pf_3_sa_4Rule_4__hash__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ +static Py_hash_t __pyx_pf_3_sa_4Rule_2__hash__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ #if PY_MAJOR_VERSION < 3 -static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Rule *__pyx_v_other); /* proto */ +static int __pyx_pf_3_sa_4Rule_4__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Rule *__pyx_v_other); /* proto */ #endif -static PyObject *__pyx_pf_3_sa_4Rule_8__iadd__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Rule *__pyx_v_other); /* proto */ -static PyObject *__pyx_pf_3_sa_4Rule_10fmerge(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_f); /* proto */ -static PyObject *__pyx_pf_3_sa_4Rule_12arity(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_3_sa_4Rule_14__str__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_3_sa_4Rule_6scores___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static int __pyx_pf_3_sa_4Rule_6scores_2__set__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, PyObject *__pyx_v_s); /* proto */ -static PyObject *__pyx_pf_3_sa_4Rule_3lhs___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static int __pyx_pf_3_sa_4Rule_3lhs_2__set__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ +static PyObject *__pyx_pf_3_sa_4Rule_6fmerge(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_f); /* proto */ +static PyObject *__pyx_pf_3_sa_4Rule_8arity(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_4Rule_7__str___genexpr(PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_3_sa_4Rule_10__str__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_4Rule_12alignments(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_3_sa_4Rule_1f___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_3_sa_4Rule_1e___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_3_sa_4Rule_15word_alignments___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ -static int __pyx_pf_3_sa_4Rule_15word_alignments_2__set__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ -static int __pyx_pf_3_sa_4Rule_15word_alignments_4__del__(struct __pyx_obj_3_sa_Rule *__pyx_v_self); /* proto */ static int __pyx_pf_3_sa_7TrieMap___cinit__(struct __pyx_obj_3_sa_TrieMap *__pyx_v_self, int __pyx_v_alphabet_size); /* proto */ static void __pyx_pf_3_sa_7TrieMap_2__dealloc__(struct __pyx_obj_3_sa_TrieMap *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_3_sa_7TrieMap_4insert(struct __pyx_obj_3_sa_TrieMap *__pyx_v_self, PyObject *__pyx_v_pattern); /* proto */ @@ -2125,6 +2337,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_16read_binary(struct __pyx_obj_3_sa static PyObject *__pyx_pf_3_sa_11SuffixArray_18write_binary(struct __pyx_obj_3_sa_SuffixArray *__pyx_v_self, char *__pyx_v_filename); /* proto */ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3_sa_SuffixArray *__pyx_v_self, char *__pyx_v_filename); /* proto */ static PyObject *__pyx_pf_3_sa_11SuffixArray_22lookup(struct __pyx_obj_3_sa_SuffixArray *__pyx_v_self, PyObject *__pyx_v_word, int __pyx_v_offset, int __pyx_v_low, int __pyx_v_high); /* proto */ +static int __pyx_pf_3_sa_13FeatureVector___cinit__(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_13FeatureVector_2set(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self, unsigned int __pyx_v_name, float __pyx_v_value); /* proto */ +static PyObject *__pyx_pf_3_sa_13FeatureVector_4__iter__(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self); /* proto */ +static PyObject *__pyx_pf_3_sa_13FeatureVector_7__str___genexpr(PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_3_sa_13FeatureVector_7__str__(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self); /* proto */ +static int __pyx_pf_3_sa_6Scorer___init__(struct __pyx_obj_3_sa_Scorer *__pyx_v_self, PyObject *__pyx_v_models); /* proto */ +static void __pyx_pf_3_sa_13DefaultScorer___dealloc__(struct __pyx_obj_3_sa_DefaultScorer *__pyx_v_self); /* proto */ +static int __pyx_pf_3_sa_13DefaultScorer_2__init__(struct __pyx_obj_3_sa_DefaultScorer *__pyx_v_self, struct __pyx_obj_3_sa_BiLex *__pyx_v_ttable); /* proto */ static int __pyx_pf_3_sa_8TrieNode___cinit__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_3_sa_8TrieNode_8children___get__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self); /* proto */ static int __pyx_pf_3_sa_8TrieNode_8children_2__set__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ @@ -2151,7 +2371,7 @@ static int __pyx_pf_3_sa_14PhraseLocation___cinit__(struct __pyx_obj_3_sa_Phrase static int __pyx_pf_3_sa_7Sampler___cinit__(struct __pyx_obj_3_sa_Sampler *__pyx_v_self, int __pyx_v_sample_size, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray); /* proto */ static PyObject *__pyx_pf_3_sa_7Sampler_2sample(struct __pyx_obj_3_sa_Sampler *__pyx_v_self, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_phrase_location); /* proto */ static int __pyx_pf_3_sa_23HieroCachingRuleFactory___cinit__(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Alignment *__pyx_v_alignment, float __pyx_v_by_slack_factor, char *__pyx_v_category, PyObject *__pyx_v_max_chunks, unsigned int __pyx_v_max_initial_size, unsigned int __pyx_v_max_length, unsigned int __pyx_v_max_nonterminals, PyObject *__pyx_v_max_target_chunks, PyObject *__pyx_v_max_target_length, unsigned int __pyx_v_min_gap_size, PyObject *__pyx_v_precompute_file, unsigned int __pyx_v_precompute_secondary_rank, unsigned int __pyx_v_precompute_rank, int __pyx_v_require_aligned_terminal, int __pyx_v_require_aligned_chunks, unsigned int __pyx_v_train_max_initial_size, unsigned int __pyx_v_train_min_gap_size, int __pyx_v_tight_phrases, int __pyx_v_use_baeza_yates, int __pyx_v_use_collocations, int __pyx_v_use_index); /* proto */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_2configure(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray, struct __pyx_obj_3_sa_DataArray *__pyx_v_edarray, struct __pyx_obj_3_sa_Sampler *__pyx_v_sampler); /* proto */ +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_2configure(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray, struct __pyx_obj_3_sa_DataArray *__pyx_v_edarray, struct __pyx_obj_3_sa_Sampler *__pyx_v_sampler, struct __pyx_obj_3_sa_Scorer *__pyx_v_scorer); /* proto */ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_4pattern2phrase(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_pattern); /* proto */ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_6pattern2phrase_plus(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_pattern); /* proto */ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_8precompute(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self); /* proto */ @@ -2161,7 +2381,8 @@ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_14get_all_nodes_isteps_ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_16reachable(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_ifrom, PyObject *__pyx_v_dist); /* proto */ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_18shortest(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_ifrom, PyObject *__pyx_v_ito); /* proto */ static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_20get_next_states(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v__columns, PyObject *__pyx_v_curr_idx, PyObject *__pyx_v_min_dist); /* proto */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_22input(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_models); /* proto */ +static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self); /* proto */ +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_22input(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords); /* proto */ static char __pyx_k_1[] = ".gz"; static char __pyx_k_2[] = "Requested index %d of %d-length FloatList"; static char __pyx_k_3[] = "IntList["; @@ -2214,6 +2435,7 @@ static char __pyx_k_91[] = " Refinement took %f seconds"; static char __pyx_k_92[] = " Finalizing sort..."; static char __pyx_k_94[] = "Suffix array construction took %f seconds"; static char __pyx_k_95[] = "Unexpected condition found in q3sort: sort from %d to %d"; +static char __pyx_k_99[] = "%s=%s"; static char __pyx_k__0[] = "0"; static char __pyx_k__1[] = "1"; static char __pyx_k__e[] = "e"; @@ -2223,41 +2445,41 @@ static char __pyx_k__i[] = "i"; static char __pyx_k__j[] = "j"; static char __pyx_k__r[] = "r"; static char __pyx_k__w[] = "w"; -static char __pyx_k_100[] = "Sampling strategy: uniform, max sample size = %d"; -static char __pyx_k_101[] = "Sampling strategy: no sampling"; -static char __pyx_k_103[] = "require_aligned_terminal"; -static char __pyx_k_104[] = "require_aligned_chunks"; -static char __pyx_k_105[] = "[X]"; -static char __pyx_k_106[] = "Must specify an alignment object"; -static char __pyx_k_108[] = "Reading precomputed data from file %s... "; -static char __pyx_k_109[] = "Precomputation done with max nonterminals %d, decoder uses %d"; -static char __pyx_k_110[] = "Precomputation done with max terminals %d, decoder uses %d"; -static char __pyx_k_111[] = "Precomputation done with max initial size %d, decoder uses %d"; -static char __pyx_k_112[] = "Precomputation done with min gap size %d, decoder uses %d"; -static char __pyx_k_113[] = "Converting %d hash keys on precomputed inverted index... "; -static char __pyx_k_114[] = "Converting %d hash keys on precomputed collocations... "; -static char __pyx_k_115[] = "Processing precomputations took %f seconds"; -static char __pyx_k_116[] = "{"; - static char __pyx_k_117[] = "("; -static char __pyx_k_118[] = "}"; -static char __pyx_k_119[] = "get_precomputed_collocation"; -static char __pyx_k_120[] = "double binary"; -static char __pyx_k_121[] = "Keyword trie error"; -static char __pyx_k_123[] = "get_all_nodes_isteps_away"; -static char __pyx_k_124[] = "Total time for rule lookup, extraction, and scoring = %f seconds"; -static char __pyx_k_125[] = " Extract time = %f seconds"; -static char __pyx_k_126[] = "No aligned terminals"; -static char __pyx_k_127[] = "Unaligned chunk"; -static char __pyx_k_128[] = "Gaps are not tight phrases"; -static char __pyx_k_129[] = "Inside edges of preceding subphrase are not tight"; -static char __pyx_k_130[] = "Inside edges of following subphrase are not tight"; -static char __pyx_k_131[] = "Subphrase [%d, %d] failed integrity check"; -static char __pyx_k_132[] = "Didn't extract anything from [%d, %d] -> [%d, %d]"; -static char __pyx_k_133[] = "Unable to extract basic phrase"; -static char __pyx_k_136[] = "/Users/vchahun/Sandbox/cdec/python/src/sa/_sa.pyx"; -static char __pyx_k_137[] = "cdec.sa"; -static char __pyx_k_141[] = "/Users/vchahun/Sandbox/cdec/python/src/sa/sym.pxi"; -static char __pyx_k_142[] = "*EPS*"; +static char __pyx_k_102[] = "Sampling strategy: uniform, max sample size = %d"; +static char __pyx_k_103[] = "Sampling strategy: no sampling"; +static char __pyx_k_105[] = "require_aligned_terminal"; +static char __pyx_k_106[] = "require_aligned_chunks"; +static char __pyx_k_107[] = "[X]"; +static char __pyx_k_108[] = "Must specify an alignment object"; +static char __pyx_k_110[] = "Reading precomputed data from file %s... "; +static char __pyx_k_111[] = "Precomputation done with max nonterminals %d, decoder uses %d"; +static char __pyx_k_112[] = "Precomputation done with max terminals %d, decoder uses %d"; +static char __pyx_k_113[] = "Precomputation done with max initial size %d, decoder uses %d"; +static char __pyx_k_114[] = "Precomputation done with min gap size %d, decoder uses %d"; +static char __pyx_k_115[] = "Converting %d hash keys on precomputed inverted index... "; +static char __pyx_k_116[] = "Converting %d hash keys on precomputed collocations... "; +static char __pyx_k_117[] = "Processing precomputations took %f seconds"; +static char __pyx_k_118[] = "{"; + static char __pyx_k_119[] = "("; +static char __pyx_k_120[] = "}"; +static char __pyx_k_121[] = "get_precomputed_collocation"; +static char __pyx_k_122[] = "double binary"; +static char __pyx_k_123[] = "Keyword trie error"; +static char __pyx_k_125[] = "get_all_nodes_isteps_away"; +static char __pyx_k_126[] = "Total time for rule lookup, extraction, and scoring = %f seconds"; +static char __pyx_k_127[] = " Extract time = %f seconds"; +static char __pyx_k_128[] = "No aligned terminals"; +static char __pyx_k_129[] = "Unaligned chunk"; +static char __pyx_k_130[] = "Gaps are not tight phrases"; +static char __pyx_k_131[] = "Inside edges of preceding subphrase are not tight"; +static char __pyx_k_132[] = "Inside edges of following subphrase are not tight"; +static char __pyx_k_133[] = "Subphrase [%d, %d] failed integrity check"; +static char __pyx_k_134[] = "Didn't extract anything from [%d, %d] -> [%d, %d]"; +static char __pyx_k_135[] = "Unable to extract basic phrase"; +static char __pyx_k_138[] = "/Users/vchahun/Sandbox/cdec/python/src/sa/_sa.pyx"; +static char __pyx_k_139[] = "cdec.sa"; +static char __pyx_k_143[] = "/Users/vchahun/Sandbox/cdec/python/src/sa/sym.pxi"; +static char __pyx_k_144[] = "*EPS*"; static char __pyx_k__gc[] = "gc"; static char __pyx_k__sa[] = "sa"; static char __pyx_k___sa[] = "_sa"; @@ -2272,6 +2494,7 @@ static char __pyx_k__low[] = "low"; static char __pyx_k__map[] = "map"; static char __pyx_k__pad[] = "pad"; static char __pyx_k__res[] = "res"; +static char __pyx_k__set[] = "set"; static char __pyx_k__zip[] = "zip"; static char __pyx_k__NULL[] = "NULL"; static char __pyx_k__dist[] = "dist"; @@ -2279,6 +2502,7 @@ static char __pyx_k__gzip[] = "gzip"; static char __pyx_k__high[] = "high"; static char __pyx_k__info[] = "info"; static char __pyx_k__join[] = "join"; +static char __pyx_k__name[] = "name"; static char __pyx_k__open[] = "open"; static char __pyx_k__seek[] = "seek"; static char __pyx_k__side[] = "side"; @@ -2301,6 +2525,7 @@ static char __pyx_k__split[] = "split"; static char __pyx_k__start[] = "start"; static char __pyx_k__stats[] = "stats"; static char __pyx_k__toMap[] = "toMap"; +static char __pyx_k__value[] = "value"; static char __pyx_k__words[] = "words"; static char __pyx_k__write[] = "write"; static char __pyx_k__earray[] = "earray"; @@ -2310,18 +2535,21 @@ static char __pyx_k__get_id[] = "get_id"; static char __pyx_k__insert[] = "insert"; static char __pyx_k__logger[] = "logger"; static char __pyx_k__lookup[] = "lookup"; -static char __pyx_k__models[] = "models"; static char __pyx_k__offset[] = "offset"; static char __pyx_k__phrase[] = "phrase"; static char __pyx_k__q3sort[] = "q3sort"; static char __pyx_k__sa_low[] = "sa_low"; static char __pyx_k__sample[] = "sample"; static char __pyx_k__sarray[] = "sarray"; +static char __pyx_k__scorer[] = "scorer"; static char __pyx_k__scores[] = "scores"; static char __pyx_k__sorted[] = "sorted"; static char __pyx_k__source[] = "source"; static char __pyx_k__string[] = "string"; +static char __pyx_k__ttable[] = "ttable"; static char __pyx_k__unlink[] = "unlink"; +static char __pyx_k__CountEF[] = "CountEF"; +static char __pyx_k__Counter[] = "Counter"; static char __pyx_k__advance[] = "advance"; static char __pyx_k__arr_low[] = "arr_low"; static char __pyx_k__collect[] = "collect"; @@ -2334,8 +2562,10 @@ static char __pyx_k__sa_high[] = "sa_high"; static char __pyx_k__sampler[] = "sampler"; static char __pyx_k__spanlen[] = "spanlen"; static char __pyx_k__GzipFile[] = "GzipFile"; +static char __pyx_k__MAXSCORE[] = "MAXSCORE"; static char __pyx_k____exit__[] = "__exit__"; static char __pyx_k____main__[] = "__main__"; +static char __pyx_k____name__[] = "__name__"; static char __pyx_k____test__[] = "__test__"; static char __pyx_k___columns[] = "_columns"; static char __pyx_k__arr_high[] = "arr_high"; @@ -2356,6 +2586,8 @@ static char __pyx_k__ru_utime[] = "ru_utime"; static char __pyx_k__shortest[] = "shortest"; static char __pyx_k__terminal[] = "terminal"; static char __pyx_k__Exception[] = "Exception"; +static char __pyx_k__INCREMENT[] = "INCREMENT"; +static char __pyx_k__NFEATURES[] = "NFEATURES"; static char __pyx_k__TypeError[] = "TypeError"; static char __pyx_k____enter__[] = "__enter__"; static char __pyx_k__alignment[] = "alignment"; @@ -2364,6 +2596,7 @@ static char __pyx_k__from_data[] = "from_data"; static char __pyx_k__from_text[] = "from_text"; static char __pyx_k__getLogger[] = "getLogger"; static char __pyx_k__getSentId[] = "getSentId"; +static char __pyx_k__get_score[] = "get_score"; static char __pyx_k__getrusage[] = "getrusage"; static char __pyx_k__increment[] = "increment"; static char __pyx_k__iteritems[] = "iteritems"; @@ -2372,17 +2605,18 @@ static char __pyx_k__reachable[] = "reachable"; static char __pyx_k__read_text[] = "read_text"; static char __pyx_k__use_index[] = "use_index"; static char __pyx_k__IndexError[] = "IndexError"; -static char __pyx_k__ValueError[] = "ValueError"; +static char __pyx_k__alignments[] = "alignments"; static char __pyx_k__from_stats[] = "from_stats"; static char __pyx_k__getSentPos[] = "getSentPos"; static char __pyx_k__max_chunks[] = "max_chunks"; static char __pyx_k__max_length[] = "max_length"; static char __pyx_k__precompute[] = "precompute"; -static char __pyx_k__setdefault[] = "setdefault"; static char __pyx_k__write_text[] = "write_text"; static char __pyx_k__END_OF_FILE[] = "END_OF_FILE"; static char __pyx_k__END_OF_LINE[] = "END_OF_LINE"; static char __pyx_k__RUSAGE_SELF[] = "RUSAGE_SELF"; +static char __pyx_k__collections[] = "collections"; +static char __pyx_k__defaultdict[] = "defaultdict"; static char __pyx_k__from_binary[] = "from_binary"; static char __pyx_k__initial_len[] = "initial_len"; static char __pyx_k__next_states[] = "next_states"; @@ -2392,15 +2626,21 @@ static char __pyx_k__read_bitext[] = "read_bitext"; static char __pyx_k__sample_size[] = "sample_size"; static char __pyx_k__suffix_link[] = "suffix_link"; static char __pyx_k__use_sent_id[] = "use_sent_id"; +static char __pyx_k__IsSingletonF[] = "IsSingletonF"; +static char __pyx_k__SampleCountF[] = "SampleCountF"; static char __pyx_k___doquicksort[] = "_doquicksort"; static char __pyx_k__gzip_or_text[] = "gzip_or_text"; static char __pyx_k__min_gap_size[] = "min_gap_size"; +static char __pyx_k__IsSingletonFE[] = "IsSingletonFE"; +static char __pyx_k__MaxLexEgivenF[] = "MaxLexEgivenF"; +static char __pyx_k__MaxLexFgivenE[] = "MaxLexFgivenE"; static char __pyx_k__StopIteration[] = "StopIteration"; static char __pyx_k__alphabet_size[] = "alphabet_size"; static char __pyx_k__tight_phrases[] = "tight_phrases"; static char __pyx_k__pattern2phrase[] = "pattern2phrase"; static char __pyx_k__read_text_data[] = "read_text_data"; static char __pyx_k__sym_fromstring[] = "sym_fromstring"; +static char __pyx_k__EgivenFCoherent[] = "EgivenFCoherent"; static char __pyx_k__by_slack_factor[] = "by_slack_factor"; static char __pyx_k__get_next_states[] = "get_next_states"; static char __pyx_k__num_subpatterns[] = "num_subpatterns"; @@ -2409,6 +2649,7 @@ static char __pyx_k__precompute_file[] = "precompute_file"; static char __pyx_k__precompute_rank[] = "precompute_rank"; static char __pyx_k__use_baeza_yates[] = "use_baeza_yates"; static char __pyx_k__word_alignments[] = "word_alignments"; +static char __pyx_k__INITIAL_CAPACITY[] = "INITIAL_CAPACITY"; static char __pyx_k__max_initial_size[] = "max_initial_size"; static char __pyx_k__max_nonterminals[] = "max_nonterminals"; static char __pyx_k__reachable_buffer[] = "reachable_buffer"; @@ -2418,13 +2659,11 @@ static char __pyx_k__max_target_length[] = "max_target_length"; static char __pyx_k__train_min_gap_size[] = "train_min_gap_size"; static char __pyx_k__pattern2phrase_plus[] = "pattern2phrase_plus"; static PyObject *__pyx_kp_s_1; -static PyObject *__pyx_kp_s_100; -static PyObject *__pyx_kp_s_101; -static PyObject *__pyx_n_s_103; -static PyObject *__pyx_n_s_104; -static PyObject *__pyx_kp_s_106; +static PyObject *__pyx_kp_s_102; +static PyObject *__pyx_kp_s_103; +static PyObject *__pyx_n_s_105; +static PyObject *__pyx_n_s_106; static PyObject *__pyx_kp_s_108; -static PyObject *__pyx_kp_s_109; static PyObject *__pyx_kp_s_110; static PyObject *__pyx_kp_s_111; static PyObject *__pyx_kp_s_112; @@ -2434,12 +2673,12 @@ static PyObject *__pyx_kp_s_115; static PyObject *__pyx_kp_s_116; static PyObject *__pyx_kp_s_117; static PyObject *__pyx_kp_s_118; -static PyObject *__pyx_n_s_119; +static PyObject *__pyx_kp_s_119; static PyObject *__pyx_kp_s_120; -static PyObject *__pyx_kp_s_121; -static PyObject *__pyx_n_s_123; -static PyObject *__pyx_kp_s_124; -static PyObject *__pyx_kp_s_125; +static PyObject *__pyx_n_s_121; +static PyObject *__pyx_kp_s_122; +static PyObject *__pyx_kp_s_123; +static PyObject *__pyx_n_s_125; static PyObject *__pyx_kp_s_126; static PyObject *__pyx_kp_s_127; static PyObject *__pyx_kp_s_128; @@ -2449,11 +2688,13 @@ static PyObject *__pyx_kp_s_130; static PyObject *__pyx_kp_s_131; static PyObject *__pyx_kp_s_132; static PyObject *__pyx_kp_s_133; -static PyObject *__pyx_kp_s_136; -static PyObject *__pyx_kp_s_137; +static PyObject *__pyx_kp_s_134; +static PyObject *__pyx_kp_s_135; +static PyObject *__pyx_kp_s_138; +static PyObject *__pyx_kp_s_139; static PyObject *__pyx_kp_s_14; -static PyObject *__pyx_kp_s_141; -static PyObject *__pyx_kp_s_142; +static PyObject *__pyx_kp_s_143; +static PyObject *__pyx_kp_s_144; static PyObject *__pyx_kp_s_18; static PyObject *__pyx_kp_s_2; static PyObject *__pyx_kp_s_21; @@ -2503,27 +2744,41 @@ static PyObject *__pyx_kp_s_91; static PyObject *__pyx_kp_s_92; static PyObject *__pyx_kp_s_94; static PyObject *__pyx_kp_s_95; +static PyObject *__pyx_kp_s_99; static PyObject *__pyx_kp_s__0; static PyObject *__pyx_kp_s__1; +static PyObject *__pyx_n_s__CountEF; +static PyObject *__pyx_n_s__Counter; static PyObject *__pyx_n_s__END_OF_FILE; static PyObject *__pyx_n_s__END_OF_LINE; +static PyObject *__pyx_n_s__EgivenFCoherent; static PyObject *__pyx_n_s__Exception; static PyObject *__pyx_n_s__GzipFile; +static PyObject *__pyx_n_s__INCREMENT; +static PyObject *__pyx_n_s__INITIAL_CAPACITY; static PyObject *__pyx_n_s__IndexError; +static PyObject *__pyx_n_s__IsSingletonF; +static PyObject *__pyx_n_s__IsSingletonFE; +static PyObject *__pyx_n_s__MAXSCORE; +static PyObject *__pyx_n_s__MaxLexEgivenF; +static PyObject *__pyx_n_s__MaxLexFgivenE; +static PyObject *__pyx_n_s__NFEATURES; static PyObject *__pyx_n_s__NULL; static PyObject *__pyx_n_s__RUSAGE_SELF; +static PyObject *__pyx_n_s__SampleCountF; static PyObject *__pyx_n_s__StopIteration; static PyObject *__pyx_n_s__TypeError; -static PyObject *__pyx_n_s__ValueError; static PyObject *__pyx_n_s____enter__; static PyObject *__pyx_n_s____exit__; static PyObject *__pyx_n_s____main__; +static PyObject *__pyx_n_s____name__; static PyObject *__pyx_n_s____test__; static PyObject *__pyx_n_s___columns; static PyObject *__pyx_n_s___doquicksort; static PyObject *__pyx_n_s___sa; static PyObject *__pyx_n_s__advance; static PyObject *__pyx_n_s__alignment; +static PyObject *__pyx_n_s__alignments; static PyObject *__pyx_n_s__alphabet_size; static PyObject *__pyx_n_s__arity; static PyObject *__pyx_n_s__arr; @@ -2535,8 +2790,10 @@ static PyObject *__pyx_n_s__children; static PyObject *__pyx_n_s__cmp; static PyObject *__pyx_n_s__col; static PyObject *__pyx_n_s__collect; +static PyObject *__pyx_n_s__collections; static PyObject *__pyx_n_s__curr_idx; static PyObject *__pyx_n_s__debug; +static PyObject *__pyx_n_s__defaultdict; static PyObject *__pyx_n_s__dist; static PyObject *__pyx_n_s__e; static PyObject *__pyx_n_s__earray; @@ -2565,6 +2822,7 @@ static PyObject *__pyx_n_s__get_e_id; static PyObject *__pyx_n_s__get_f_id; static PyObject *__pyx_n_s__get_id; static PyObject *__pyx_n_s__get_next_states; +static PyObject *__pyx_n_s__get_score; static PyObject *__pyx_n_s__get_word; static PyObject *__pyx_n_s__getchunk; static PyObject *__pyx_n_s__getrusage; @@ -2599,7 +2857,7 @@ static PyObject *__pyx_n_s__max_target_length; static PyObject *__pyx_n_s__merge; static PyObject *__pyx_n_s__min_dist; static PyObject *__pyx_n_s__min_gap_size; -static PyObject *__pyx_n_s__models; +static PyObject *__pyx_n_s__name; static PyObject *__pyx_n_s__next_states; static PyObject *__pyx_n_s__num_subpatterns; static PyObject *__pyx_n_s__offset; @@ -2635,9 +2893,10 @@ static PyObject *__pyx_n_s__sample; static PyObject *__pyx_n_s__sample_size; static PyObject *__pyx_n_s__sampler; static PyObject *__pyx_n_s__sarray; +static PyObject *__pyx_n_s__scorer; static PyObject *__pyx_n_s__scores; static PyObject *__pyx_n_s__seek; -static PyObject *__pyx_n_s__setdefault; +static PyObject *__pyx_n_s__set; static PyObject *__pyx_n_s__shortest; static PyObject *__pyx_n_s__side; static PyObject *__pyx_n_s__size; @@ -2656,11 +2915,13 @@ static PyObject *__pyx_n_s__terminal; static PyObject *__pyx_n_s__tight_phrases; static PyObject *__pyx_n_s__toMap; static PyObject *__pyx_n_s__train_min_gap_size; +static PyObject *__pyx_n_s__ttable; static PyObject *__pyx_n_s__unlink; static PyObject *__pyx_n_s__use_baeza_yates; static PyObject *__pyx_n_s__use_collocations; static PyObject *__pyx_n_s__use_index; static PyObject *__pyx_n_s__use_sent_id; +static PyObject *__pyx_n_s__value; static PyObject *__pyx_n_s__w; static PyObject *__pyx_n_s__warn; static PyObject *__pyx_n_s__word; @@ -2672,14 +2933,19 @@ static PyObject *__pyx_n_s__zip; static PyObject *__pyx_int_0; static PyObject *__pyx_int_1; static PyObject *__pyx_int_2; +static PyObject *__pyx_int_3; +static PyObject *__pyx_int_4; static PyObject *__pyx_int_5; +static PyObject *__pyx_int_6; +static PyObject *__pyx_int_7; static PyObject *__pyx_int_neg_1; static PyObject *__pyx_int_10; static PyObject *__pyx_int_20; +static PyObject *__pyx_int_neg_99; static PyObject *__pyx_int_1000; static PyObject *__pyx_int_65536; static PyObject *__pyx_k_41; -static PyObject *__pyx_k_99; +static PyObject *__pyx_k_101; static PyObject *__pyx_k_tuple_10; static PyObject *__pyx_k_tuple_11; static PyObject *__pyx_k_tuple_12; @@ -2725,14 +2991,15 @@ static PyObject *__pyx_k_tuple_93; static PyObject *__pyx_k_tuple_96; static PyObject *__pyx_k_tuple_97; static PyObject *__pyx_k_tuple_98; -static PyObject *__pyx_k_tuple_102; -static PyObject *__pyx_k_tuple_107; -static PyObject *__pyx_k_tuple_122; -static PyObject *__pyx_k_tuple_134; -static PyObject *__pyx_k_tuple_138; -static PyObject *__pyx_k_tuple_139; -static PyObject *__pyx_k_codeobj_135; -static PyObject *__pyx_k_codeobj_140; +static PyObject *__pyx_k_tuple_100; +static PyObject *__pyx_k_tuple_104; +static PyObject *__pyx_k_tuple_109; +static PyObject *__pyx_k_tuple_124; +static PyObject *__pyx_k_tuple_136; +static PyObject *__pyx_k_tuple_140; +static PyObject *__pyx_k_tuple_141; +static PyObject *__pyx_k_codeobj_137; +static PyObject *__pyx_k_codeobj_142; /* "_sa.pyx":5 * import gzip @@ -3002,7 +3269,7 @@ static int __pyx_pw_3_sa_9FloatList_1__cinit__(PyObject *__pyx_v_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __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[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3014,24 +3281,24 @@ static int __pyx_pw_3_sa_9FloatList_1__cinit__(PyObject *__pyx_v_self, PyObject } } if (values[0]) { - __pyx_v_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_size = ((int)0); } if (values[1]) { - __pyx_v_increment = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_increment == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_increment = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_increment == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_increment = ((int)1); } if (values[2]) { - __pyx_v_initial_len = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_initial_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_initial_len = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_initial_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_initial_len = ((int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.FloatList.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3042,8 +3309,8 @@ static int __pyx_pw_3_sa_9FloatList_1__cinit__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":15 - * cdef float* arr +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":11 + * cdef class FloatList: * * def __cinit__(self, int size=0, int increment=1, int initial_len=0): # <<<<<<<<<<<<<< * if initial_len > size: @@ -3056,7 +3323,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ int __pyx_t_1; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":16 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":12 * * def __cinit__(self, int size=0, int increment=1, int initial_len=0): * if initial_len > size: # <<<<<<<<<<<<<< @@ -3066,7 +3333,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ __pyx_t_1 = (__pyx_v_initial_len > __pyx_v_size); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":17 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":13 * def __cinit__(self, int size=0, int increment=1, int initial_len=0): * if initial_len > size: * size = initial_len # <<<<<<<<<<<<<< @@ -3078,7 +3345,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":18 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":14 * if initial_len > size: * size = initial_len * self.size = size # <<<<<<<<<<<<<< @@ -3087,7 +3354,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ */ __pyx_v_self->size = __pyx_v_size; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":19 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":15 * size = initial_len * self.size = size * self.increment = increment # <<<<<<<<<<<<<< @@ -3096,7 +3363,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ */ __pyx_v_self->increment = __pyx_v_increment; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":20 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":16 * self.size = size * self.increment = increment * self.len = initial_len # <<<<<<<<<<<<<< @@ -3105,7 +3372,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ */ __pyx_v_self->len = __pyx_v_initial_len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":21 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":17 * self.increment = increment * self.len = initial_len * self.arr = malloc(size*sizeof(float)) # <<<<<<<<<<<<<< @@ -3114,7 +3381,7 @@ static int __pyx_pf_3_sa_9FloatList___cinit__(struct __pyx_obj_3_sa_FloatList *_ */ __pyx_v_self->arr = ((float *)malloc((__pyx_v_size * (sizeof(float))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":22 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":18 * self.len = initial_len * self.arr = malloc(size*sizeof(float)) * memset(self.arr, 0, initial_len*sizeof(float)) # <<<<<<<<<<<<<< @@ -3137,7 +3404,7 @@ static void __pyx_pw_3_sa_9FloatList_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":24 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":20 * memset(self.arr, 0, initial_len*sizeof(float)) * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3149,7 +3416,7 @@ static void __pyx_pf_3_sa_9FloatList_2__dealloc__(struct __pyx_obj_3_sa_FloatLis __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":25 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":21 * * def __dealloc__(self): * free(self.arr) # <<<<<<<<<<<<<< @@ -3172,7 +3439,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_5__getitem__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":27 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":23 * free(self.arr) * * def __getitem__(self, i): # <<<<<<<<<<<<<< @@ -3195,7 +3462,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":28 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":24 * * def __getitem__(self, i): * j = i # <<<<<<<<<<<<<< @@ -3205,29 +3472,29 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo __Pyx_INCREF(__pyx_v_i); __pyx_v_j = __pyx_v_i; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":29 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":25 * def __getitem__(self, i): * j = i * if i<0: # <<<<<<<<<<<<<< * j = self.len + i * if j<0 or j>=self.len: */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(__pyx_v_i, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":30 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":26 * j = i * if i<0: * j = self.len + i # <<<<<<<<<<<<<< * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_v_j); @@ -3237,24 +3504,24 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":31 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":27 * if i<0: * j = self.len + i * if j<0 or j>=self.len: # <<<<<<<<<<<<<< * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) * return self.arr[j] */ - __pyx_t_3 = PyObject_RichCompare(__pyx_v_j, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_j, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!__pyx_t_2) { - __pyx_t_3 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_j, __pyx_t_3, Py_GE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(__pyx_v_j, __pyx_t_3, Py_GE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_5 = __pyx_t_4; } else { @@ -3262,16 +3529,16 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo } if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":32 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":28 * j = self.len + i * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) # <<<<<<<<<<<<<< * return self.arr[j] * */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_i); @@ -3279,25 +3546,25 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __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_IndexError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":33 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":29 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) * return self.arr[j] # <<<<<<<<<<<<<< @@ -3305,8 +3572,8 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo * cdef void set(self, int i, float v): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_j); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->arr[__pyx_t_6])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_j); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->arr[__pyx_t_6])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3326,7 +3593,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_4__getitem__(struct __pyx_obj_3_sa_Flo return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":35 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":31 * return self.arr[j] * * cdef void set(self, int i, float v): # <<<<<<<<<<<<<< @@ -3348,7 +3615,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":36 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":32 * * cdef void set(self, int i, float v): * j = i # <<<<<<<<<<<<<< @@ -3357,7 +3624,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v */ __pyx_v_j = __pyx_v_i; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":37 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":33 * cdef void set(self, int i, float v): * j = i * if i<0: # <<<<<<<<<<<<<< @@ -3367,7 +3634,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v __pyx_t_1 = (__pyx_v_i < 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":38 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":34 * j = i * if i<0: * j = self.len + i # <<<<<<<<<<<<<< @@ -3379,7 +3646,7 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":39 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":35 * if i<0: * j = self.len + i * if j<0 or j>=self.len: # <<<<<<<<<<<<<< @@ -3395,18 +3662,18 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v } if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":40 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":36 * j = self.len + i * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) # <<<<<<<<<<<<<< * self.arr[j] = v * */ - __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); @@ -3414,25 +3681,25 @@ static void __pyx_f_3_sa_9FloatList_set(struct __pyx_obj_3_sa_FloatList *__pyx_v __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":41 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":37 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length FloatList" % (i, self.len)) * self.arr[j] = v # <<<<<<<<<<<<<< @@ -3462,7 +3729,7 @@ static int __pyx_pw_3_sa_9FloatList_7__setitem__(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":43 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":39 * self.arr[j] = v * * def __setitem__(self, i, val): # <<<<<<<<<<<<<< @@ -3480,15 +3747,15 @@ static int __pyx_pf_3_sa_9FloatList_6__setitem__(struct __pyx_obj_3_sa_FloatList int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":44 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":40 * * def __setitem__(self, i, val): * self.set(i, val) # <<<<<<<<<<<<<< * * def __len__(self): */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_PyFloat_AsFloat(__pyx_v_val); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->set(__pyx_v_self, __pyx_t_1, __pyx_t_2); __pyx_r = 0; @@ -3512,7 +3779,7 @@ static Py_ssize_t __pyx_pw_3_sa_9FloatList_9__len__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":46 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":42 * self.set(i, val) * * def __len__(self): # <<<<<<<<<<<<<< @@ -3525,7 +3792,7 @@ static Py_ssize_t __pyx_pf_3_sa_9FloatList_8__len__(struct __pyx_obj_3_sa_FloatL __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":47 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":43 * * def __len__(self): * return self.len # <<<<<<<<<<<<<< @@ -3549,7 +3816,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_11append(PyObject *__pyx_v_self, PyObj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("append (wrapper)", 0); assert(__pyx_arg_val); { - __pyx_v_val = __pyx_PyFloat_AsFloat(__pyx_arg_val); if (unlikely((__pyx_v_val == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_val = __pyx_PyFloat_AsFloat(__pyx_arg_val); if (unlikely((__pyx_v_val == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3562,7 +3829,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_11append(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":49 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":45 * return self.len * * def append(self, float val): # <<<<<<<<<<<<<< @@ -3576,7 +3843,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi int __pyx_t_1; __Pyx_RefNannySetupContext("append", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":50 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":46 * * def append(self, float val): * if self.len == self.size: # <<<<<<<<<<<<<< @@ -3586,7 +3853,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi __pyx_t_1 = (__pyx_v_self->len == __pyx_v_self->size); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":51 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":47 * def append(self, float val): * if self.len == self.size: * self.size = self.size + self.increment # <<<<<<<<<<<<<< @@ -3595,7 +3862,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi */ __pyx_v_self->size = (__pyx_v_self->size + __pyx_v_self->increment); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":52 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":48 * if self.len == self.size: * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(float)) # <<<<<<<<<<<<<< @@ -3607,7 +3874,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":53 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":49 * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(float)) * self.arr[self.len] = val # <<<<<<<<<<<<<< @@ -3616,7 +3883,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi */ (__pyx_v_self->arr[__pyx_v_self->len]) = __pyx_v_val; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":54 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":50 * self.arr = realloc(self.arr, self.size*sizeof(float)) * self.arr[self.len] = val * self.len = self.len + 1 # <<<<<<<<<<<<<< @@ -3631,7 +3898,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_10append(struct __pyx_obj_3_sa_FloatLi return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":56 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":52 * self.len = self.len + 1 * * cdef void write_handle(self, FILE* f): # <<<<<<<<<<<<<< @@ -3643,7 +3910,7 @@ static void __pyx_f_3_sa_9FloatList_write_handle(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":57 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":53 * * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(float), 1, f) # <<<<<<<<<<<<<< @@ -3652,7 +3919,7 @@ static void __pyx_f_3_sa_9FloatList_write_handle(struct __pyx_obj_3_sa_FloatList */ fwrite((&__pyx_v_self->len), (sizeof(float)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":58 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":54 * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(float), 1, f) * fwrite(self.arr, sizeof(float), self.len, f) # <<<<<<<<<<<<<< @@ -3672,7 +3939,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_13write(PyObject *__pyx_v_self, PyObje __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3685,7 +3952,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_13write(PyObject *__pyx_v_self, PyObje return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":60 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":56 * fwrite(self.arr, sizeof(float), self.len, f) * * def write(self, char* filename): # <<<<<<<<<<<<<< @@ -3699,7 +3966,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_12write(struct __pyx_obj_3_sa_FloatLis __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":62 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":58 * def write(self, char* filename): * cdef FILE* f * f = fopen(filename, "w") # <<<<<<<<<<<<<< @@ -3708,7 +3975,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_12write(struct __pyx_obj_3_sa_FloatLis */ __pyx_v_f = fopen(__pyx_v_filename, __pyx_k__w); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":63 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":59 * cdef FILE* f * f = fopen(filename, "w") * self.write_handle(f) # <<<<<<<<<<<<<< @@ -3717,7 +3984,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_12write(struct __pyx_obj_3_sa_FloatLis */ ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->write_handle(__pyx_v_self, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":64 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":60 * f = fopen(filename, "w") * self.write_handle(f) * fclose(f) # <<<<<<<<<<<<<< @@ -3732,7 +3999,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_12write(struct __pyx_obj_3_sa_FloatLis return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":66 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":62 * fclose(f) * * cdef void read_handle(self, FILE* f): # <<<<<<<<<<<<<< @@ -3744,7 +4011,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":67 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":63 * * cdef void read_handle(self, FILE* f): * free(self.arr) # <<<<<<<<<<<<<< @@ -3753,7 +4020,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList */ free(__pyx_v_self->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":68 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":64 * cdef void read_handle(self, FILE* f): * free(self.arr) * fread(&(self.len), sizeof(float), 1, f) # <<<<<<<<<<<<<< @@ -3762,7 +4029,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList */ fread((&__pyx_v_self->len), (sizeof(float)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":69 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":65 * free(self.arr) * fread(&(self.len), sizeof(float), 1, f) * self.arr = malloc(self.len * sizeof(float)) # <<<<<<<<<<<<<< @@ -3771,7 +4038,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList */ __pyx_v_self->arr = ((float *)malloc((__pyx_v_self->len * (sizeof(float))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":70 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":66 * fread(&(self.len), sizeof(float), 1, f) * self.arr = malloc(self.len * sizeof(float)) * self.size = self.len # <<<<<<<<<<<<<< @@ -3780,7 +4047,7 @@ static void __pyx_f_3_sa_9FloatList_read_handle(struct __pyx_obj_3_sa_FloatList */ __pyx_v_self->size = __pyx_v_self->len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":71 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":67 * self.arr = malloc(self.len * sizeof(float)) * self.size = self.len * fread(self.arr, sizeof(float), self.len, f) # <<<<<<<<<<<<<< @@ -3800,7 +4067,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_15read(PyObject *__pyx_v_self, PyObjec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3813,7 +4080,7 @@ static PyObject *__pyx_pw_3_sa_9FloatList_15read(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":73 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":69 * fread(self.arr, sizeof(float), self.len, f) * * def read(self, char* filename): # <<<<<<<<<<<<<< @@ -3827,7 +4094,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_14read(struct __pyx_obj_3_sa_FloatList __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":75 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":71 * def read(self, char* filename): * cdef FILE* f * f = fopen(filename, "r") # <<<<<<<<<<<<<< @@ -3836,7 +4103,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_14read(struct __pyx_obj_3_sa_FloatList */ __pyx_v_f = fopen(__pyx_v_filename, __pyx_k__r); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":76 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":72 * cdef FILE* f * f = fopen(filename, "r") * self.read_handle(f) # <<<<<<<<<<<<<< @@ -3844,7 +4111,7 @@ static PyObject *__pyx_pf_3_sa_9FloatList_14read(struct __pyx_obj_3_sa_FloatList */ ((struct __pyx_vtabstruct_3_sa_FloatList *)__pyx_v_self->__pyx_vtab)->read_handle(__pyx_v_self, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":77 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/float_list.pxi":73 * f = fopen(filename, "r") * self.read_handle(f) * fclose(f) # <<<<<<<<<<<<<< @@ -3898,7 +4165,7 @@ static int __pyx_pw_3_sa_7IntList_1__cinit__(PyObject *__pyx_v_self, PyObject *_ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -3910,24 +4177,24 @@ static int __pyx_pw_3_sa_7IntList_1__cinit__(PyObject *__pyx_v_self, PyObject *_ } } if (values[0]) { - __pyx_v_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_size = ((int)0); } if (values[1]) { - __pyx_v_increment = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_increment == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_increment = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_increment == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_increment = ((int)1); } if (values[2]) { - __pyx_v_initial_len = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_initial_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_initial_len = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_initial_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { __pyx_v_initial_len = ((int)0); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.IntList.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -3938,8 +4205,8 @@ static int __pyx_pw_3_sa_7IntList_1__cinit__(PyObject *__pyx_v_self, PyObject *_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":15 - * cdef int* arr +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":11 + * cdef class IntList: * * def __cinit__(self, int size=0, int increment=1, int initial_len=0): # <<<<<<<<<<<<<< * if initial_len > size: @@ -3952,7 +4219,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx int __pyx_t_1; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":16 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":12 * * def __cinit__(self, int size=0, int increment=1, int initial_len=0): * if initial_len > size: # <<<<<<<<<<<<<< @@ -3962,7 +4229,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx __pyx_t_1 = (__pyx_v_initial_len > __pyx_v_size); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":17 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":13 * def __cinit__(self, int size=0, int increment=1, int initial_len=0): * if initial_len > size: * size = initial_len # <<<<<<<<<<<<<< @@ -3974,7 +4241,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":18 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":14 * if initial_len > size: * size = initial_len * self.size = size # <<<<<<<<<<<<<< @@ -3983,7 +4250,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx */ __pyx_v_self->size = __pyx_v_size; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":19 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":15 * size = initial_len * self.size = size * self.increment = increment # <<<<<<<<<<<<<< @@ -3992,7 +4259,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx */ __pyx_v_self->increment = __pyx_v_increment; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":20 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":16 * self.size = size * self.increment = increment * self.len = initial_len # <<<<<<<<<<<<<< @@ -4001,7 +4268,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx */ __pyx_v_self->len = __pyx_v_initial_len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":21 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":17 * self.increment = increment * self.len = initial_len * self.arr = malloc(size*sizeof(int)) # <<<<<<<<<<<<<< @@ -4010,7 +4277,7 @@ static int __pyx_pf_3_sa_7IntList___cinit__(struct __pyx_obj_3_sa_IntList *__pyx */ __pyx_v_self->arr = ((int *)malloc((__pyx_v_size * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":22 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":18 * self.len = initial_len * self.arr = malloc(size*sizeof(int)) * memset(self.arr, 0, initial_len*sizeof(int)) # <<<<<<<<<<<<<< @@ -4035,7 +4302,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_3__str__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":24 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":20 * memset(self.arr, 0, initial_len*sizeof(int)) * * def __str__(self): # <<<<<<<<<<<<<< @@ -4058,7 +4325,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_2__str__(struct __pyx_obj_3_sa_IntList * int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":26 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":22 * def __str__(self): * cdef unsigned i * ret = "IntList[" # <<<<<<<<<<<<<< @@ -4068,7 +4335,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_2__str__(struct __pyx_obj_3_sa_IntList * __Pyx_INCREF(((PyObject *)__pyx_kp_s_3)); __pyx_v_ret = ((PyObject *)__pyx_kp_s_3); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":27 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":23 * cdef unsigned i * ret = "IntList[" * for idx in range(self.size): # <<<<<<<<<<<<<< @@ -4079,7 +4346,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_2__str__(struct __pyx_obj_3_sa_IntList * for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_idx = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":28 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":24 * ret = "IntList[" * for idx in range(self.size): * if idx>0: # <<<<<<<<<<<<<< @@ -4089,14 +4356,14 @@ static PyObject *__pyx_pf_3_sa_7IntList_2__str__(struct __pyx_obj_3_sa_IntList * __pyx_t_3 = (__pyx_v_idx > 0); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":29 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":25 * for idx in range(self.size): * if idx>0: * ret += "," # <<<<<<<<<<<<<< * ret += str(self.arr[idx]) * ret += "]" */ - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_ret, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_ret, ((PyObject *)__pyx_kp_s_4)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_v_ret); __pyx_v_ret = __pyx_t_4; @@ -4105,24 +4372,24 @@ static PyObject *__pyx_pf_3_sa_7IntList_2__str__(struct __pyx_obj_3_sa_IntList * } __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":30 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":26 * if idx>0: * ret += "," * ret += str(self.arr[idx]) # <<<<<<<<<<<<<< * ret += "]" * ret += "len=" */ - __pyx_t_4 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_idx])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_idx])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_ret, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_ret, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_v_ret); @@ -4130,49 +4397,49 @@ static PyObject *__pyx_pf_3_sa_7IntList_2__str__(struct __pyx_obj_3_sa_IntList * __pyx_t_5 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":31 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":27 * ret += "," * ret += str(self.arr[idx]) * ret += "]" # <<<<<<<<<<<<<< * ret += "len=" * ret += self.len */ - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_ret, ((PyObject *)__pyx_kp_s_5)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_ret, ((PyObject *)__pyx_kp_s_5)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_v_ret); __pyx_v_ret = __pyx_t_5; __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":32 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":28 * ret += str(self.arr[idx]) * ret += "]" * ret += "len=" # <<<<<<<<<<<<<< * ret += self.len * return ret */ - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_ret, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_ret, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_v_ret); __pyx_v_ret = __pyx_t_5; __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":33 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":29 * ret += "]" * ret += "len=" * ret += self.len # <<<<<<<<<<<<<< * return ret * */ - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_ret, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_ret, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_v_ret); __pyx_v_ret = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":34 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":30 * ret += "len=" * ret += self.len * return ret # <<<<<<<<<<<<<< @@ -4209,7 +4476,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_5index(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":36 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":32 * return ret * * def index(self, val): # <<<<<<<<<<<<<< @@ -4231,7 +4498,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_4index(struct __pyx_obj_3_sa_IntList *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("index", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":38 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":34 * def index(self, val): * cdef unsigned i * for i in range(self.len): # <<<<<<<<<<<<<< @@ -4242,23 +4509,23 @@ static PyObject *__pyx_pf_3_sa_7IntList_4index(struct __pyx_obj_3_sa_IntList *__ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":39 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":35 * cdef unsigned i * for i in range(self.len): * if self.arr[i] == val: # <<<<<<<<<<<<<< * return i * return IndexError */ - __pyx_t_3 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_val, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_v_val, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":40 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":36 * for i in range(self.len): * if self.arr[i] == val: * return i # <<<<<<<<<<<<<< @@ -4266,7 +4533,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_4index(struct __pyx_obj_3_sa_IntList *__ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; @@ -4276,7 +4543,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_4index(struct __pyx_obj_3_sa_IntList *__ __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":41 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":37 * if self.arr[i] == val: * return i * return IndexError # <<<<<<<<<<<<<< @@ -4329,11 +4596,11 @@ static PyObject *__pyx_pw_3_sa_7IntList_7partition(PyObject *__pyx_v_self, PyObj case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("partition", 1, 2, 2, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("partition", 1, 2, 2, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "partition") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "partition") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4346,7 +4613,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_7partition(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("partition", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("partition", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.IntList.partition", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4357,7 +4624,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_7partition(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":43 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":39 * return IndexError * * def partition(self,start,end): # <<<<<<<<<<<<<< @@ -4383,32 +4650,32 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList int __pyx_clineno = 0; __Pyx_RefNannySetupContext("partition", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":44 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":40 * * def partition(self,start,end): * pivot = self.arr[end] # <<<<<<<<<<<<<< * bottom = start-1 * top = end */ - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_end); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyInt_FromLong((__pyx_v_self->arr[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_end); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->arr[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_pivot = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":45 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":41 * def partition(self,start,end): * pivot = self.arr[end] * bottom = start-1 # <<<<<<<<<<<<<< * top = end * done = 0 */ - __pyx_t_2 = PyNumber_Subtract(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Subtract(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_bottom = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":46 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":42 * pivot = self.arr[end] * bottom = start-1 * top = end # <<<<<<<<<<<<<< @@ -4418,7 +4685,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList __Pyx_INCREF(__pyx_v_end); __pyx_v_top = __pyx_v_end; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":47 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":43 * bottom = start-1 * top = end * done = 0 # <<<<<<<<<<<<<< @@ -4427,7 +4694,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList */ __pyx_v_done = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":48 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":44 * top = end * done = 0 * while not done: # <<<<<<<<<<<<<< @@ -4438,7 +4705,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList __pyx_t_3 = (!__pyx_v_done); if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":49 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":45 * done = 0 * while not done: * while not done: # <<<<<<<<<<<<<< @@ -4449,33 +4716,33 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList __pyx_t_3 = (!__pyx_v_done); if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":50 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":46 * while not done: * while not done: * bottom += 1 # <<<<<<<<<<<<<< * if bottom == top: * done = 1 */ - __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_bottom, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_bottom, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_v_bottom); __pyx_v_bottom = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":51 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":47 * while not done: * bottom += 1 * if bottom == top: # <<<<<<<<<<<<<< * done = 1 * break */ - __pyx_t_2 = PyObject_RichCompare(__pyx_v_bottom, __pyx_v_top, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_v_bottom, __pyx_v_top, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":52 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":48 * bottom += 1 * if bottom == top: * done = 1 # <<<<<<<<<<<<<< @@ -4484,7 +4751,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList */ __pyx_v_done = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":53 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":49 * if bottom == top: * done = 1 * break # <<<<<<<<<<<<<< @@ -4496,35 +4763,35 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":54 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":50 * done = 1 * break * if self.arr[bottom] > pivot: # <<<<<<<<<<<<<< * self.arr[top] = self.arr[bottom] * break */ - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bottom); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyInt_FromLong((__pyx_v_self->arr[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bottom); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->arr[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_v_pivot, Py_GT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_v_pivot, Py_GT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":55 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":51 * break * if self.arr[bottom] > pivot: * self.arr[top] = self.arr[bottom] # <<<<<<<<<<<<<< * break * while not done: */ - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bottom); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bottom); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} (__pyx_v_self->arr[__pyx_t_5]) = (__pyx_v_self->arr[__pyx_t_1]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":56 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":52 * if self.arr[bottom] > pivot: * self.arr[top] = self.arr[bottom] * break # <<<<<<<<<<<<<< @@ -4538,7 +4805,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList } __pyx_L6_break:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":57 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":53 * self.arr[top] = self.arr[bottom] * break * while not done: # <<<<<<<<<<<<<< @@ -4549,33 +4816,33 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList __pyx_t_3 = (!__pyx_v_done); if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":58 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":54 * break * while not done: * top -= 1 # <<<<<<<<<<<<<< * if top == bottom: * done = 1 */ - __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_v_top, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_InPlaceSubtract(__pyx_v_top, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_v_top); __pyx_v_top = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":59 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":55 * while not done: * top -= 1 * if top == bottom: # <<<<<<<<<<<<<< * done = 1 * break */ - __pyx_t_4 = PyObject_RichCompare(__pyx_v_top, __pyx_v_bottom, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_RichCompare(__pyx_v_top, __pyx_v_bottom, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":60 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":56 * top -= 1 * if top == bottom: * done = 1 # <<<<<<<<<<<<<< @@ -4584,7 +4851,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList */ __pyx_v_done = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":61 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":57 * if top == bottom: * done = 1 * break # <<<<<<<<<<<<<< @@ -4596,35 +4863,35 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList } __pyx_L11:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":62 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":58 * done = 1 * break * if self.arr[top] < pivot: # <<<<<<<<<<<<<< * self.arr[bottom] = self.arr[top] * break */ - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromLong((__pyx_v_self->arr[__pyx_t_1])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong((__pyx_v_self->arr[__pyx_t_1])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_v_pivot, Py_LT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_v_pivot, Py_LT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":63 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":59 * break * if self.arr[top] < pivot: * self.arr[bottom] = self.arr[top] # <<<<<<<<<<<<<< * break * self.arr[top] = pivot */ - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bottom); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bottom); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} (__pyx_v_self->arr[__pyx_t_5]) = (__pyx_v_self->arr[__pyx_t_1]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":64 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":60 * if self.arr[top] < pivot: * self.arr[bottom] = self.arr[top] * break # <<<<<<<<<<<<<< @@ -4639,18 +4906,18 @@ static PyObject *__pyx_pf_3_sa_7IntList_6partition(struct __pyx_obj_3_sa_IntList __pyx_L10_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":65 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":61 * self.arr[bottom] = self.arr[top] * break * self.arr[top] = pivot # <<<<<<<<<<<<<< * return top * */ - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_pivot); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_pivot); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_top); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} (__pyx_v_self->arr[__pyx_t_1]) = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":66 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":62 * break * self.arr[top] = pivot * return top # <<<<<<<<<<<<<< @@ -4706,11 +4973,11 @@ static PyObject *__pyx_pw_3_sa_7IntList_9_doquicksort(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("_doquicksort", 1, 2, 2, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_doquicksort", 1, 2, 2, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_doquicksort") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_doquicksort") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -4723,7 +4990,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_9_doquicksort(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("_doquicksort", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("_doquicksort", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.IntList._doquicksort", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -4734,7 +5001,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_9_doquicksort(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":68 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":64 * return top * * def _doquicksort(self,start,end): # <<<<<<<<<<<<<< @@ -4755,29 +5022,29 @@ static PyObject *__pyx_pf_3_sa_7IntList_8_doquicksort(struct __pyx_obj_3_sa_IntL int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_doquicksort", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":69 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":65 * * def _doquicksort(self,start,end): * if start < end: # <<<<<<<<<<<<<< * split = self.partition(start,end) * self._doquicksort(start,split-1) */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __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[2]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":70 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":66 * def _doquicksort(self,start,end): * if start < end: * split = self.partition(start,end) # <<<<<<<<<<<<<< * self._doquicksort(start,split-1) * self._doquicksort(split+1,end) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__partition); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__partition); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_start); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_start); @@ -4785,25 +5052,25 @@ static PyObject *__pyx_pf_3_sa_7IntList_8_doquicksort(struct __pyx_obj_3_sa_IntL __Pyx_INCREF(__pyx_v_end); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_end); __Pyx_GIVEREF(__pyx_v_end); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_split = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":71 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":67 * if start < end: * split = self.partition(start,end) * self._doquicksort(start,split-1) # <<<<<<<<<<<<<< * self._doquicksort(split+1,end) * else: */ - __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___doquicksort); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___doquicksort); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyNumber_Subtract(__pyx_v_split, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Subtract(__pyx_v_split, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_start); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_start); @@ -4811,24 +5078,24 @@ static PyObject *__pyx_pf_3_sa_7IntList_8_doquicksort(struct __pyx_obj_3_sa_IntL PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":72 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":68 * split = self.partition(start,end) * self._doquicksort(start,split-1) * self._doquicksort(split+1,end) # <<<<<<<<<<<<<< * else: * return */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___doquicksort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___doquicksort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyNumber_Add(__pyx_v_split, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Add(__pyx_v_split, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -4836,7 +5103,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_8_doquicksort(struct __pyx_obj_3_sa_IntL PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_end); __Pyx_GIVEREF(__pyx_v_end); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -4845,7 +5112,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_8_doquicksort(struct __pyx_obj_3_sa_IntL } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":74 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":70 * self._doquicksort(split+1,end) * else: * return # <<<<<<<<<<<<<< @@ -4884,7 +5151,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_11sort(PyObject *__pyx_v_self, CYTHON_UN return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":76 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":72 * return * * def sort(self): # <<<<<<<<<<<<<< @@ -4903,18 +5170,18 @@ static PyObject *__pyx_pf_3_sa_7IntList_10sort(struct __pyx_obj_3_sa_IntList *__ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("sort", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":77 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":73 * * def sort(self): * self._doquicksort(0,self.len-1) # <<<<<<<<<<<<<< * * def reset(self): */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___doquicksort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___doquicksort); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong((__pyx_v_self->len - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->len - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_int_0); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_0); @@ -4922,7 +5189,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_10sort(struct __pyx_obj_3_sa_IntList *__ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __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; @@ -4953,7 +5220,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_13reset(PyObject *__pyx_v_self, CYTHON_U return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":79 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":75 * self._doquicksort(0,self.len-1) * * def reset(self): # <<<<<<<<<<<<<< @@ -4966,7 +5233,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_12reset(struct __pyx_obj_3_sa_IntList *_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reset", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":80 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":76 * * def reset(self): * self.len = 0 # <<<<<<<<<<<<<< @@ -4990,7 +5257,7 @@ static void __pyx_pw_3_sa_7IntList_15__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":82 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":78 * self.len = 0 * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -5002,38 +5269,160 @@ static void __pyx_pf_3_sa_7IntList_14__dealloc__(struct __pyx_obj_3_sa_IntList * __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":83 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":79 * * def __dealloc__(self): * free(self.arr) # <<<<<<<<<<<<<< * - * def __getitem__(self, index): + * def __iter__(self): */ free(__pyx_v_self->arr); __Pyx_RefNannyFinishContext(); } +static PyObject *__pyx_gb_3_sa_7IntList_18generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7IntList_17__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ -static PyObject *__pyx_pw_3_sa_7IntList_17__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { +static PyObject *__pyx_pw_3_sa_7IntList_17__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_17__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_7IntList_16__getitem__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((PyObject *)__pyx_v_index)); + __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_7IntList_16__iter__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":85 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":81 * free(self.arr) * + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef int i + * for i in range(self.len): + */ + +static PyObject *__pyx_pf_3_sa_7IntList_16__iter__(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { + struct __pyx_obj_3_sa___pyx_scope_struct____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_3_sa___pyx_scope_struct____iter__ *)__pyx_ptype_3_sa___pyx_scope_struct____iter__->tp_new(__pyx_ptype_3_sa___pyx_scope_struct____iter__, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_7IntList_18generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __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("_sa.IntList.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static PyObject *__pyx_gb_3_sa_7IntList_18generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + int __pyx_t_1; + int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":83 + * def __iter__(self): + * cdef int i + * for i in range(self.len): # <<<<<<<<<<<<<< + * yield self.arr[i] + * + */ + __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->len; + 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/sa/int_list.pxi":84 + * cdef int i + * for i in range(self.len): + * yield self.arr[i] # <<<<<<<<<<<<<< + * + * def __getitem__(self, index): + */ + __pyx_t_3 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_self->arr[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_r = __pyx_t_3; + __pyx_t_3 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return NULL; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_7IntList_20__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_20__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_index) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_7IntList_19__getitem__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((PyObject *)__pyx_v_index)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":86 + * yield self.arr[i] + * * def __getitem__(self, index): # <<<<<<<<<<<<<< * cdef int i, j, k * if isinstance(index, int): */ -static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_index) { +static PyObject *__pyx_pf_3_sa_7IntList_19__getitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_index) { int __pyx_v_i; int __pyx_v_j; int __pyx_v_k; @@ -5055,7 +5444,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":87 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":88 * def __getitem__(self, index): * cdef int i, j, k * if isinstance(index, int): # <<<<<<<<<<<<<< @@ -5068,17 +5457,17 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":88 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":89 * cdef int i, j, k * if isinstance(index, int): * j = index # <<<<<<<<<<<<<< * if j < 0: * j = self.len + j */ - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_index); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_j = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":89 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":90 * if isinstance(index, int): * j = index * if j < 0: # <<<<<<<<<<<<<< @@ -5088,7 +5477,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_2 = (__pyx_v_j < 0); if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":90 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":91 * j = index * if j < 0: * j = self.len + j # <<<<<<<<<<<<<< @@ -5100,7 +5489,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":91 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":92 * if j < 0: * j = self.len + j * if j<0 or j>=self.len: # <<<<<<<<<<<<<< @@ -5116,16 +5505,16 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL } if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":92 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":93 * j = self.len + j * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (index, self.len)) # <<<<<<<<<<<<<< * return self.arr[j] * elif isinstance(index, slice): */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_v_index); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_index); @@ -5133,25 +5522,25 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":93 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":94 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (index, self.len)) * return self.arr[j] # <<<<<<<<<<<<<< @@ -5159,7 +5548,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL * i = index.start */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_j])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_j])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5167,7 +5556,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":94 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":95 * raise IndexError("Requested index %d of %d-length IntList" % (index, self.len)) * return self.arr[j] * elif isinstance(index, slice): # <<<<<<<<<<<<<< @@ -5180,33 +5569,33 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":95 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":96 * return self.arr[j] * elif isinstance(index, slice): * i = index.start # <<<<<<<<<<<<<< * j = index.stop * if i < 0: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":96 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":97 * elif isinstance(index, slice): * i = index.start * j = index.stop # <<<<<<<<<<<<<< * if i < 0: * i = self.len + i */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_j = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":97 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":98 * i = index.start * j = index.stop * if i < 0: # <<<<<<<<<<<<<< @@ -5216,7 +5605,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_5 = (__pyx_v_i < 0); if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":98 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":99 * j = index.stop * if i < 0: * i = self.len + i # <<<<<<<<<<<<<< @@ -5228,7 +5617,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL } __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":99 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":100 * if i < 0: * i = self.len + i * if j < 0: # <<<<<<<<<<<<<< @@ -5238,7 +5627,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_5 = (__pyx_v_j < 0); if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":100 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":101 * i = self.len + i * if j < 0: * j = self.len + j # <<<<<<<<<<<<<< @@ -5250,7 +5639,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":101 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":102 * if j < 0: * j = self.len + j * if i < 0 or i >= self.len or j < 0 or j > self.len: # <<<<<<<<<<<<<< @@ -5278,20 +5667,20 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL } if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":102 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":103 * j = self.len + j * if i < 0 or i >= self.len or j < 0 or j > self.len: * raise IndexError("Requested index %d:%d of %d-length IntList" % (index.start, index.stop, self.len)) # <<<<<<<<<<<<<< * result = () * for k from i <= k < j: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_index, __pyx_n_s__stop); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_9 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -5302,25 +5691,25 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_1 = 0; __pyx_t_6 = 0; __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9)); __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L8; } __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":103 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":104 * if i < 0 or i >= self.len or j < 0 or j > self.len: * raise IndexError("Requested index %d:%d of %d-length IntList" % (index.start, index.stop, self.len)) * result = () # <<<<<<<<<<<<<< @@ -5330,7 +5719,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); __pyx_v_result = __pyx_empty_tuple; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":104 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":105 * raise IndexError("Requested index %d:%d of %d-length IntList" % (index.start, index.stop, self.len)) * result = () * for k from i <= k < j: # <<<<<<<<<<<<<< @@ -5340,21 +5729,21 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_3 = __pyx_v_j; for (__pyx_v_k = __pyx_v_i; __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":105 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":106 * result = () * for k from i <= k < j: * result = result + (self.arr[k],) # <<<<<<<<<<<<<< * return result * else: */ - __pyx_t_9 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_k])); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromLong((__pyx_v_self->arr[__pyx_v_k])); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __Pyx_GIVEREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_result)); @@ -5362,7 +5751,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL __pyx_t_9 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":106 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":107 * for k from i <= k < j: * result = result + (self.arr[k],) * return result # <<<<<<<<<<<<<< @@ -5377,26 +5766,26 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":108 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":109 * return result * else: * raise TypeError("Illegal key type %s for IntList" % type(index)) # <<<<<<<<<<<<<< * * cdef void set(self, int i, int val): */ - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)Py_TYPE(__pyx_v_index))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)Py_TYPE(__pyx_v_index))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9)); __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_9, 0, 0, 0); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -5416,7 +5805,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_16__getitem__(struct __pyx_obj_3_sa_IntL return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":110 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":111 * raise TypeError("Illegal key type %s for IntList" % type(index)) * * cdef void set(self, int i, int val): # <<<<<<<<<<<<<< @@ -5438,7 +5827,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":111 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":112 * * cdef void set(self, int i, int val): * j = i # <<<<<<<<<<<<<< @@ -5447,7 +5836,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel */ __pyx_v_j = __pyx_v_i; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":112 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":113 * cdef void set(self, int i, int val): * j = i * if i<0: # <<<<<<<<<<<<<< @@ -5457,7 +5846,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel __pyx_t_1 = (__pyx_v_i < 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":113 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":114 * j = i * if i<0: * j = self.len + i # <<<<<<<<<<<<<< @@ -5469,7 +5858,7 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":114 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":115 * if i<0: * j = self.len + i * if j<0 or j>=self.len: # <<<<<<<<<<<<<< @@ -5485,18 +5874,18 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel } if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":115 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":116 * j = self.len + i * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (i, self.len)) # <<<<<<<<<<<<<< * self.arr[j] = val * */ - __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); @@ -5504,25 +5893,25 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel __Pyx_GIVEREF(__pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":116 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":117 * if j<0 or j>=self.len: * raise IndexError("Requested index %d of %d-length IntList" % (i, self.len)) * self.arr[j] = val # <<<<<<<<<<<<<< @@ -5542,17 +5931,17 @@ static void __pyx_f_3_sa_7IntList_set(struct __pyx_obj_3_sa_IntList *__pyx_v_sel } /* Python wrapper */ -static int __pyx_pw_3_sa_7IntList_19__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val); /*proto*/ -static int __pyx_pw_3_sa_7IntList_19__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val) { +static int __pyx_pw_3_sa_7IntList_22__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val); /*proto*/ +static int __pyx_pw_3_sa_7IntList_22__setitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_7IntList_18__setitem__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((PyObject *)__pyx_v_i), ((PyObject *)__pyx_v_val)); + __pyx_r = __pyx_pf_3_sa_7IntList_21__setitem__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((PyObject *)__pyx_v_i), ((PyObject *)__pyx_v_val)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":118 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":119 * self.arr[j] = val * * def __setitem__(self, i, val): # <<<<<<<<<<<<<< @@ -5560,7 +5949,7 @@ static int __pyx_pw_3_sa_7IntList_19__setitem__(PyObject *__pyx_v_self, PyObject * */ -static int __pyx_pf_3_sa_7IntList_18__setitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val) { +static int __pyx_pf_3_sa_7IntList_21__setitem__(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_i, PyObject *__pyx_v_val) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -5570,15 +5959,15 @@ static int __pyx_pf_3_sa_7IntList_18__setitem__(struct __pyx_obj_3_sa_IntList *_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":119 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":120 * * def __setitem__(self, i, val): * self.set(i, val) # <<<<<<<<<<<<<< * * def __len__(self): */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_val); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_i); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_val); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->set(__pyx_v_self, __pyx_t_1, __pyx_t_2); __pyx_r = 0; @@ -5592,17 +5981,17 @@ static int __pyx_pf_3_sa_7IntList_18__setitem__(struct __pyx_obj_3_sa_IntList *_ } /* Python wrapper */ -static Py_ssize_t __pyx_pw_3_sa_7IntList_21__len__(PyObject *__pyx_v_self); /*proto*/ -static Py_ssize_t __pyx_pw_3_sa_7IntList_21__len__(PyObject *__pyx_v_self) { +static Py_ssize_t __pyx_pw_3_sa_7IntList_24__len__(PyObject *__pyx_v_self); /*proto*/ +static Py_ssize_t __pyx_pw_3_sa_7IntList_24__len__(PyObject *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_7IntList_20__len__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self)); + __pyx_r = __pyx_pf_3_sa_7IntList_23__len__(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":121 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":122 * self.set(i, val) * * def __len__(self): # <<<<<<<<<<<<<< @@ -5610,12 +5999,12 @@ static Py_ssize_t __pyx_pw_3_sa_7IntList_21__len__(PyObject *__pyx_v_self) { * */ -static Py_ssize_t __pyx_pf_3_sa_7IntList_20__len__(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { +static Py_ssize_t __pyx_pf_3_sa_7IntList_23__len__(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":122 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":123 * * def __len__(self): * return self.len # <<<<<<<<<<<<<< @@ -5632,17 +6021,17 @@ static Py_ssize_t __pyx_pf_3_sa_7IntList_20__len__(struct __pyx_obj_3_sa_IntList } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7IntList_23getSize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_3_sa_7IntList_23getSize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_3_sa_7IntList_26getSize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_26getSize(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("getSize (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_7IntList_22getSize(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self)); + __pyx_r = __pyx_pf_3_sa_7IntList_25getSize(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":124 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":125 * return self.len * * def getSize(self): # <<<<<<<<<<<<<< @@ -5650,7 +6039,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_23getSize(PyObject *__pyx_v_self, CYTHON * */ -static PyObject *__pyx_pf_3_sa_7IntList_22getSize(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { +static PyObject *__pyx_pf_3_sa_7IntList_25getSize(struct __pyx_obj_3_sa_IntList *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -5659,7 +6048,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_22getSize(struct __pyx_obj_3_sa_IntList int __pyx_clineno = 0; __Pyx_RefNannySetupContext("getSize", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":125 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":126 * * def getSize(self): * return self.size # <<<<<<<<<<<<<< @@ -5667,7 +6056,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_22getSize(struct __pyx_obj_3_sa_IntList * def append(self, int val): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5686,14 +6075,14 @@ static PyObject *__pyx_pf_3_sa_7IntList_22getSize(struct __pyx_obj_3_sa_IntList } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7IntList_25append(PyObject *__pyx_v_self, PyObject *__pyx_arg_val); /*proto*/ -static PyObject *__pyx_pw_3_sa_7IntList_25append(PyObject *__pyx_v_self, PyObject *__pyx_arg_val) { +static PyObject *__pyx_pw_3_sa_7IntList_28append(PyObject *__pyx_v_self, PyObject *__pyx_arg_val); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_28append(PyObject *__pyx_v_self, PyObject *__pyx_arg_val) { int __pyx_v_val; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("append (wrapper)", 0); assert(__pyx_arg_val); { - __pyx_v_val = __Pyx_PyInt_AsInt(__pyx_arg_val); if (unlikely((__pyx_v_val == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_val = __Pyx_PyInt_AsInt(__pyx_arg_val); if (unlikely((__pyx_v_val == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -5701,12 +6090,12 @@ static PyObject *__pyx_pw_3_sa_7IntList_25append(PyObject *__pyx_v_self, PyObjec __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_7IntList_24append(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((int)__pyx_v_val)); + __pyx_r = __pyx_pf_3_sa_7IntList_27append(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((int)__pyx_v_val)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":127 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":128 * return self.size * * def append(self, int val): # <<<<<<<<<<<<<< @@ -5714,12 +6103,12 @@ static PyObject *__pyx_pw_3_sa_7IntList_25append(PyObject *__pyx_v_self, PyObjec * */ -static PyObject *__pyx_pf_3_sa_7IntList_24append(struct __pyx_obj_3_sa_IntList *__pyx_v_self, int __pyx_v_val) { +static PyObject *__pyx_pf_3_sa_7IntList_27append(struct __pyx_obj_3_sa_IntList *__pyx_v_self, int __pyx_v_val) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("append", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":128 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":129 * * def append(self, int val): * self._append(val) # <<<<<<<<<<<<<< @@ -5734,7 +6123,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_24append(struct __pyx_obj_3_sa_IntList * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":130 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":131 * self._append(val) * * cdef void _append(self, int val): # <<<<<<<<<<<<<< @@ -5747,7 +6136,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v int __pyx_t_1; __Pyx_RefNannySetupContext("_append", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":131 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":132 * * cdef void _append(self, int val): * if self.len == self.size: # <<<<<<<<<<<<<< @@ -5757,7 +6146,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v __pyx_t_1 = (__pyx_v_self->len == __pyx_v_self->size); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":132 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":133 * cdef void _append(self, int val): * if self.len == self.size: * self.size = self.size + self.increment # <<<<<<<<<<<<<< @@ -5766,7 +6155,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v */ __pyx_v_self->size = (__pyx_v_self->size + __pyx_v_self->increment); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":133 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":134 * if self.len == self.size: * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(int)) # <<<<<<<<<<<<<< @@ -5778,7 +6167,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":134 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":135 * self.size = self.size + self.increment * self.arr = realloc(self.arr, self.size*sizeof(int)) * self.arr[self.len] = val # <<<<<<<<<<<<<< @@ -5787,7 +6176,7 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v */ (__pyx_v_self->arr[__pyx_v_self->len]) = __pyx_v_val; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":135 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":136 * self.arr = realloc(self.arr, self.size*sizeof(int)) * self.arr[self.len] = val * self.len = self.len + 1 # <<<<<<<<<<<<<< @@ -5800,17 +6189,17 @@ static void __pyx_f_3_sa_7IntList__append(struct __pyx_obj_3_sa_IntList *__pyx_v } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7IntList_27extend(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ -static PyObject *__pyx_pw_3_sa_7IntList_27extend(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { +static PyObject *__pyx_pw_3_sa_7IntList_30extend(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_30extend(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("extend (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_7IntList_26extend(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((PyObject *)__pyx_v_other)); + __pyx_r = __pyx_pf_3_sa_7IntList_29extend(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((PyObject *)__pyx_v_other)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":137 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":138 * self.len = self.len + 1 * * def extend(self, other): # <<<<<<<<<<<<<< @@ -5818,7 +6207,7 @@ static PyObject *__pyx_pw_3_sa_7IntList_27extend(PyObject *__pyx_v_self, PyObjec * */ -static PyObject *__pyx_pf_3_sa_7IntList_26extend(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_other) { +static PyObject *__pyx_pf_3_sa_7IntList_29extend(struct __pyx_obj_3_sa_IntList *__pyx_v_self, PyObject *__pyx_v_other) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -5827,14 +6216,14 @@ static PyObject *__pyx_pf_3_sa_7IntList_26extend(struct __pyx_obj_3_sa_IntList * int __pyx_clineno = 0; __Pyx_RefNannySetupContext("extend", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":138 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":139 * * def extend(self, other): * self._extend(other) # <<<<<<<<<<<<<< * * cdef void _extend(self, IntList other): */ - if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_other) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_other, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_other; __Pyx_INCREF(__pyx_t_1); ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->_extend(__pyx_v_self, ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1)); @@ -5852,7 +6241,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_26extend(struct __pyx_obj_3_sa_IntList * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":140 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":141 * self._extend(other) * * cdef void _extend(self, IntList other): # <<<<<<<<<<<<<< @@ -5864,7 +6253,7 @@ static void __pyx_f_3_sa_7IntList__extend(struct __pyx_obj_3_sa_IntList *__pyx_v __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_extend", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":141 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":142 * * cdef void _extend(self, IntList other): * self._extend_arr(other.arr, other.len) # <<<<<<<<<<<<<< @@ -5876,7 +6265,7 @@ static void __pyx_f_3_sa_7IntList__extend(struct __pyx_obj_3_sa_IntList *__pyx_v __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":143 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":144 * self._extend_arr(other.arr, other.len) * * cdef void _extend_arr(self, int* other, int other_len): # <<<<<<<<<<<<<< @@ -5889,7 +6278,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p int __pyx_t_1; __Pyx_RefNannySetupContext("_extend_arr", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":144 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":145 * * cdef void _extend_arr(self, int* other, int other_len): * if self.size < self.len + other_len: # <<<<<<<<<<<<<< @@ -5899,7 +6288,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p __pyx_t_1 = (__pyx_v_self->size < (__pyx_v_self->len + __pyx_v_other_len)); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":145 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":146 * cdef void _extend_arr(self, int* other, int other_len): * if self.size < self.len + other_len: * self.size = self.len + other_len # <<<<<<<<<<<<<< @@ -5908,7 +6297,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->size = (__pyx_v_self->len + __pyx_v_other_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":146 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":147 * if self.size < self.len + other_len: * self.size = self.len + other_len * self.arr = realloc(self.arr, self.size*sizeof(int)) # <<<<<<<<<<<<<< @@ -5920,7 +6309,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":147 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":148 * self.size = self.len + other_len * self.arr = realloc(self.arr, self.size*sizeof(int)) * memcpy(self.arr+self.len, other, other_len*sizeof(int)) # <<<<<<<<<<<<<< @@ -5929,7 +6318,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p */ memcpy((__pyx_v_self->arr + __pyx_v_self->len), __pyx_v_other, (__pyx_v_other_len * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":148 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":149 * self.arr = realloc(self.arr, self.size*sizeof(int)) * memcpy(self.arr+self.len, other, other_len*sizeof(int)) * self.len = self.len + other_len # <<<<<<<<<<<<<< @@ -5941,7 +6330,7 @@ static void __pyx_f_3_sa_7IntList__extend_arr(struct __pyx_obj_3_sa_IntList *__p __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":150 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":151 * self.len = self.len + other_len * * cdef void _clear(self): # <<<<<<<<<<<<<< @@ -5953,7 +6342,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("_clear", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":151 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":152 * * cdef void _clear(self): * free(self.arr) # <<<<<<<<<<<<<< @@ -5962,7 +6351,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ */ free(__pyx_v_self->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":152 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":153 * cdef void _clear(self): * free(self.arr) * self.len = 0 # <<<<<<<<<<<<<< @@ -5971,7 +6360,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ */ __pyx_v_self->len = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":153 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":154 * free(self.arr) * self.len = 0 * self.size = 0 # <<<<<<<<<<<<<< @@ -5980,7 +6369,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ */ __pyx_v_self->size = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":154 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":155 * self.len = 0 * self.size = 0 * self.arr = malloc(0) # <<<<<<<<<<<<<< @@ -5992,7 +6381,7 @@ static void __pyx_f_3_sa_7IntList__clear(struct __pyx_obj_3_sa_IntList *__pyx_v_ __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":156 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":157 * self.arr = malloc(0) * * cdef void write_handle(self, FILE* f): # <<<<<<<<<<<<<< @@ -6004,7 +6393,7 @@ static void __pyx_f_3_sa_7IntList_write_handle(struct __pyx_obj_3_sa_IntList *__ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":157 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":158 * * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(int), 1, f) # <<<<<<<<<<<<<< @@ -6013,7 +6402,7 @@ static void __pyx_f_3_sa_7IntList_write_handle(struct __pyx_obj_3_sa_IntList *__ */ fwrite((&__pyx_v_self->len), (sizeof(int)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":158 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":159 * cdef void write_handle(self, FILE* f): * fwrite(&(self.len), sizeof(int), 1, f) * fwrite(self.arr, sizeof(int), self.len, f) # <<<<<<<<<<<<<< @@ -6026,14 +6415,14 @@ static void __pyx_f_3_sa_7IntList_write_handle(struct __pyx_obj_3_sa_IntList *__ } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7IntList_29write(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/ -static PyObject *__pyx_pw_3_sa_7IntList_29write(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) { +static PyObject *__pyx_pw_3_sa_7IntList_32write(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_32write(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) { char *__pyx_v_filename; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6041,12 +6430,12 @@ static PyObject *__pyx_pw_3_sa_7IntList_29write(PyObject *__pyx_v_self, PyObject __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_7IntList_28write(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((char *)__pyx_v_filename)); + __pyx_r = __pyx_pf_3_sa_7IntList_31write(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((char *)__pyx_v_filename)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":160 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":161 * fwrite(self.arr, sizeof(int), self.len, f) * * def write(self, char* filename): # <<<<<<<<<<<<<< @@ -6054,13 +6443,13 @@ static PyObject *__pyx_pw_3_sa_7IntList_29write(PyObject *__pyx_v_self, PyObject * f = fopen(filename, "w") */ -static PyObject *__pyx_pf_3_sa_7IntList_28write(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename) { +static PyObject *__pyx_pf_3_sa_7IntList_31write(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename) { FILE *__pyx_v_f; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":162 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":163 * def write(self, char* filename): * cdef FILE* f * f = fopen(filename, "w") # <<<<<<<<<<<<<< @@ -6069,7 +6458,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_28write(struct __pyx_obj_3_sa_IntList *_ */ __pyx_v_f = fopen(__pyx_v_filename, __pyx_k__w); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":163 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":164 * cdef FILE* f * f = fopen(filename, "w") * self.write_handle(f) # <<<<<<<<<<<<<< @@ -6078,7 +6467,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_28write(struct __pyx_obj_3_sa_IntList *_ */ ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->write_handle(__pyx_v_self, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":164 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":165 * f = fopen(filename, "w") * self.write_handle(f) * fclose(f) # <<<<<<<<<<<<<< @@ -6093,7 +6482,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_28write(struct __pyx_obj_3_sa_IntList *_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":166 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":167 * fclose(f) * * cdef void read_handle(self, FILE* f): # <<<<<<<<<<<<<< @@ -6105,7 +6494,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_handle", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":167 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":168 * * cdef void read_handle(self, FILE* f): * (self.arr) # <<<<<<<<<<<<<< @@ -6114,7 +6503,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->arr; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":168 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":169 * cdef void read_handle(self, FILE* f): * (self.arr) * fread(&(self.len), sizeof(int), 1, f) # <<<<<<<<<<<<<< @@ -6123,7 +6512,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p */ fread((&__pyx_v_self->len), (sizeof(int)), 1, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":169 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":170 * (self.arr) * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(int)) # <<<<<<<<<<<<<< @@ -6132,7 +6521,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->arr = ((int *)malloc((__pyx_v_self->len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":170 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":171 * fread(&(self.len), sizeof(int), 1, f) * self.arr = malloc(self.len * sizeof(int)) * self.size = self.len # <<<<<<<<<<<<<< @@ -6141,7 +6530,7 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p */ __pyx_v_self->size = __pyx_v_self->len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":171 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":172 * self.arr = malloc(self.len * sizeof(int)) * self.size = self.len * fread(self.arr, sizeof(int), self.len, f) # <<<<<<<<<<<<<< @@ -6154,14 +6543,14 @@ static void __pyx_f_3_sa_7IntList_read_handle(struct __pyx_obj_3_sa_IntList *__p } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7IntList_31read(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/ -static PyObject *__pyx_pw_3_sa_7IntList_31read(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) { +static PyObject *__pyx_pw_3_sa_7IntList_34read(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/ +static PyObject *__pyx_pw_3_sa_7IntList_34read(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) { char *__pyx_v_filename; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -6169,12 +6558,12 @@ static PyObject *__pyx_pw_3_sa_7IntList_31read(PyObject *__pyx_v_self, PyObject __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_7IntList_30read(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((char *)__pyx_v_filename)); + __pyx_r = __pyx_pf_3_sa_7IntList_33read(((struct __pyx_obj_3_sa_IntList *)__pyx_v_self), ((char *)__pyx_v_filename)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":173 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":174 * fread(self.arr, sizeof(int), self.len, f) * * def read(self, char* filename): # <<<<<<<<<<<<<< @@ -6182,13 +6571,13 @@ static PyObject *__pyx_pw_3_sa_7IntList_31read(PyObject *__pyx_v_self, PyObject * f = fopen(filename, "r") */ -static PyObject *__pyx_pf_3_sa_7IntList_30read(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename) { +static PyObject *__pyx_pf_3_sa_7IntList_33read(struct __pyx_obj_3_sa_IntList *__pyx_v_self, char *__pyx_v_filename) { FILE *__pyx_v_f; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":175 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":176 * def read(self, char* filename): * cdef FILE* f * f = fopen(filename, "r") # <<<<<<<<<<<<<< @@ -6197,7 +6586,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_30read(struct __pyx_obj_3_sa_IntList *__ */ __pyx_v_f = fopen(__pyx_v_filename, __pyx_k__r); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":176 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":177 * cdef FILE* f * f = fopen(filename, "r") * self.read_handle(f) # <<<<<<<<<<<<<< @@ -6205,7 +6594,7 @@ static PyObject *__pyx_pf_3_sa_7IntList_30read(struct __pyx_obj_3_sa_IntList *__ */ ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_self->__pyx_vtab)->read_handle(__pyx_v_self, __pyx_v_f); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":177 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/int_list.pxi":178 * f = fopen(filename, "r") * self.read_handle(f) * fclose(f) # <<<<<<<<<<<<<< @@ -7730,7 +8119,7 @@ static PyObject *__pyx_pw_3_sa_9DataArray_19read_bitext(PyObject *__pyx_v_self, __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_3_sa_9DataArray_11read_bitext_2generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_3_sa_9DataArray_11read_bitext_2generator6(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* "/Users/vchahun/Sandbox/cdec/python/src/sa/data_array.pxi":73 * def read_bitext(self, char* filename, int side): @@ -7741,24 +8130,24 @@ static PyObject *__pyx_gb_3_sa_9DataArray_11read_bitext_2generator3(__pyx_Genera */ static PyObject *__pyx_pf_3_sa_9DataArray_11read_bitext_genexpr(PyObject *__pyx_self) { - struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *__pyx_cur_scope; + struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("genexpr", 0); - __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *)__pyx_ptype_3_sa___pyx_scope_struct_1_genexpr->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_1_genexpr, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *)__pyx_ptype_3_sa___pyx_scope_struct_2_genexpr->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_2_genexpr, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; } __Pyx_GOTREF(__pyx_cur_scope); - __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *) __pyx_self; + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *) __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_3_sa_9DataArray_11read_bitext_2generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_9DataArray_11read_bitext_2generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -7776,9 +8165,9 @@ static PyObject *__pyx_pf_3_sa_9DataArray_11read_bitext_genexpr(PyObject *__pyx_ return __pyx_r; } -static PyObject *__pyx_gb_3_sa_9DataArray_11read_bitext_2generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_3_sa_9DataArray_11read_bitext_2generator6(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *)__pyx_generator->closure); + struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; Py_ssize_t __pyx_t_2; @@ -7888,7 +8277,7 @@ static PyObject *__pyx_gb_3_sa_9DataArray_11read_bitext_2generator3(__pyx_Genera */ static PyObject *__pyx_pf_3_sa_9DataArray_18read_bitext(struct __pyx_obj_3_sa_DataArray *__pyx_v_self, char *__pyx_v_filename, int __pyx_v_side) { - struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *__pyx_cur_scope; + struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *__pyx_cur_scope; PyObject *__pyx_v_data = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -7907,7 +8296,7 @@ static PyObject *__pyx_pf_3_sa_9DataArray_18read_bitext(struct __pyx_obj_3_sa_Da const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("read_bitext", 0); - __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *)__pyx_ptype_3_sa___pyx_scope_struct__read_bitext->tp_new(__pyx_ptype_3_sa___pyx_scope_struct__read_bitext, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *)__pyx_ptype_3_sa___pyx_scope_struct_1_read_bitext->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_1_read_bitext, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -20752,7 +21141,7 @@ static int __pyx_pf_3_sa_3LCP___cinit__(struct __pyx_obj_3_sa_LCP *__pyx_v_self, __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_3_sa_3LCP_4generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_3_sa_3LCP_4generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_3_sa_3LCP_3compute_stats(PyObject *__pyx_v_self, PyObject *__pyx_arg_max_n); /*proto*/ @@ -20785,14 +21174,14 @@ static PyObject *__pyx_pw_3_sa_3LCP_3compute_stats(PyObject *__pyx_v_self, PyObj */ static PyObject *__pyx_pf_3_sa_3LCP_2compute_stats(struct __pyx_obj_3_sa_LCP *__pyx_v_self, int __pyx_v_max_n) { - struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *__pyx_cur_scope; + struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("compute_stats", 0); - __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *)__pyx_ptype_3_sa___pyx_scope_struct_2_compute_stats->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_2_compute_stats, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *)__pyx_ptype_3_sa___pyx_scope_struct_3_compute_stats->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_3_compute_stats, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -20803,7 +21192,7 @@ static PyObject *__pyx_pf_3_sa_3LCP_2compute_stats(struct __pyx_obj_3_sa_LCP *__ __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __pyx_cur_scope->__pyx_v_max_n = __pyx_v_max_n; { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_3LCP_4generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_3LCP_4generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -20821,9 +21210,9 @@ static PyObject *__pyx_pf_3_sa_3LCP_2compute_stats(struct __pyx_obj_3_sa_LCP *__ return __pyx_r; } -static PyObject *__pyx_gb_3_sa_3LCP_4generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_3_sa_3LCP_4generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *)__pyx_generator->closure); + struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *)__pyx_generator->closure); PyObject *__pyx_r = NULL; PyObject *__pyx_t_1 = NULL; int __pyx_t_2; @@ -22797,7 +23186,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_4__str__(struct __pyx_obj_3_sa_Phrase *__ * for i from 0 <= i < self.n: * s = self.syms[i] # <<<<<<<<<<<<<< * strs.append(sym_tostring(s)) - * return " ".join(strs) + * return ' '.join(strs) */ __pyx_v_s = (__pyx_v_self->syms[__pyx_v_i]); @@ -22805,7 +23194,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_4__str__(struct __pyx_obj_3_sa_Phrase *__ * for i from 0 <= i < self.n: * s = self.syms[i] * strs.append(sym_tostring(s)) # <<<<<<<<<<<<<< - * return " ".join(strs) + * return ' '.join(strs) * */ __pyx_t_1 = PyBytes_FromString(__pyx_f_3_sa_sym_tostring(__pyx_v_s)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -22817,7 +23206,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_4__str__(struct __pyx_obj_3_sa_Phrase *__ /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":34 * s = self.syms[i] * strs.append(sym_tostring(s)) - * return " ".join(strs) # <<<<<<<<<<<<<< + * return ' '.join(strs) # <<<<<<<<<<<<<< * * def handle(self): */ @@ -22865,7 +23254,7 @@ static PyObject *__pyx_pw_3_sa_6Phrase_7handle(PyObject *__pyx_v_self, CYTHON_UN } /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":36 - * return " ".join(strs) + * return ' '.join(strs) * * def handle(self): # <<<<<<<<<<<<<< * """return a hashable representation that normalizes the ordering @@ -23131,7 +23520,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_8strhandle(struct __pyx_obj_3_sa_Phrase * * s = sym_setindex(s,i) * i = i + 1 # <<<<<<<<<<<<<< * norm.append(sym_tostring(s)) - * return " ".join(norm) + * return ' '.join(norm) */ __pyx_v_i = (__pyx_v_i + 1); goto __pyx_L5; @@ -23142,7 +23531,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_8strhandle(struct __pyx_obj_3_sa_Phrase * * s = sym_setindex(s,i) * i = i + 1 * norm.append(sym_tostring(s)) # <<<<<<<<<<<<<< - * return " ".join(norm) + * return ' '.join(norm) * */ __pyx_t_1 = PyBytes_FromString(__pyx_f_3_sa_sym_tostring(__pyx_v_s)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -23154,7 +23543,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_8strhandle(struct __pyx_obj_3_sa_Phrase * /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":63 * i = i + 1 * norm.append(sym_tostring(s)) - * return " ".join(norm) # <<<<<<<<<<<<<< + * return ' '.join(norm) # <<<<<<<<<<<<<< * * def arity(self): */ @@ -23202,7 +23591,7 @@ static PyObject *__pyx_pw_3_sa_6Phrase_11arity(PyObject *__pyx_v_self, CYTHON_UN } /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":65 - * return " ".join(norm) + * return ' '.join(norm) * * def arity(self): # <<<<<<<<<<<<<< * return self.n_vars @@ -24130,7 +24519,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_26__getitem__(struct __pyx_obj_3_sa_Phras __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_3_sa_6Phrase_30generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_3_sa_6Phrase_30generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ static PyObject *__pyx_pw_3_sa_6Phrase_29__iter__(PyObject *__pyx_v_self); /*proto*/ @@ -24152,14 +24541,14 @@ static PyObject *__pyx_pw_3_sa_6Phrase_29__iter__(PyObject *__pyx_v_self) { */ static PyObject *__pyx_pf_3_sa_6Phrase_28__iter__(struct __pyx_obj_3_sa_Phrase *__pyx_v_self) { - struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *__pyx_cur_scope; + struct __pyx_obj_3_sa___pyx_scope_struct_4___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_3_sa___pyx_scope_struct_3___iter__ *)__pyx_ptype_3_sa___pyx_scope_struct_3___iter__->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_3___iter__, __pyx_empty_tuple, NULL); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *)__pyx_ptype_3_sa___pyx_scope_struct_4___iter__->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_4___iter__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return NULL; @@ -24169,7 +24558,7 @@ static PyObject *__pyx_pf_3_sa_6Phrase_28__iter__(struct __pyx_obj_3_sa_Phrase * __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_3_sa_6Phrase_30generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_6Phrase_30generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -24187,9 +24576,9 @@ static PyObject *__pyx_pf_3_sa_6Phrase_28__iter__(struct __pyx_obj_3_sa_Phrase * return __pyx_r; } -static PyObject *__pyx_gb_3_sa_6Phrase_30generator1(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_3_sa_6Phrase_30generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { - struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *)__pyx_generator->closure); + struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *)__pyx_generator->closure); PyObject *__pyx_r = NULL; int __pyx_t_1; PyObject *__pyx_t_2 = NULL; @@ -24548,12 +24937,12 @@ static int __pyx_pw_3_sa_4Rule_1__cinit__(PyObject *__pyx_v_self, PyObject *__py static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__f,&__pyx_n_s__e,&__pyx_n_s__scores,&__pyx_n_s__word_alignments,0}; PyObject* values[5] = {0,0,0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":162 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":161 + * cdef class Rule: * - * def __cinit__(self, int lhs, Phrase f, Phrase e, - * scores=None, word_alignments=None): # <<<<<<<<<<<<<< - * cdef int i, n - * cdef char *rest + * def __cinit__(self, int lhs, Phrase f, Phrase e, scores=None, word_alignments=None): # <<<<<<<<<<<<<< + * if not sym_isvar(lhs): raise Exception('Invalid LHS symbol: %d' % lhs) + * self.lhs = lhs */ values[3] = ((PyObject *)Py_None); values[4] = ((PyObject *)Py_None); @@ -24634,82 +25023,61 @@ static int __pyx_pw_3_sa_4Rule_1__cinit__(PyObject *__pyx_v_self, PyObject *__py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":161 - * cdef class Rule: - * - * def __cinit__(self, int lhs, Phrase f, Phrase e, # <<<<<<<<<<<<<< - * scores=None, word_alignments=None): - * cdef int i, n - */ - static int __pyx_pf_3_sa_4Rule___cinit__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, int __pyx_v_lhs, struct __pyx_obj_3_sa_Phrase *__pyx_v_f, struct __pyx_obj_3_sa_Phrase *__pyx_v_e, PyObject *__pyx_v_scores, PyObject *__pyx_v_word_alignments) { - int __pyx_v_i; - int __pyx_v_n; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - Py_ssize_t __pyx_t_4; - int __pyx_t_5; - float __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":166 - * cdef char *rest - * - * if not sym_isvar(lhs): # <<<<<<<<<<<<<< - * raise Exception('Invalid LHS symbol: %d' % lhs) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":162 * + * def __cinit__(self, int lhs, Phrase f, Phrase e, scores=None, word_alignments=None): + * if not sym_isvar(lhs): raise Exception('Invalid LHS symbol: %d' % lhs) # <<<<<<<<<<<<<< + * self.lhs = lhs + * self.f = f */ __pyx_t_1 = (!__pyx_f_3_sa_sym_isvar(__pyx_v_lhs)); if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":167 - * - * if not sym_isvar(lhs): - * raise Exception('Invalid LHS symbol: %d' % lhs) # <<<<<<<<<<<<<< - * - * self.lhs = lhs - */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_68), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_68), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[7]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":169 - * raise Exception('Invalid LHS symbol: %d' % lhs) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":163 + * def __cinit__(self, int lhs, Phrase f, Phrase e, scores=None, word_alignments=None): + * if not sym_isvar(lhs): raise Exception('Invalid LHS symbol: %d' % lhs) * self.lhs = lhs # <<<<<<<<<<<<<< * self.f = f * self.e = e */ __pyx_v_self->lhs = __pyx_v_lhs; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":170 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":164 + * if not sym_isvar(lhs): raise Exception('Invalid LHS symbol: %d' % lhs) * self.lhs = lhs * self.f = f # <<<<<<<<<<<<<< * self.e = e - * + * self.word_alignments = word_alignments */ __Pyx_INCREF(((PyObject *)__pyx_v_f)); __Pyx_GIVEREF(((PyObject *)__pyx_v_f)); @@ -24717,12 +25085,12 @@ static int __pyx_pf_3_sa_4Rule___cinit__(struct __pyx_obj_3_sa_Rule *__pyx_v_sel __Pyx_DECREF(((PyObject *)__pyx_v_self->f)); __pyx_v_self->f = __pyx_v_f; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":171 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":165 * self.lhs = lhs * self.f = f * self.e = e # <<<<<<<<<<<<<< - * * self.word_alignments = word_alignments + * self.scores = scores */ __Pyx_INCREF(((PyObject *)__pyx_v_e)); __Pyx_GIVEREF(((PyObject *)__pyx_v_e)); @@ -24730,12 +25098,12 @@ static int __pyx_pf_3_sa_4Rule___cinit__(struct __pyx_obj_3_sa_Rule *__pyx_v_sel __Pyx_DECREF(((PyObject *)__pyx_v_self->e)); __pyx_v_self->e = __pyx_v_e; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":173 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":166 + * self.f = f * self.e = e - * * self.word_alignments = word_alignments # <<<<<<<<<<<<<< - * if scores is None: - * self.cscores = NULL + * self.scores = scores + * */ __Pyx_INCREF(__pyx_v_word_alignments); __Pyx_GIVEREF(__pyx_v_word_alignments); @@ -24743,90 +25111,19 @@ static int __pyx_pf_3_sa_4Rule___cinit__(struct __pyx_obj_3_sa_Rule *__pyx_v_sel __Pyx_DECREF(__pyx_v_self->word_alignments); __pyx_v_self->word_alignments = __pyx_v_word_alignments; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":174 - * - * self.word_alignments = word_alignments - * if scores is None: # <<<<<<<<<<<<<< - * self.cscores = NULL - * self.n_scores = 0 - */ - __pyx_t_1 = (__pyx_v_scores == Py_None); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":175 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":167 + * self.e = e * self.word_alignments = word_alignments - * if scores is None: - * self.cscores = NULL # <<<<<<<<<<<<<< - * self.n_scores = 0 - * else: - */ - __pyx_v_self->cscores = NULL; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":176 - * if scores is None: - * self.cscores = NULL - * self.n_scores = 0 # <<<<<<<<<<<<<< - * else: - * n = len(scores) - */ - __pyx_v_self->n_scores = 0; - goto __pyx_L4; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":178 - * self.n_scores = 0 - * else: - * n = len(scores) # <<<<<<<<<<<<<< - * self.cscores = malloc(n*sizeof(float)) - * self.n_scores = n - */ - __pyx_t_4 = PyObject_Length(__pyx_v_scores); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_n = __pyx_t_4; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":179 - * else: - * n = len(scores) - * self.cscores = malloc(n*sizeof(float)) # <<<<<<<<<<<<<< - * self.n_scores = n - * for i from 0 <= i < n: - */ - __pyx_v_self->cscores = ((float *)malloc((__pyx_v_n * (sizeof(float))))); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":180 - * n = len(scores) - * self.cscores = malloc(n*sizeof(float)) - * self.n_scores = n # <<<<<<<<<<<<<< - * for i from 0 <= i < n: - * self.cscores[i] = scores[i] - */ - __pyx_v_self->n_scores = __pyx_v_n; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":181 - * self.cscores = malloc(n*sizeof(float)) - * self.n_scores = n - * for i from 0 <= i < n: # <<<<<<<<<<<<<< - * self.cscores[i] = scores[i] - * - */ - __pyx_t_5 = __pyx_v_n; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":182 - * self.n_scores = n - * for i from 0 <= i < n: - * self.cscores[i] = scores[i] # <<<<<<<<<<<<<< + * self.scores = scores # <<<<<<<<<<<<<< * - * def __dealloc__(self): + * def __hash__(self): */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_scores, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __pyx_PyFloat_AsFloat(__pyx_t_3); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - (__pyx_v_self->cscores[__pyx_v_i]) = __pyx_t_6; - } - } - __pyx_L4:; + if (!(likely(((__pyx_v_scores) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_scores, __pyx_ptype_3_sa_FeatureVector))))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_scores); + __Pyx_GIVEREF(__pyx_v_scores); + __Pyx_GOTREF(__pyx_v_self->scores); + __Pyx_DECREF(((PyObject *)__pyx_v_self->scores)); + __pyx_v_self->scores = ((struct __pyx_obj_3_sa_FeatureVector *)__pyx_v_scores); __pyx_r = 0; goto __pyx_L0; @@ -24841,72 +25138,25 @@ static int __pyx_pf_3_sa_4Rule___cinit__(struct __pyx_obj_3_sa_Rule *__pyx_v_sel } /* Python wrapper */ -static void __pyx_pw_3_sa_4Rule_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_pw_3_sa_4Rule_3__dealloc__(PyObject *__pyx_v_self) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); - __pyx_pf_3_sa_4Rule_2__dealloc__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":184 - * self.cscores[i] = scores[i] - * - * def __dealloc__(self): # <<<<<<<<<<<<<< - * if self.cscores != NULL: - * free(self.cscores) - */ - -static void __pyx_pf_3_sa_4Rule_2__dealloc__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__dealloc__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":185 - * - * def __dealloc__(self): - * if self.cscores != NULL: # <<<<<<<<<<<<<< - * free(self.cscores) - * - */ - __pyx_t_1 = (__pyx_v_self->cscores != NULL); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":186 - * def __dealloc__(self): - * if self.cscores != NULL: - * free(self.cscores) # <<<<<<<<<<<<<< - * - * def __hash__(self): - */ - free(__pyx_v_self->cscores); - goto __pyx_L3; - } - __pyx_L3:; - - __Pyx_RefNannyFinishContext(); -} - -/* Python wrapper */ -static Py_hash_t __pyx_pw_3_sa_4Rule_5__hash__(PyObject *__pyx_v_self); /*proto*/ -static Py_hash_t __pyx_pw_3_sa_4Rule_5__hash__(PyObject *__pyx_v_self) { +static Py_hash_t __pyx_pw_3_sa_4Rule_3__hash__(PyObject *__pyx_v_self); /*proto*/ +static Py_hash_t __pyx_pw_3_sa_4Rule_3__hash__(PyObject *__pyx_v_self) { Py_hash_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__hash__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_4__hash__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); + __pyx_r = __pyx_pf_3_sa_4Rule_2__hash__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":188 - * free(self.cscores) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":169 + * self.scores = scores * * def __hash__(self): # <<<<<<<<<<<<<< * return hash((self.lhs, self.f, self.e)) * */ -static Py_hash_t __pyx_pf_3_sa_4Rule_4__hash__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { +static Py_hash_t __pyx_pf_3_sa_4Rule_2__hash__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { Py_hash_t __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -24917,16 +25167,16 @@ static Py_hash_t __pyx_pf_3_sa_4Rule_4__hash__(struct __pyx_obj_3_sa_Rule *__pyx int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__hash__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":189 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":170 * * def __hash__(self): * return hash((self.lhs, self.f, self.e)) # <<<<<<<<<<<<<< * * def __cmp__(self, Rule other): */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -24937,7 +25187,7 @@ static Py_hash_t __pyx_pf_3_sa_4Rule_4__hash__(struct __pyx_obj_3_sa_Rule *__pyx PyTuple_SET_ITEM(__pyx_t_2, 2, ((PyObject *)__pyx_v_self->e)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->e)); __pyx_t_1 = 0; - __pyx_t_3 = PyObject_Hash(((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Hash(((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_3; goto __pyx_L0; @@ -24957,13 +25207,13 @@ static Py_hash_t __pyx_pf_3_sa_4Rule_4__hash__(struct __pyx_obj_3_sa_Rule *__pyx /* Python wrapper */ #if PY_MAJOR_VERSION < 3 -static int __pyx_pw_3_sa_4Rule_7__cmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ -static int __pyx_pw_3_sa_4Rule_7__cmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { +static int __pyx_pw_3_sa_4Rule_5__cmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static int __pyx_pw_3_sa_4Rule_5__cmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_3_sa_Rule, 1, "other", 0))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_4Rule_6__cmp__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((struct __pyx_obj_3_sa_Rule *)__pyx_v_other)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_3_sa_Rule, 1, "other", 0))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_4Rule_4__cmp__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((struct __pyx_obj_3_sa_Rule *)__pyx_v_other)); goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; @@ -24973,16 +25223,16 @@ static int __pyx_pw_3_sa_4Rule_7__cmp__(PyObject *__pyx_v_self, PyObject *__pyx_ } #endif /*!(#if PY_MAJOR_VERSION < 3)*/ -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":191 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":172 * return hash((self.lhs, self.f, self.e)) * * def __cmp__(self, Rule other): # <<<<<<<<<<<<<< - * return cmp((self.lhs, self.f, self.e, self.word_alignments), (other.lhs, other.f, other.e, self.word_alignments)) - * + * return cmp((self.lhs, self.f, self.e, self.word_alignments), + * (other.lhs, other.f, other.e, self.word_alignments)) */ #if PY_MAJOR_VERSION < 3 -static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Rule *__pyx_v_other) { +static int __pyx_pf_3_sa_4Rule_4__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Rule *__pyx_v_other) { int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -24994,16 +25244,16 @@ static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":192 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":173 * * def __cmp__(self, Rule other): - * return cmp((self.lhs, self.f, self.e, self.word_alignments), (other.lhs, other.f, other.e, self.word_alignments)) # <<<<<<<<<<<<<< + * return cmp((self.lhs, self.f, self.e, self.word_alignments), # <<<<<<<<<<<<<< + * (other.lhs, other.f, other.e, self.word_alignments)) * - * def __iadd__(self, Rule other): */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -25017,9 +25267,17 @@ static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_self->word_alignments); __Pyx_GIVEREF(__pyx_v_self->word_alignments); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromLong(__pyx_v_other->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":174 + * def __cmp__(self, Rule other): + * return cmp((self.lhs, self.f, self.e, self.word_alignments), + * (other.lhs, other.f, other.e, self.word_alignments)) # <<<<<<<<<<<<<< + * + * def fmerge(self, Phrase f): + */ + __pyx_t_1 = PyInt_FromLong(__pyx_v_other->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -25033,7 +25291,7 @@ static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->word_alignments); __Pyx_GIVEREF(__pyx_v_self->word_alignments); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); @@ -25041,10 +25299,10 @@ static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_2 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_cmp, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_cmp, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; goto __pyx_L0; @@ -25064,114 +25322,13 @@ static int __pyx_pf_3_sa_4Rule_6__cmp__(struct __pyx_obj_3_sa_Rule *__pyx_v_self #endif /*!(#if PY_MAJOR_VERSION < 3)*/ /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_9__iadd__(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_9__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_3_sa_Rule, 1, "other", 0))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_4Rule_8__iadd__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((struct __pyx_obj_3_sa_Rule *)__pyx_v_other)); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":194 - * return cmp((self.lhs, self.f, self.e, self.word_alignments), (other.lhs, other.f, other.e, self.word_alignments)) - * - * def __iadd__(self, Rule other): # <<<<<<<<<<<<<< - * if self.n_scores != other.n_scores: - * raise ValueError - */ - -static PyObject *__pyx_pf_3_sa_4Rule_8__iadd__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Rule *__pyx_v_other) { - long __pyx_v_i; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__iadd__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":195 - * - * def __iadd__(self, Rule other): - * if self.n_scores != other.n_scores: # <<<<<<<<<<<<<< - * raise ValueError - * for i from 0 <= i < self.n_scores: - */ - __pyx_t_1 = (__pyx_v_self->n_scores != __pyx_v_other->n_scores); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":196 - * def __iadd__(self, Rule other): - * if self.n_scores != other.n_scores: - * raise ValueError # <<<<<<<<<<<<<< - * for i from 0 <= i < self.n_scores: - * self.cscores[i] = self.cscores[i] + other.cscores[i] - */ - __Pyx_Raise(__pyx_builtin_ValueError, 0, 0, 0); - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":197 - * if self.n_scores != other.n_scores: - * raise ValueError - * for i from 0 <= i < self.n_scores: # <<<<<<<<<<<<<< - * self.cscores[i] = self.cscores[i] + other.cscores[i] - * return self - */ - __pyx_t_2 = __pyx_v_self->n_scores; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":198 - * raise ValueError - * for i from 0 <= i < self.n_scores: - * self.cscores[i] = self.cscores[i] + other.cscores[i] # <<<<<<<<<<<<<< - * return self - * - */ - (__pyx_v_self->cscores[__pyx_v_i]) = ((__pyx_v_self->cscores[__pyx_v_i]) + (__pyx_v_other->cscores[__pyx_v_i])); - } - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":199 - * for i from 0 <= i < self.n_scores: - * self.cscores[i] = self.cscores[i] + other.cscores[i] - * return self # <<<<<<<<<<<<<< - * - * def fmerge(self, Phrase f): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_self)); - __pyx_r = ((PyObject *)__pyx_v_self); - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("_sa.Rule.__iadd__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_11fmerge(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_11fmerge(PyObject *__pyx_v_self, PyObject *__pyx_v_f) { +static PyObject *__pyx_pw_3_sa_4Rule_7fmerge(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/ +static PyObject *__pyx_pw_3_sa_4Rule_7fmerge(PyObject *__pyx_v_self, PyObject *__pyx_v_f) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("fmerge (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_f), __pyx_ptype_3_sa_Phrase, 1, "f", 0))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_4Rule_10fmerge(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((struct __pyx_obj_3_sa_Phrase *)__pyx_v_f)); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_f), __pyx_ptype_3_sa_Phrase, 1, "f", 0))) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_4Rule_6fmerge(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((struct __pyx_obj_3_sa_Phrase *)__pyx_v_f)); goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; @@ -25180,15 +25337,15 @@ static PyObject *__pyx_pw_3_sa_4Rule_11fmerge(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":201 - * return self +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":176 + * (other.lhs, other.f, other.e, self.word_alignments)) * * def fmerge(self, Phrase f): # <<<<<<<<<<<<<< * if self.f == f: * self.f = f */ -static PyObject *__pyx_pf_3_sa_4Rule_10fmerge(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_f) { +static PyObject *__pyx_pf_3_sa_4Rule_6fmerge(struct __pyx_obj_3_sa_Rule *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_f) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -25198,20 +25355,20 @@ static PyObject *__pyx_pf_3_sa_4Rule_10fmerge(struct __pyx_obj_3_sa_Rule *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("fmerge", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":202 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":177 * * def fmerge(self, Phrase f): * if self.f == f: # <<<<<<<<<<<<<< * self.f = f * */ - __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->f), ((PyObject *)__pyx_v_f), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_self->f), ((PyObject *)__pyx_v_f), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 177; __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[7]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":203 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":178 * def fmerge(self, Phrase f): * if self.f == f: * self.f = f # <<<<<<<<<<<<<< @@ -25240,17 +25397,17 @@ static PyObject *__pyx_pf_3_sa_4Rule_10fmerge(struct __pyx_obj_3_sa_Rule *__pyx_ } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_13arity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_13arity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { +static PyObject *__pyx_pw_3_sa_4Rule_9arity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_3_sa_4Rule_9arity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("arity (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_12arity(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); + __pyx_r = __pyx_pf_3_sa_4Rule_8arity(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":205 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":180 * self.f = f * * def arity(self): # <<<<<<<<<<<<<< @@ -25258,7 +25415,7 @@ static PyObject *__pyx_pw_3_sa_4Rule_13arity(PyObject *__pyx_v_self, CYTHON_UNUS * */ -static PyObject *__pyx_pf_3_sa_4Rule_12arity(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { +static PyObject *__pyx_pf_3_sa_4Rule_8arity(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -25268,7 +25425,7 @@ static PyObject *__pyx_pf_3_sa_4Rule_12arity(struct __pyx_obj_3_sa_Rule *__pyx_v int __pyx_clineno = 0; __Pyx_RefNannySetupContext("arity", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":206 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":181 * * def arity(self): * return self.f.arity() # <<<<<<<<<<<<<< @@ -25276,9 +25433,9 @@ static PyObject *__pyx_pf_3_sa_4Rule_12arity(struct __pyx_obj_3_sa_Rule *__pyx_v * def __str__(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->f), __pyx_n_s__arity); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->f), __pyx_n_s__arity); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 181; __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[7]; __pyx_lineno = 206; __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[7]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -25299,557 +25456,498 @@ static PyObject *__pyx_pf_3_sa_4Rule_12arity(struct __pyx_obj_3_sa_Rule *__pyx_v } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_15__str__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_15__str__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_3_sa_4Rule_11__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_4Rule_11__str__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_14__str__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); + __pyx_r = __pyx_pf_3_sa_4Rule_10__str__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_3_sa_4Rule_7__str___2generator7(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":187 + * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), str(self.scores)] + * if self.word_alignments is not None: + * fields.append(' '.join('%d-%d' % a for a in self.alignments())) # <<<<<<<<<<<<<< + * return ' ||| '.join(fields) + * + */ + +static PyObject *__pyx_pf_3_sa_4Rule_7__str___genexpr(PyObject *__pyx_self) { + struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("genexpr", 0); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *)__pyx_ptype_3_sa___pyx_scope_struct_6_genexpr->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_6_genexpr, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *) __pyx_self; + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_4Rule_7__str___2generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } + + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_sa.Rule.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":208 +static PyObject *__pyx_gb_3_sa_4Rule_7__str___2generator7(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *(*__pyx_t_4)(PyObject *); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __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[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { + __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; + __pyx_t_4 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + for (;;) { + if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_2 = __pyx_t_4(__pyx_t_1); + if (unlikely(!__pyx_t_2)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_a); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_a); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_a = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_69), __pyx_cur_scope->__pyx_v_a); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_r = ((PyObject *)__pyx_t_2); + __pyx_t_2 = 0; + __Pyx_XGIVEREF(__pyx_t_1); + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_3; + __pyx_cur_scope->__pyx_t_2 = __pyx_t_4; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_cur_scope->__pyx_t_0 = 0; + __Pyx_XGOTREF(__pyx_t_1); + __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_4 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return NULL; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":183 * return self.f.arity() * * def __str__(self): # <<<<<<<<<<<<<< - * scorestrs = [] - * for i from 0 <= i < self.n_scores: + * cdef unsigned i + * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), str(self.scores)] */ -static PyObject *__pyx_pf_3_sa_4Rule_14__str__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { - PyObject *__pyx_v_scorestrs = NULL; - long __pyx_v_i; +static PyObject *__pyx_pf_3_sa_4Rule_10__str__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { + struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *__pyx_cur_scope; PyObject *__pyx_v_fields = NULL; - PyObject *__pyx_v_alignstr = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; + PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - Py_ssize_t __pyx_t_10; + int __pyx_t_6; + int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":209 - * - * def __str__(self): - * scorestrs = [] # <<<<<<<<<<<<<< - * for i from 0 <= i < self.n_scores: - * scorestrs.append(str(self.cscores[i])) - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_scorestrs = __pyx_t_1; - __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":210 - * def __str__(self): - * scorestrs = [] - * for i from 0 <= i < self.n_scores: # <<<<<<<<<<<<<< - * scorestrs.append(str(self.cscores[i])) - * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), " ".join(scorestrs)] - */ - __pyx_t_2 = __pyx_v_self->n_scores; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":211 - * scorestrs = [] - * for i from 0 <= i < self.n_scores: - * scorestrs.append(str(self.cscores[i])) # <<<<<<<<<<<<<< - * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), " ".join(scorestrs)] - * if self.word_alignments is not None: - */ - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->cscores[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 211; __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[7]; __pyx_lineno = 211; __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(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_4 = PyList_Append(__pyx_v_scorestrs, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *)__pyx_ptype_3_sa___pyx_scope_struct_5___str__->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_5___str__, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":212 - * for i from 0 <= i < self.n_scores: - * scorestrs.append(str(self.cscores[i])) - * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), " ".join(scorestrs)] # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":185 + * def __str__(self): + * cdef unsigned i + * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), str(self.scores)] # <<<<<<<<<<<<<< * if self.word_alignments is not None: - * alignstr = [] + * fields.append(' '.join('%d-%d' % a for a in self.alignments())) */ - __pyx_t_1 = PyBytes_FromString(__pyx_f_3_sa_sym_tostring(__pyx_v_self->lhs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_f_3_sa_sym_tostring(__pyx_cur_scope->__pyx_v_self->lhs)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __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[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->f)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_self->f)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->f)); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_v_self->f)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->f)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self->f)); - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->e)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_self->e)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->e)); + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->scores)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_self->scores)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_self->scores)); + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_v_self->e)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->e)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self->e)); - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_67), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_INCREF(((PyObject *)__pyx_v_scorestrs)); - PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_scorestrs)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_scorestrs)); - __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __pyx_t_7 = PyList_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - PyList_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); - PyList_SET_ITEM(__pyx_t_7, 1, __pyx_t_5); + PyList_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyList_SET_ITEM(__pyx_t_2, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyList_SET_ITEM(__pyx_t_2, 3, __pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); - PyList_SET_ITEM(__pyx_t_7, 2, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - PyList_SET_ITEM(__pyx_t_7, 3, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); __pyx_t_1 = 0; + __pyx_t_3 = 0; + __pyx_t_4 = 0; __pyx_t_5 = 0; - __pyx_t_6 = 0; - __pyx_t_8 = 0; - __pyx_v_fields = __pyx_t_7; - __pyx_t_7 = 0; + __pyx_v_fields = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":213 - * scorestrs.append(str(self.cscores[i])) - * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), " ".join(scorestrs)] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":186 + * cdef unsigned i + * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), str(self.scores)] * if self.word_alignments is not None: # <<<<<<<<<<<<<< - * alignstr = [] - * for i from 0 <= i < len(self.word_alignments): - */ - __pyx_t_9 = (__pyx_v_self->word_alignments != Py_None); - if (__pyx_t_9) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":214 - * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), " ".join(scorestrs)] - * if self.word_alignments is not None: - * alignstr = [] # <<<<<<<<<<<<<< - * for i from 0 <= i < len(self.word_alignments): - * alignstr.append("%d-%d" % (self.word_alignments[i]/65536, self.word_alignments[i]%65536)) + * fields.append(' '.join('%d-%d' % a for a in self.alignments())) + * return ' ||| '.join(fields) */ - __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_v_alignstr = __pyx_t_7; - __pyx_t_7 = 0; + __pyx_t_6 = (__pyx_cur_scope->__pyx_v_self->word_alignments != Py_None); + if (__pyx_t_6) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":215 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":187 + * fields = [sym_tostring(self.lhs), str(self.f), str(self.e), str(self.scores)] * if self.word_alignments is not None: - * alignstr = [] - * for i from 0 <= i < len(self.word_alignments): # <<<<<<<<<<<<<< - * alignstr.append("%d-%d" % (self.word_alignments[i]/65536, self.word_alignments[i]%65536)) - * #for s,t in self.word_alignments: - */ - __pyx_t_7 = __pyx_v_self->word_alignments; - __Pyx_INCREF(__pyx_t_7); - __pyx_t_10 = PyObject_Length(__pyx_t_7); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_10; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":216 - * alignstr = [] - * for i from 0 <= i < len(self.word_alignments): - * alignstr.append("%d-%d" % (self.word_alignments[i]/65536, self.word_alignments[i]%65536)) # <<<<<<<<<<<<<< - * #for s,t in self.word_alignments: - * #alignstr.append("%d-%d" % (s,t)) - */ - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_self->word_alignments, __pyx_v_i, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_int_65536); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_self->word_alignments, __pyx_v_i, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyNumber_Remainder(__pyx_t_7, __pyx_int_65536); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __pyx_t_8 = 0; - __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_69), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __pyx_t_4 = PyList_Append(__pyx_v_alignstr, ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - } - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":219 - * #for s,t in self.word_alignments: - * #alignstr.append("%d-%d" % (s,t)) - * fields.append(" ".join(alignstr)) # <<<<<<<<<<<<<< + * fields.append(' '.join('%d-%d' % a for a in self.alignments())) # <<<<<<<<<<<<<< + * return ' ||| '.join(fields) * - * return " ||| ".join(fields) */ - __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_67), __pyx_n_s__join); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_INCREF(((PyObject *)__pyx_v_alignstr)); - PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_alignstr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_alignstr)); - __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __pyx_t_4 = PyList_Append(__pyx_v_fields, __pyx_t_8); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L5; + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_67), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = __pyx_pf_3_sa_4Rule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_7 = PyList_Append(__pyx_v_fields, __pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L3; } - __pyx_L5:; + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":221 - * fields.append(" ".join(alignstr)) - * - * return " ||| ".join(fields) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":188 + * if self.word_alignments is not None: + * fields.append(' '.join('%d-%d' % a for a in self.alignments())) + * return ' ||| '.join(fields) # <<<<<<<<<<<<<< * - * property scores: + * def alignments(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_18), __pyx_n_s__join); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); + __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_18), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(((PyObject *)__pyx_v_fields)); - PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_fields)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_fields)); __Pyx_GIVEREF(((PyObject *)__pyx_v_fields)); - __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __pyx_r = __pyx_t_6; - __pyx_t_6 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 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_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("_sa.Rule.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_scorestrs); __Pyx_XDECREF(__pyx_v_fields); - __Pyx_XDECREF(__pyx_v_alignstr); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } +static PyObject *__pyx_gb_3_sa_4Rule_14generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_6scores_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_6scores_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_3_sa_4Rule_13alignments(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_3_sa_4Rule_13alignments(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_6scores___get__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); + __Pyx_RefNannySetupContext("alignments (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_4Rule_12alignments(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":224 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":190 + * return ' ||| '.join(fields) * - * property scores: - * def __get__(self): # <<<<<<<<<<<<<< - * s = [None]*self.n_scores - * for i from 0 <= i < self.n_scores: + * def alignments(self): # <<<<<<<<<<<<<< + * for point in self.word_alignments: + * yield point/65536, point%65536 */ -static PyObject *__pyx_pf_3_sa_4Rule_6scores___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { - PyObject *__pyx_v_s = NULL; - long __pyx_v_i; +static PyObject *__pyx_pf_3_sa_4Rule_12alignments(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { + struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":225 - * property scores: - * def __get__(self): - * s = [None]*self.n_scores # <<<<<<<<<<<<<< - * for i from 0 <= i < self.n_scores: - * s[i] = self.cscores[i] - */ - __pyx_t_1 = PyList_New(1 * ((__pyx_v_self->n_scores<0) ? 0:__pyx_v_self->n_scores)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - { Py_ssize_t __pyx_temp; - for (__pyx_temp=0; __pyx_temp < __pyx_v_self->n_scores; __pyx_temp++) { - __Pyx_INCREF(Py_None); - PyList_SET_ITEM(__pyx_t_1, __pyx_temp, Py_None); - __Pyx_GIVEREF(Py_None); - } + __Pyx_RefNannySetupContext("alignments", 0); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *)__pyx_ptype_3_sa___pyx_scope_struct_7_alignments->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_7_alignments, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; } - __pyx_v_s = __pyx_t_1; - __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":226 - * def __get__(self): - * s = [None]*self.n_scores - * for i from 0 <= i < self.n_scores: # <<<<<<<<<<<<<< - * s[i] = self.cscores[i] - * return s - */ - __pyx_t_2 = __pyx_v_self->n_scores; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_2; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":227 - * s = [None]*self.n_scores - * for i from 0 <= i < self.n_scores: - * s[i] = self.cscores[i] # <<<<<<<<<<<<<< - * return s - * - */ - __pyx_t_1 = PyFloat_FromDouble((__pyx_v_self->cscores[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_SetItemInt(((PyObject *)__pyx_v_s), __pyx_v_i, __pyx_t_1, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_4Rule_14generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":228 - * for i from 0 <= i < self.n_scores: - * s[i] = self.cscores[i] - * return s # <<<<<<<<<<<<<< - * - * def __set__(self, s): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_s)); - __pyx_r = ((PyObject *)__pyx_v_s); - goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_sa.Rule.scores.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.Rule.alignments", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_s); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static int __pyx_pw_3_sa_4Rule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_s); /*proto*/ -static int __pyx_pw_3_sa_4Rule_6scores_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_s) { - int __pyx_r; +static PyObject *__pyx_gb_3_sa_4Rule_14generator3(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_6scores_2__set__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((PyObject *)__pyx_v_s)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":230 - * return s + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":191 * - * def __set__(self, s): # <<<<<<<<<<<<<< - * if self.cscores != NULL: - * free(self.cscores) + * def alignments(self): + * for point in self.word_alignments: # <<<<<<<<<<<<<< + * yield point/65536, point%65536 */ - -static int __pyx_pf_3_sa_4Rule_6scores_2__set__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, PyObject *__pyx_v_s) { - long __pyx_v_i; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - Py_ssize_t __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - float __pyx_t_5; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__set__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":231 - * - * def __set__(self, s): - * if self.cscores != NULL: # <<<<<<<<<<<<<< - * free(self.cscores) - * self.cscores = malloc(len(s)*sizeof(float)) - */ - __pyx_t_1 = (__pyx_v_self->cscores != NULL); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":232 - * def __set__(self, s): - * if self.cscores != NULL: - * free(self.cscores) # <<<<<<<<<<<<<< - * self.cscores = malloc(len(s)*sizeof(float)) - * self.n_scores = len(s) - */ - free(__pyx_v_self->cscores); - goto __pyx_L3; + if (PyList_CheckExact(__pyx_cur_scope->__pyx_v_self->word_alignments) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_self->word_alignments)) { + __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->word_alignments; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_self->word_alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } - __pyx_L3:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":233 - * if self.cscores != NULL: - * free(self.cscores) - * self.cscores = malloc(len(s)*sizeof(float)) # <<<<<<<<<<<<<< - * self.n_scores = len(s) - * for i from 0 <= i < self.n_scores: - */ - __pyx_t_2 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->cscores = ((float *)malloc((__pyx_t_2 * (sizeof(float))))); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":234 - * free(self.cscores) - * self.cscores = malloc(len(s)*sizeof(float)) - * self.n_scores = len(s) # <<<<<<<<<<<<<< - * for i from 0 <= i < self.n_scores: - * self.cscores[i] = s[i] - */ - __pyx_t_2 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->n_scores = __pyx_t_2; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":235 - * self.cscores = malloc(len(s)*sizeof(float)) - * self.n_scores = len(s) - * for i from 0 <= i < self.n_scores: # <<<<<<<<<<<<<< - * self.cscores[i] = s[i] - */ - __pyx_t_3 = __pyx_v_self->n_scores; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + for (;;) { + if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[7]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_point); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_point); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_cur_scope->__pyx_v_point = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":236 - * self.n_scores = len(s) - * for i from 0 <= i < self.n_scores: - * self.cscores[i] = s[i] # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rule.pxi":192 + * def alignments(self): + * for point in self.word_alignments: + * yield point/65536, point%65536 # <<<<<<<<<<<<<< */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_s, __pyx_v_i, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyNumber_Divide(__pyx_cur_scope->__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - (__pyx_v_self->cscores[__pyx_v_i]) = __pyx_t_5; + __pyx_t_5 = PyNumber_Remainder(__pyx_cur_scope->__pyx_v_point, __pyx_int_65536); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_4 = 0; + __pyx_t_5 = 0; + __pyx_r = ((PyObject *)__pyx_t_6); + __pyx_t_6 = 0; + __Pyx_XGIVEREF(__pyx_t_1); + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_cur_scope->__pyx_t_0 = 0; + __Pyx_XGOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - - __pyx_r = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("_sa.Rule.scores.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("alignments", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_3lhs_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_3lhs_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_3lhs___get__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_sa.pxd":8 - * - * cdef class Rule: - * cdef public int lhs # <<<<<<<<<<<<<< - * cdef readonly Phrase f, e - * cdef float *cscores - */ - -static PyObject *__pyx_pf_3_sa_4Rule_3lhs___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->lhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_sa.Rule.lhs.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_4Rule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_4Rule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_3lhs_2__set__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_3_sa_4Rule_3lhs_2__set__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->lhs = __pyx_t_1; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("_sa.Rule.lhs.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); - return __pyx_r; + return NULL; } /* Python wrapper */ @@ -25863,11 +25961,11 @@ static PyObject *__pyx_pw_3_sa_4Rule_1f_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "_sa.pxd":9 +/* "_sa.pxd":37 * cdef class Rule: - * cdef public int lhs + * cdef int lhs * cdef readonly Phrase f, e # <<<<<<<<<<<<<< - * cdef float *cscores + * cdef FeatureVector scores * cdef int n_scores */ @@ -25914,93 +26012,6 @@ static PyObject *__pyx_pf_3_sa_4Rule_1e___get__(struct __pyx_obj_3_sa_Rule *__py return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_4Rule_15word_alignments_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_4Rule_15word_alignments_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_15word_alignments___get__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "_sa.pxd":12 - * cdef float *cscores - * cdef int n_scores - * cdef public word_alignments # <<<<<<<<<<<<<< - * - * cdef char* sym_tostring(int sym) - */ - -static PyObject *__pyx_pf_3_sa_4Rule_15word_alignments___get__(struct __pyx_obj_3_sa_Rule *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->word_alignments); - __pyx_r = __pyx_v_self->word_alignments; - 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_3_sa_4Rule_15word_alignments_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_4Rule_15word_alignments_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_15word_alignments_2__set__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_3_sa_4Rule_15word_alignments_2__set__(struct __pyx_obj_3_sa_Rule *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->word_alignments); - __Pyx_DECREF(__pyx_v_self->word_alignments); - __pyx_v_self->word_alignments = __pyx_v_value; - - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_4Rule_15word_alignments_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_3_sa_4Rule_15word_alignments_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_4Rule_15word_alignments_4__del__(((struct __pyx_obj_3_sa_Rule *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_3_sa_4Rule_15word_alignments_4__del__(struct __pyx_obj_3_sa_Rule *__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->word_alignments); - __Pyx_DECREF(__pyx_v_self->word_alignments); - __pyx_v_self->word_alignments = Py_None; - - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":21 * int arr_len * @@ -26177,7 +26188,7 @@ static PyObject *__pyx_f_3_sa_free_trie_node(struct __pyx_t_3_sa__Trie_Node *__p * free(node.arr) * */ - __pyx_t_2 = __pyx_f_3_sa_free_trie_edge(__pyx_v_node->root); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_free_trie_edge(__pyx_v_node->root); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -26240,7 +26251,7 @@ static PyObject *__pyx_f_3_sa_free_trie_edge(struct __pyx_t_3_sa__Trie_Edge *__p * free_trie_edge(edge.bigger) * free_trie_edge(edge.smaller) */ - __pyx_t_2 = __pyx_f_3_sa_free_trie_node(__pyx_v_edge->node); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_free_trie_node(__pyx_v_edge->node); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -26251,7 +26262,7 @@ static PyObject *__pyx_f_3_sa_free_trie_edge(struct __pyx_t_3_sa__Trie_Edge *__p * free_trie_edge(edge.smaller) * */ - __pyx_t_2 = __pyx_f_3_sa_free_trie_edge(__pyx_v_edge->bigger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_free_trie_edge(__pyx_v_edge->bigger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -26262,7 +26273,7 @@ static PyObject *__pyx_f_3_sa_free_trie_edge(struct __pyx_t_3_sa__Trie_Edge *__p * * cdef _Trie_Node* trie_find(_Trie_Node* node, int val): */ - __pyx_t_2 = __pyx_f_3_sa_free_trie_edge(__pyx_v_edge->smaller); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_free_trie_edge(__pyx_v_edge->smaller); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L3; @@ -26688,7 +26699,7 @@ static PyObject *__pyx_f_3_sa_trie_node_to_map(struct __pyx_t_3_sa__Trie_Node *_ * free(arr.arr) * arr.arr = malloc(node.arr_len * sizeof(int)) */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_v_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); __pyx_t_3 = 0; @@ -26745,7 +26756,7 @@ static PyObject *__pyx_f_3_sa_trie_node_to_map(struct __pyx_t_3_sa__Trie_Node *_ * trie_edge_to_map(node.root, result, prefix, include_zeros) * */ - if (PyObject_SetItem(__pyx_v_result, __pyx_v_prefix, ((PyObject *)__pyx_v_arr)) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetItem(__pyx_v_result, __pyx_v_prefix, ((PyObject *)__pyx_v_arr)) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; @@ -26757,7 +26768,7 @@ static PyObject *__pyx_f_3_sa_trie_node_to_map(struct __pyx_t_3_sa__Trie_Node *_ * * cdef trie_edge_to_map(_Trie_Edge* edge, result, prefix, int include_zeros): */ - __pyx_t_3 = __pyx_f_3_sa_trie_edge_to_map(__pyx_v_node->root, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_edge_to_map(__pyx_v_node->root, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -26811,7 +26822,7 @@ static PyObject *__pyx_f_3_sa_trie_edge_to_map(struct __pyx_t_3_sa__Trie_Edge *_ * trie_edge_to_map(edge.bigger, result, prefix, include_zeros) * prefix = prefix + (edge.val,) */ - __pyx_t_2 = __pyx_f_3_sa_trie_edge_to_map(__pyx_v_edge->smaller, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_trie_edge_to_map(__pyx_v_edge->smaller, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -26822,7 +26833,7 @@ static PyObject *__pyx_f_3_sa_trie_edge_to_map(struct __pyx_t_3_sa__Trie_Edge *_ * prefix = prefix + (edge.val,) * trie_node_to_map(edge.node, result, prefix, include_zeros) */ - __pyx_t_2 = __pyx_f_3_sa_trie_edge_to_map(__pyx_v_edge->bigger, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_trie_edge_to_map(__pyx_v_edge->bigger, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -26833,14 +26844,14 @@ static PyObject *__pyx_f_3_sa_trie_edge_to_map(struct __pyx_t_3_sa__Trie_Edge *_ * trie_node_to_map(edge.node, result, prefix, include_zeros) * */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_edge->val); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_edge->val); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 106; __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[12]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 106; __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 = PyNumber_Add(__pyx_v_prefix, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Add(__pyx_v_prefix, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_v_prefix); @@ -26854,7 +26865,7 @@ static PyObject *__pyx_f_3_sa_trie_edge_to_map(struct __pyx_t_3_sa__Trie_Edge *_ * * cdef class TrieMap: */ - __pyx_t_2 = __pyx_f_3_sa_trie_node_to_map(__pyx_v_edge->node, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_trie_node_to_map(__pyx_v_edge->node, __pyx_v_result, __pyx_v_prefix, __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L3; @@ -26900,18 +26911,18 @@ static int __pyx_pw_3_sa_7TrieMap_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[12]; __pyx_lineno = 114; __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[11]; __pyx_lineno = 114; __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_alphabet_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_alphabet_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_alphabet_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_alphabet_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 114; __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[12]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.TrieMap.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -27022,7 +27033,7 @@ static void __pyx_pf_3_sa_7TrieMap_2__dealloc__(struct __pyx_obj_3_sa_TrieMap *_ * free(self.root) * */ - __pyx_t_3 = __pyx_f_3_sa_free_trie_node((__pyx_v_self->root[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_free_trie_node((__pyx_v_self->root[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L5; @@ -27088,7 +27099,7 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_4insert(struct __pyx_obj_3_sa_TrieMap *_ * p = malloc(l*sizeof(int)) * for i from 0 <= i < l: */ - __pyx_t_1 = PyObject_Length(__pyx_v_pattern); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_pattern); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_l = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":132 @@ -27117,9 +27128,9 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_4insert(struct __pyx_obj_3_sa_TrieMap *_ * self._insert(p,l) * free(p) */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pattern, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pattern, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; (__pyx_v_p[__pyx_v_i]) = __pyx_t_4; } @@ -27281,7 +27292,7 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_6contains(struct __pyx_obj_3_sa_TrieMap * p = malloc(l*sizeof(int)) * for i from 0 <= i < l: */ - __pyx_t_1 = PyObject_Length(__pyx_v_pattern); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_pattern); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_l = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":154 @@ -27310,9 +27321,9 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_6contains(struct __pyx_obj_3_sa_TrieMap * node = self._contains(p,l) * free(p) */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pattern, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_pattern, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; (__pyx_v_p[__pyx_v_i]) = __pyx_t_4; } @@ -27353,7 +27364,7 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_6contains(struct __pyx_obj_3_sa_TrieMap * return True */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -27370,7 +27381,7 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_6contains(struct __pyx_obj_3_sa_TrieMap * cdef _Trie_Node* _contains(self, int* pattern, int pattern_len): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -27519,7 +27530,7 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_8toMap(struct __pyx_obj_3_sa_TrieMap *__ * include_zeros=1 * else: */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_flag); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_flag); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":178 @@ -27552,7 +27563,7 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_8toMap(struct __pyx_obj_3_sa_TrieMap *__ * for i from 0 <= i < self.V: * if self.root[i] != NULL: */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_v_result = __pyx_t_2; __pyx_t_2 = 0; @@ -27584,14 +27595,14 @@ static PyObject *__pyx_pf_3_sa_7TrieMap_8toMap(struct __pyx_obj_3_sa_TrieMap *__ * return result * */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __pyx_f_3_sa_trie_node_to_map((__pyx_v_self->root[__pyx_v_i]), ((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_4), __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_f_3_sa_trie_node_to_map((__pyx_v_self->root[__pyx_v_i]), ((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_4), __pyx_v_include_zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -27726,7 +27737,7 @@ static int __pyx_pw_3_sa_14Precomputation_1__cinit__(PyObject *__pyx_v_self, PyO } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 200; __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[11]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -27755,7 +27766,7 @@ static int __pyx_pw_3_sa_14Precomputation_1__cinit__(PyObject *__pyx_v_self, PyO } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.Precomputation.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -27786,7 +27797,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.precompute_secondary_rank = precompute_secondary_rank * self.max_length = max_length */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_precompute_rank); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_precompute_rank); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->precompute_rank = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":205 @@ -27796,7 +27807,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.max_length = max_length * self.max_nonterminals = max_nonterminals */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_precompute_secondary_rank); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_precompute_secondary_rank); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->precompute_secondary_rank = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":206 @@ -27806,7 +27817,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.max_nonterminals = max_nonterminals * self.train_max_initial_size = train_max_initial_size */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_max_length); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_max_length); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->max_length = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":207 @@ -27816,7 +27827,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.train_max_initial_size = train_max_initial_size * self.train_min_gap_size = train_min_gap_size */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_max_nonterminals); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_max_nonterminals); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->max_nonterminals = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":208 @@ -27826,7 +27837,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.train_min_gap_size = train_min_gap_size * if from_binary: */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_train_max_initial_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_train_max_initial_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->train_max_initial_size = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":209 @@ -27836,7 +27847,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * if from_binary: * self.read_binary(from_binary) */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_train_min_gap_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_train_min_gap_size); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->train_min_gap_size = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":210 @@ -27846,7 +27857,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.read_binary(from_binary) * elif from_stats: */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_binary); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_binary); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":211 @@ -27856,14 +27867,14 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * elif from_stats: * self.precompute(from_stats, fsarray) */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read_binary); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read_binary); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_from_binary); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_from_binary); __Pyx_GIVEREF(__pyx_v_from_binary); - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -27878,7 +27889,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * self.precompute(from_stats, fsarray) * */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_stats); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_stats); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":213 @@ -27888,9 +27899,9 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom * * */ - __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__precompute); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__precompute); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_from_stats); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_from_stats); @@ -27898,7 +27909,7 @@ static int __pyx_pf_3_sa_14Precomputation___cinit__(struct __pyx_obj_3_sa_Precom __Pyx_INCREF(__pyx_v_fsarray); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_fsarray); __Pyx_GIVEREF(__pyx_v_fsarray); - __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -27928,7 +27939,7 @@ static PyObject *__pyx_pw_3_sa_14Precomputation_3read_binary(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_binary (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -28029,7 +28040,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_2read_binary(struct __pyx_obj_3_ * self.precomputed_collocations = self.read_map(f) * fclose(f) */ - __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->read_map(__pyx_v_self, __pyx_v_f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->read_map(__pyx_v_self, __pyx_v_f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->precomputed_index); @@ -28044,7 +28055,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_2read_binary(struct __pyx_obj_3_ * fclose(f) * */ - __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->read_map(__pyx_v_self, __pyx_v_f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->read_map(__pyx_v_self, __pyx_v_f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->precomputed_collocations); @@ -28081,7 +28092,7 @@ static PyObject *__pyx_pw_3_sa_14Precomputation_5write_binary(PyObject *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_binary (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -28185,7 +28196,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_4write_binary(struct __pyx_obj_3 */ __pyx_t_1 = __pyx_v_self->precomputed_index; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->write_map(__pyx_v_self, __pyx_t_1, __pyx_v_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->write_map(__pyx_v_self, __pyx_t_1, __pyx_v_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; @@ -28199,7 +28210,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_4write_binary(struct __pyx_obj_3 */ __pyx_t_2 = __pyx_v_self->precomputed_collocations; __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->write_map(__pyx_v_self, __pyx_t_2, __pyx_v_f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_Precomputation *)__pyx_v_self->__pyx_vtab)->write_map(__pyx_v_self, __pyx_t_2, __pyx_v_f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -28264,7 +28275,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ * fwrite(&(N), sizeof(int), 1, f) * for pattern, val in m.iteritems(): */ - __pyx_t_1 = PyObject_Length(__pyx_v_m); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_m); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_N = __pyx_t_1; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":249 @@ -28286,9 +28297,9 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ __pyx_t_1 = 0; if (unlikely(__pyx_v_m == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); - {__pyx_filename = __pyx_f[12]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[11]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_m, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_dict_iterator(__pyx_v_m, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_3), (&__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = __pyx_t_5; @@ -28296,7 +28307,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ while (1) { __pyx_t_7 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_3, &__pyx_t_1, &__pyx_t_5, &__pyx_t_6, NULL, __pyx_t_4); if (unlikely(__pyx_t_7 == 0)) break; - if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_GOTREF(__pyx_t_6); __Pyx_XDECREF(__pyx_v_pattern); @@ -28313,7 +28324,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ * fwrite(&(N), sizeof(int), 1, f) * for word_id in pattern: */ - __pyx_t_8 = PyObject_Length(__pyx_v_pattern); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Length(__pyx_v_pattern); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_N = __pyx_t_8; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":252 @@ -28336,7 +28347,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ __pyx_t_6 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_6); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { - __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; } @@ -28346,21 +28357,21 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_5 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_6)) { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_6)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_8); __Pyx_INCREF(__pyx_t_5); __pyx_t_8++; #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_6, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_5 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_5)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -28377,7 +28388,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ * fwrite(&(i), sizeof(int), 1, f) * arr = val */ - __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_v_word_id); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_v_word_id); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_i = __pyx_t_7; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":255 @@ -28398,7 +28409,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_write_map(CYTHON_UNUSED struct __ * arr.write_handle(f) * */ - if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_val) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_val, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_INCREF(__pyx_v_val); __Pyx_XDECREF(((PyObject *)__pyx_v_arr)); __pyx_v_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_v_val); @@ -28467,7 +28478,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_read_map(CYTHON_UNUSED struct __p * fread(&(N), sizeof(int), 1, f) * for j from 0 <= j < N: */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_m = __pyx_t_1; __pyx_t_1 = 0; @@ -28537,14 +28548,14 @@ static PyObject *__pyx_f_3_sa_14Precomputation_read_map(CYTHON_UNUSED struct __p * arr = IntList() * arr.read_handle(f) */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_word_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_word_id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_key), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_v_key), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_key)); @@ -28559,7 +28570,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_read_map(CYTHON_UNUSED struct __p * arr.read_handle(f) * m[key] = arr */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_XDECREF(((PyObject *)__pyx_v_arr)); __pyx_v_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); @@ -28581,7 +28592,7 @@ static PyObject *__pyx_f_3_sa_14Precomputation_read_map(CYTHON_UNUSED struct __p * return m * */ - if (PyDict_SetItem(((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_key), ((PyObject *)__pyx_v_arr)) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(((PyObject *)__pyx_v_m), ((PyObject *)__pyx_v_key), ((PyObject *)__pyx_v_arr)) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":275 @@ -28640,11 +28651,11 @@ static PyObject *__pyx_pw_3_sa_14Precomputation_7precompute(PyObject *__pyx_v_se case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sarray)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("precompute", 1, 2, 2, 1); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("precompute", 1, 2, 2, 1); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "precompute") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "precompute") < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -28657,13 +28668,13 @@ static PyObject *__pyx_pw_3_sa_14Precomputation_7precompute(PyObject *__pyx_v_se } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("precompute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("precompute", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[11]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.Precomputation.precompute", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sarray), __pyx_ptype_3_sa_SuffixArray, 1, "sarray", 0))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sarray), __pyx_ptype_3_sa_SuffixArray, 1, "sarray", 0))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 278; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_3_sa_14Precomputation_6precompute(((struct __pyx_obj_3_sa_Precomputation *)__pyx_v_self), __pyx_v_stats, __pyx_v_sarray); goto __pyx_L0; __pyx_L1_error:; @@ -28787,16 +28798,16 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s */ __pyx_t_1 = __pyx_v_darray->id2word; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 287; __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[12]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 287; __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[12]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 287; __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(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieMap)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieMap)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_frequent_patterns = ((struct __pyx_obj_3_sa_TrieMap *)__pyx_t_1); @@ -28811,16 +28822,16 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s */ __pyx_t_1 = __pyx_v_darray->id2word; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 288; __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[12]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 288; __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[12]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 288; __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(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieMap)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieMap)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_super_frequent_patterns = ((struct __pyx_obj_3_sa_TrieMap *)__pyx_t_1); @@ -28835,16 +28846,16 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s */ __pyx_t_1 = __pyx_v_darray->id2word; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 289; __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[12]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 289; __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[12]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 289; __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(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieMap)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieMap)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_collocations = ((struct __pyx_obj_3_sa_TrieMap *)__pyx_t_1); @@ -28857,7 +28868,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * J_set = set() * J2_set = set() */ - __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_I_set = __pyx_t_1; __pyx_t_1 = 0; @@ -28869,7 +28880,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * J2_set = set() * IJ_set = set() */ - __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_J_set = __pyx_t_1; __pyx_t_1 = 0; @@ -28881,7 +28892,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * IJ_set = set() * pattern_rank = {} */ - __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_J2_set = __pyx_t_1; __pyx_t_1 = 0; @@ -28893,7 +28904,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * pattern_rank = {} * */ - __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 294; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_IJ_set = __pyx_t_1; __pyx_t_1 = 0; @@ -28905,7 +28916,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * logger.info("Precomputing frequent intersections") */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_pattern_rank = __pyx_t_1; __pyx_t_1 = 0; @@ -28917,12 +28928,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * cdef float start_time = monitor_cpu() * */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 297; __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_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_73), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_73), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -28958,7 +28969,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __pyx_t_3 = __pyx_v_stats; __Pyx_INCREF(__pyx_t_3); __pyx_t_2 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_stats); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_stats); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; } @@ -28968,21 +28979,21 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_5 = __pyx_t_4(__pyx_t_3); if (unlikely(!__pyx_t_5)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -28998,7 +29009,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(size != 3)) { if (size > 3) __Pyx_RaiseTooManyValuesError(3); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -29014,15 +29025,15 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __Pyx_INCREF(__pyx_t_7); __Pyx_INCREF(__pyx_t_8); #else - __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } else { Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; @@ -29032,7 +29043,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __Pyx_GOTREF(__pyx_t_7); index = 2; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_8); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 3) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_10 = NULL; __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; goto __pyx_L6_unpacking_done; @@ -29040,7 +29051,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_10 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } __Pyx_XDECREF(__pyx_v__); @@ -29055,7 +29066,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF(__pyx_v_rank); __pyx_v_rank = __pyx_t_1; - __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_5; @@ -29068,12 +29079,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * break * max_pattern_len = max(max_pattern_len, len(phrase)) */ - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->precompute_rank); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->precompute_rank); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = PyObject_RichCompare(__pyx_v_rank, __pyx_t_5, Py_GE); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_RichCompare(__pyx_v_rank, __pyx_t_5, Py_GE); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_11) { @@ -29096,7 +29107,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * frequent_patterns.insert(phrase) * I_set.add(phrase) */ - __pyx_t_12 = PyObject_Length(__pyx_v_phrase); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = PyObject_Length(__pyx_v_phrase); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_13 = __pyx_v_max_pattern_len; if ((__pyx_t_12 > __pyx_t_13)) { __pyx_t_14 = __pyx_t_12; @@ -29112,14 +29123,14 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * I_set.add(phrase) * pattern_rank[phrase] = rank */ - __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_frequent_patterns), __pyx_n_s__insert); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_frequent_patterns), __pyx_n_s__insert); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(__pyx_v_phrase); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_phrase); __Pyx_GIVEREF(__pyx_v_phrase); - __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; @@ -29132,7 +29143,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * pattern_rank[phrase] = rank * if rank < self.precompute_secondary_rank: */ - __pyx_t_15 = PySet_Add(__pyx_v_I_set, __pyx_v_phrase); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PySet_Add(__pyx_v_I_set, __pyx_v_phrase); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":307 * frequent_patterns.insert(phrase) @@ -29141,7 +29152,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * if rank < self.precompute_secondary_rank: * super_frequent_patterns.insert(phrase) */ - if (PyDict_SetItem(((PyObject *)__pyx_v_pattern_rank), __pyx_v_phrase, __pyx_v_rank) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(((PyObject *)__pyx_v_pattern_rank), __pyx_v_phrase, __pyx_v_rank) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":308 * I_set.add(phrase) @@ -29150,12 +29161,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * super_frequent_patterns.insert(phrase) * J_set.add(phrase) */ - __pyx_t_7 = PyInt_FromLong(__pyx_v_self->precompute_secondary_rank); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyInt_FromLong(__pyx_v_self->precompute_secondary_rank); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_rank, __pyx_t_7, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_RichCompare(__pyx_v_rank, __pyx_t_7, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (__pyx_t_11) { @@ -29166,14 +29177,14 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * J_set.add(phrase) * */ - __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_super_frequent_patterns), __pyx_n_s__insert); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_super_frequent_patterns), __pyx_n_s__insert); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(__pyx_v_phrase); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_phrase); __Pyx_GIVEREF(__pyx_v_phrase); - __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; @@ -29186,7 +29197,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * queue = IntList(increment=1000) */ - __pyx_t_15 = PySet_Add(__pyx_v_J_set, __pyx_v_phrase); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PySet_Add(__pyx_v_J_set, __pyx_v_phrase); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L8; } __pyx_L8:; @@ -29202,10 +29213,10 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * logger.info(" Computing inverted indexes...") */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__increment), __pyx_int_1000) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__increment), __pyx_int_1000) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_queue = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); @@ -29218,12 +29229,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * N = len(data) * for i from 0 <= i < N: */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 314; __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_75), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_75), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -29235,7 +29246,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * for i from 0 <= i < N: * sa_word_id = data.arr[i] */ - __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_data)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_data)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_N = __pyx_t_2; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":316 @@ -29345,7 +29356,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * logger.info(" Computing collocations...") */ - __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } @@ -29361,12 +29372,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * N = len(queue) * ptr1 = 0 */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 329; __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_77), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_77), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -29378,7 +29389,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * ptr1 = 0 * sent_count = 0 */ - __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_queue)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(((PyObject *)__pyx_v_queue)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_N = __pyx_t_2; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":331 @@ -29587,7 +29598,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * trie_node_data_append(node, i2) * if super_frequent_patterns._contains(data.arr+i2, l2) != NULL: */ - __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 350; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -29598,7 +29609,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * if super_frequent_patterns._contains(data.arr+i2, l2) != NULL: * if super_frequent_patterns._contains(data.arr+i1, l1) != NULL: */ - __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -29838,7 +29849,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * trie_node_data_append(node, i2) * trie_node_data_append(node, i3) */ - __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -29849,7 +29860,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * trie_node_data_append(node, i3) * ptr3 = ptr3 + 2 */ - __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -29860,7 +29871,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * ptr3 = ptr3 + 2 * ptr2 = ptr2 + 2 */ - __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_f_3_sa_trie_node_data_append(__pyx_v_node, __pyx_v_i3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L30; @@ -29936,14 +29947,14 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * ptr1 = ptr1 + 1 * */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__debug); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__debug); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyInt_FromLong(__pyx_v_sent_count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_sent_count); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_kp_s_78)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_kp_s_78)); @@ -29951,7 +29962,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; @@ -29979,16 +29990,16 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * self.precomputed_index = frequent_patterns.toMap(True) * */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_collocations), __pyx_n_s__toMap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_collocations), __pyx_n_s__toMap); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -30005,16 +30016,16 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * x = 0 */ - __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_frequent_patterns), __pyx_n_s__toMap); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_frequent_patterns), __pyx_n_s__toMap); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 387; __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[12]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 387; __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_t_8, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -30041,7 +30052,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * for pattern2 in J_set: * if len(pattern1) + len(pattern2) + 1 < self.max_length: */ - __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_J_set)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_J_set)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; for (;;) { @@ -30050,7 +30061,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30067,7 +30078,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * if len(pattern1) + len(pattern2) + 1 < self.max_length: * combined_pattern = pattern1 + (-1,) + pattern2 */ - __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_J_set)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_J_set)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_20 = Py_TYPE(__pyx_t_3)->tp_iternext; for (;;) { @@ -30076,7 +30087,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_8)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30093,8 +30104,8 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * combined_pattern = pattern1 + (-1,) + pattern2 * J2_set.add(combined_pattern) */ - __pyx_t_2 = PyObject_Length(__pyx_v_pattern1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_14 = PyObject_Length(__pyx_v_pattern2); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_v_pattern1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PyObject_Length(__pyx_v_pattern2); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_19 = (((__pyx_t_2 + __pyx_t_14) + 1) < __pyx_v_self->max_length); if (__pyx_t_19) { @@ -30105,9 +30116,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * J2_set.add(combined_pattern) * */ - __pyx_t_8 = PyNumber_Add(__pyx_v_pattern1, ((PyObject *)__pyx_k_tuple_79)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Add(__pyx_v_pattern1, ((PyObject *)__pyx_k_tuple_79)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_v_pattern2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_v_pattern2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_v_combined_pattern); @@ -30121,7 +30132,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * for pattern1 in I_set: */ - __pyx_t_15 = PySet_Add(__pyx_v_J2_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PySet_Add(__pyx_v_J2_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L40; } __pyx_L40:; @@ -30137,7 +30148,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * for pattern2 in I_set: * x = x+1 */ - __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_I_set)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_I_set)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; for (;;) { @@ -30146,7 +30157,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30163,7 +30174,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * x = x+1 * if len(pattern1) + len(pattern2) + 1 <= self.max_length: */ - __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_I_set)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_I_set)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_20 = Py_TYPE(__pyx_t_3)->tp_iternext; for (;;) { @@ -30172,7 +30183,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_7)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30189,7 +30200,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * if len(pattern1) + len(pattern2) + 1 <= self.max_length: * combined_pattern = pattern1 + (-1,) + pattern2 */ - __pyx_t_7 = PyNumber_Add(__pyx_v_x, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_v_x, __pyx_int_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_v_x); __pyx_v_x = __pyx_t_7; @@ -30202,8 +30213,8 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * combined_pattern = pattern1 + (-1,) + pattern2 * IJ_set.add(combined_pattern) */ - __pyx_t_14 = PyObject_Length(__pyx_v_pattern1); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Length(__pyx_v_pattern2); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PyObject_Length(__pyx_v_pattern1); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_v_pattern2); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_19 = (((__pyx_t_14 + __pyx_t_2) + 1) <= __pyx_v_self->max_length); if (__pyx_t_19) { @@ -30214,9 +30225,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * IJ_set.add(combined_pattern) * */ - __pyx_t_7 = PyNumber_Add(__pyx_v_pattern1, ((PyObject *)__pyx_k_tuple_80)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_v_pattern1, ((PyObject *)__pyx_k_tuple_80)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyNumber_Add(__pyx_t_7, __pyx_v_pattern2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Add(__pyx_t_7, __pyx_v_pattern2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_XDECREF(__pyx_v_combined_pattern); @@ -30230,7 +30241,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * for pattern1 in I_set: */ - __pyx_t_15 = PySet_Add(__pyx_v_IJ_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PySet_Add(__pyx_v_IJ_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L45; } __pyx_L45:; @@ -30246,7 +30257,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * for pattern2 in J2_set: * x = x+2 */ - __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_I_set)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_v_I_set)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; for (;;) { @@ -30255,7 +30266,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 403; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30272,7 +30283,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * x = x+2 * if len(pattern1) + len(pattern2) + 1<= self.max_length: */ - __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_J2_set)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetIter(((PyObject *)__pyx_v_J2_set)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_20 = Py_TYPE(__pyx_t_3)->tp_iternext; for (;;) { @@ -30281,7 +30292,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_8)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30298,7 +30309,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * if len(pattern1) + len(pattern2) + 1<= self.max_length: * combined_pattern = pattern1 + (-1,) + pattern2 */ - __pyx_t_8 = PyNumber_Add(__pyx_v_x, __pyx_int_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Add(__pyx_v_x, __pyx_int_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_v_x); __pyx_v_x = __pyx_t_8; @@ -30311,8 +30322,8 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * combined_pattern = pattern1 + (-1,) + pattern2 * IJ_set.add(combined_pattern) */ - __pyx_t_2 = PyObject_Length(__pyx_v_pattern1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_14 = PyObject_Length(__pyx_v_pattern2); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_v_pattern1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PyObject_Length(__pyx_v_pattern2); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_19 = (((__pyx_t_2 + __pyx_t_14) + 1) <= __pyx_v_self->max_length); if (__pyx_t_19) { @@ -30323,9 +30334,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * IJ_set.add(combined_pattern) * combined_pattern = pattern2 + (-1,) + pattern1 */ - __pyx_t_8 = PyNumber_Add(__pyx_v_pattern1, ((PyObject *)__pyx_k_tuple_81)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Add(__pyx_v_pattern1, ((PyObject *)__pyx_k_tuple_81)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_v_pattern2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_t_8, __pyx_v_pattern2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_XDECREF(__pyx_v_combined_pattern); @@ -30339,7 +30350,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * combined_pattern = pattern2 + (-1,) + pattern1 * IJ_set.add(combined_pattern) */ - __pyx_t_15 = PySet_Add(__pyx_v_IJ_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PySet_Add(__pyx_v_IJ_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":409 * combined_pattern = pattern1 + (-1,) + pattern2 @@ -30348,9 +30359,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * IJ_set.add(combined_pattern) * */ - __pyx_t_7 = PyNumber_Add(__pyx_v_pattern2, ((PyObject *)__pyx_k_tuple_82)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_v_pattern2, ((PyObject *)__pyx_k_tuple_82)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyNumber_Add(__pyx_t_7, __pyx_v_pattern1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Add(__pyx_t_7, __pyx_v_pattern1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_v_combined_pattern); @@ -30364,7 +30375,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * N = len(pattern_rank) */ - __pyx_t_15 = PySet_Add(__pyx_v_IJ_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PySet_Add(__pyx_v_IJ_set, __pyx_v_combined_pattern); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L50; } __pyx_L50:; @@ -30380,7 +30391,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * cost_by_rank = IntList(initial_len=N) * count_by_rank = IntList(initial_len=N) */ - __pyx_t_14 = PyDict_Size(((PyObject *)__pyx_v_pattern_rank)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PyDict_Size(((PyObject *)__pyx_v_pattern_rank)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_N = __pyx_t_14; /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":413 @@ -30390,13 +30401,13 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * count_by_rank = IntList(initial_len=N) * for pattern, arr in self.precomputed_collocations.iteritems(): */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_3 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_cost_by_rank = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); @@ -30409,13 +30420,13 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * for pattern, arr in self.precomputed_collocations.iteritems(): * if pattern not in IJ_set: */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_count_by_rank = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); @@ -30431,9 +30442,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __pyx_t_14 = 0; if (unlikely(__pyx_v_self->precomputed_collocations == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); - {__pyx_filename = __pyx_f[12]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[11]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_self->precomputed_collocations, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_2), (&__pyx_t_13)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_dict_iterator(__pyx_v_self->precomputed_collocations, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_2), (&__pyx_t_13)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_3; @@ -30441,7 +30452,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s while (1) { __pyx_t_16 = __Pyx_dict_iter_next(__pyx_t_1, __pyx_t_2, &__pyx_t_14, &__pyx_t_3, &__pyx_t_8, NULL, __pyx_t_13); if (unlikely(__pyx_t_16 == 0)) break; - if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_GOTREF(__pyx_t_8); __Pyx_XDECREF(__pyx_v_pattern); @@ -30458,7 +30469,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * s = "" * for word_id in pattern: */ - __pyx_t_19 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_IJ_set), __pyx_v_pattern))); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_IJ_set), __pyx_v_pattern))); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_19) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":417 @@ -30483,7 +30494,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __pyx_t_8 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_8); __pyx_t_12 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_12 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = Py_TYPE(__pyx_t_8)->tp_iternext; } @@ -30493,21 +30504,21 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_12); __Pyx_INCREF(__pyx_t_3); __pyx_t_12++; #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_8)) { if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_8)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_12); __Pyx_INCREF(__pyx_t_3); __pyx_t_12++; #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PySequence_ITEM(__pyx_t_8, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_3 = __pyx_t_4(__pyx_t_8); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30524,9 +30535,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * s = s + "X " * else: */ - __pyx_t_3 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_19) { @@ -30537,7 +30548,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * else: * s = s + darray.id2word[word_id] + " " */ - __pyx_t_3 = PyNumber_Add(__pyx_v_s, ((PyObject *)__pyx_kp_s_83)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Add(__pyx_v_s, ((PyObject *)__pyx_kp_s_83)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_v_s); __pyx_v_s = __pyx_t_3; @@ -30553,12 +30564,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * logger.warn("ERROR: unexpected pattern %s in set of precomputed collocations", s) * else: */ - __pyx_t_3 = PyObject_GetItem(__pyx_v_darray->id2word, __pyx_v_word_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetItem(__pyx_v_darray->id2word, __pyx_v_word_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_7 = PyNumber_Add(__pyx_v_s, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_v_s, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_s_67)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_s_67)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_v_s); @@ -30576,12 +30587,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * else: * chunk = () */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__warn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__warn); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_INCREF(((PyObject *)__pyx_kp_s_84)); PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_kp_s_84)); @@ -30589,7 +30600,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __Pyx_INCREF(__pyx_v_s); PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_s); __Pyx_GIVEREF(__pyx_v_s); - __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; @@ -30640,7 +30651,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __pyx_t_7 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_7); __pyx_t_12 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_12 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = Py_TYPE(__pyx_t_7)->tp_iternext; } @@ -30650,21 +30661,21 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_8 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_12); __Pyx_INCREF(__pyx_t_8); __pyx_t_12++; #else - __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_7)) { if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_7)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_12); __Pyx_INCREF(__pyx_t_8); __pyx_t_12++; #else - __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_8 = PySequence_ITEM(__pyx_t_7, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { __pyx_t_8 = __pyx_t_4(__pyx_t_7); if (unlikely(!__pyx_t_8)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30681,9 +30692,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * max_rank = max(max_rank, pattern_rank[chunk]) * arity = arity + 1 */ - __pyx_t_8 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 429; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; if (__pyx_t_19) { @@ -30694,27 +30705,27 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * arity = arity + 1 * chunk = () */ - __pyx_t_8 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_pattern_rank), ((PyObject *)__pyx_v_chunk)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_pattern_rank), ((PyObject *)__pyx_v_chunk)); if (!__pyx_t_8) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_16 = __pyx_v_max_rank; - __pyx_t_5 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_8, __pyx_t_5, Py_GT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_RichCompare(__pyx_t_8, __pyx_t_5, Py_GT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_19) { __Pyx_INCREF(__pyx_t_8); __pyx_t_3 = __pyx_t_8; } else { - __pyx_t_6 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = __pyx_t_6; __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_v_max_rank = __pyx_t_16; @@ -30725,7 +30736,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * chunk = () * else: */ - __pyx_t_3 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_v_arity); __pyx_v_arity = __pyx_t_3; @@ -30752,12 +30763,12 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * max_rank = max(max_rank, pattern_rank[chunk]) * cost_by_rank.arr[max_rank] = cost_by_rank.arr[max_rank] + (4*len(arr)) */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_word_id); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_word_id); __Pyx_GIVEREF(__pyx_v_word_id); - __pyx_t_8 = PyNumber_Add(((PyObject *)__pyx_v_chunk), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyNumber_Add(((PyObject *)__pyx_v_chunk), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_8)); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_chunk)); @@ -30775,27 +30786,27 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * cost_by_rank.arr[max_rank] = cost_by_rank.arr[max_rank] + (4*len(arr)) * count_by_rank.arr[max_rank] = count_by_rank.arr[max_rank] + (len(arr)/(arity+1)) */ - __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_pattern_rank), ((PyObject *)__pyx_v_chunk)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_pattern_rank), ((PyObject *)__pyx_v_chunk)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_16 = __pyx_v_max_rank; - __pyx_t_3 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_7, __pyx_t_3, Py_GT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_RichCompare(__pyx_t_7, __pyx_t_3, Py_GT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (__pyx_t_19) { __Pyx_INCREF(__pyx_t_7); __pyx_t_8 = __pyx_t_7; } else { - __pyx_t_6 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_t_16); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = __pyx_t_6; __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_v_max_rank = __pyx_t_16; @@ -30806,7 +30817,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * count_by_rank.arr[max_rank] = count_by_rank.arr[max_rank] + (len(arr)/(arity+1)) * */ - __pyx_t_12 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} (__pyx_v_cost_by_rank->arr[__pyx_v_max_rank]) = ((__pyx_v_cost_by_rank->arr[__pyx_v_max_rank]) + (4 * __pyx_t_12)); /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":437 @@ -30816,22 +30827,22 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * cumul_cost = 0 */ - __pyx_t_8 = PyInt_FromLong((__pyx_v_count_by_rank->arr[__pyx_v_max_rank])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong((__pyx_v_count_by_rank->arr[__pyx_v_max_rank])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_12 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_16 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_16 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; (__pyx_v_count_by_rank->arr[__pyx_v_max_rank]) = __pyx_t_16; } @@ -30876,9 +30887,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * cumul_count = cumul_count + count_by_rank.arr[i] * logger.debug("RANK %d\tCOUNT, COST: %d %d\tCUMUL: %d, %d", i, count_by_rank.arr[i], cost_by_rank.arr[i], cumul_count, cumul_cost) */ - __pyx_t_1 = PyInt_FromLong((__pyx_v_cost_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong((__pyx_v_cost_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyNumber_Add(__pyx_v_cumul_cost, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_v_cumul_cost, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_v_cumul_cost); @@ -30892,9 +30903,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * logger.debug("RANK %d\tCOUNT, COST: %d %d\tCUMUL: %d, %d", i, count_by_rank.arr[i], cost_by_rank.arr[i], cumul_count, cumul_cost) * */ - __pyx_t_6 = PyInt_FromLong((__pyx_v_count_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong((__pyx_v_count_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_1 = PyNumber_Add(__pyx_v_cumul_count, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Add(__pyx_v_cumul_count, __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_v_cumul_count); @@ -30908,18 +30919,18 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * num_found_patterns = len(self.precomputed_collocations) */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__debug); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyInt_FromLong((__pyx_v_count_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_v_count_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = PyInt_FromLong((__pyx_v_cost_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong((__pyx_v_cost_by_rank->arr[__pyx_v_i])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyTuple_New(6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(((PyObject *)__pyx_kp_s_85)); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_85)); @@ -30939,7 +30950,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; @@ -30955,9 +30966,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s */ __pyx_t_8 = __pyx_v_self->precomputed_collocations; __Pyx_INCREF(__pyx_t_8); - __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_v_num_found_patterns = __pyx_t_8; __pyx_t_8 = 0; @@ -30969,7 +30980,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * if pattern not in self.precomputed_collocations: * self.precomputed_collocations[pattern] = IntList() */ - __pyx_t_8 = PyObject_GetIter(((PyObject *)__pyx_v_IJ_set)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_GetIter(((PyObject *)__pyx_v_IJ_set)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __pyx_t_4 = Py_TYPE(__pyx_t_8)->tp_iternext; for (;;) { @@ -30978,7 +30989,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s if (unlikely(!__pyx_t_7)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[11]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -30995,7 +31006,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * self.precomputed_collocations[pattern] = IntList() * */ - __pyx_t_19 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_v_self->precomputed_collocations, __pyx_v_pattern))); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = (__Pyx_NegateNonNeg(PySequence_Contains(__pyx_v_self->precomputed_collocations, __pyx_v_pattern))); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_19) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/precomputation.pxi":449 @@ -31005,9 +31016,9 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * * cdef float stop_time = monitor_cpu() */ - __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - if (PyObject_SetItem(__pyx_v_self->precomputed_collocations, __pyx_v_pattern, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetItem(__pyx_v_self->precomputed_collocations, __pyx_v_pattern, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L64; } @@ -31031,18 +31042,18 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * logger.info("Precomputed inverted index for %d patterns ", len(self.precomputed_index)) * logger.info("Precomputation took %f seconds", (stop_time - start_time)) */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__info); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__info); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __pyx_v_self->precomputed_collocations; __Pyx_INCREF(__pyx_t_8); - __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_kp_s_86)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_86)); @@ -31056,7 +31067,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_v_x); __Pyx_GIVEREF(__pyx_v_x); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 452; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; @@ -31068,18 +31079,18 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * logger.info("Precomputed inverted index for %d patterns ", len(self.precomputed_index)) # <<<<<<<<<<<<<< * logger.info("Precomputation took %f seconds", (stop_time - start_time)) */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__info); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__info); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = __pyx_v_self->precomputed_index; __Pyx_INCREF(__pyx_t_8); - __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_t_8); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_INCREF(((PyObject *)__pyx_kp_s_87)); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_87)); @@ -31087,7 +31098,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; @@ -31098,14 +31109,14 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s * logger.info("Precomputed inverted index for %d patterns ", len(self.precomputed_index)) * logger.info("Precomputation took %f seconds", (stop_time - start_time)) # <<<<<<<<<<<<<< */ - __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__info); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__info); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyFloat_FromDouble((__pyx_v_stop_time - __pyx_v_start_time)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyFloat_FromDouble((__pyx_v_stop_time - __pyx_v_start_time)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_kp_s_88)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_88)); @@ -31113,7 +31124,7 @@ static PyObject *__pyx_pf_3_sa_14Precomputation_6precompute(struct __pyx_obj_3_s PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; @@ -31218,7 +31229,7 @@ static int __pyx_pw_3_sa_11SuffixArray_1__cinit__(PyObject *__pyx_v_self, PyObje } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __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[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -31235,7 +31246,7 @@ static int __pyx_pw_3_sa_11SuffixArray_1__cinit__(PyObject *__pyx_v_self, PyObje } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.SuffixArray.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -31265,7 +31276,7 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * self.sa = IntList() * self.ha = IntList() */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_DataArray)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_DataArray)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->darray); @@ -31280,7 +31291,7 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * self.ha = IntList() * if from_binary: */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->sa); @@ -31295,7 +31306,7 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * if from_binary: * self.read_binary(from_binary) */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->ha); @@ -31310,7 +31321,7 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * self.read_binary(from_binary) * elif from_text: */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_binary); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_binary); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/suffix_array.pxi":16 @@ -31320,14 +31331,14 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * elif from_text: * self.read_text(from_text, side) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read_binary); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read_binary); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 16; __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[13]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_from_binary); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_from_binary); __Pyx_GIVEREF(__pyx_v_from_binary); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -31342,7 +31353,7 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * self.read_text(from_text, side) * */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_text); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_from_text); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/suffix_array.pxi":18 @@ -31352,9 +31363,9 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr * * def __getitem__(self, i): */ - __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read_text); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__read_text); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_from_text); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_from_text); @@ -31362,7 +31373,7 @@ static int __pyx_pf_3_sa_11SuffixArray___cinit__(struct __pyx_obj_3_sa_SuffixArr __Pyx_INCREF(__pyx_v_side); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_side); __Pyx_GIVEREF(__pyx_v_side); - __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -31421,8 +31432,8 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_2__getitem__(struct __pyx_obj_3_sa_ * def getSentId(self, i): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyInt_FromLong((__pyx_v_self->sa->arr[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_1 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->sa->arr[__pyx_t_1])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -31478,14 +31489,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_4getSentId(struct __pyx_obj_3_sa_Su * def getSent(self, i): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__getSentId); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__getSentId); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -31545,14 +31556,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_6getSent(struct __pyx_obj_3_sa_Suff * def getSentPos(self, loc): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__getSent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__getSent); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_i); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_i); __Pyx_GIVEREF(__pyx_v_i); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -31612,14 +31623,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_8getSentPos(struct __pyx_obj_3_sa_S * def read_text(self, filename, side): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__getSentPos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__getSentPos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_loc); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_loc); __Pyx_GIVEREF(__pyx_v_loc); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -31670,11 +31681,11 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_11read_text(PyObject *__pyx_v_self, case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__side)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("read_text", 1, 2, 2, 1); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("read_text", 1, 2, 2, 1); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_text") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_text") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -31687,7 +31698,7 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_11read_text(PyObject *__pyx_v_self, } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("read_text", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("read_text", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.SuffixArray.read_text", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -31745,15 +31756,15 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * N = len(self.darray) * V = len(self.darray.id2word) */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__from_text), __pyx_v_filename) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__side), __pyx_v_side) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__from_text), __pyx_v_filename) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__side), __pyx_v_side) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__use_sent_id), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__use_sent_id), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_DataArray)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_DataArray)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_2); @@ -31771,7 +31782,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S */ __pyx_t_2 = ((PyObject *)__pyx_v_self->darray); __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_N = __pyx_t_3; @@ -31784,7 +31795,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S */ __pyx_t_2 = __pyx_v_self->darray->id2word; __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_V = __pyx_t_3; @@ -31795,13 +31806,13 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * self.ha = IntList(initial_len=V+1) * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_GIVEREF(__pyx_t_1); @@ -31817,13 +31828,13 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * * isa = IntList(initial_len=N) */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyInt_FromLong((__pyx_v_V + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_V + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_2); @@ -31839,13 +31850,13 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * word_count = IntList(initial_len=V+1) * */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_isa = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); @@ -31858,13 +31869,13 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * * '''Step 1: bucket sort data''' */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyInt_FromLong((__pyx_v_V + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_V + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_word_count = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); @@ -32099,14 +32110,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * * '''Step 2: prefix-doubling sort''' */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyFloat_FromDouble((__pyx_f_3_sa_monitor_cpu() - __pyx_v_sort_start_time)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble((__pyx_f_3_sa_monitor_cpu() - __pyx_v_sort_start_time)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_INCREF(((PyObject *)__pyx_kp_s_89)); PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_kp_s_89)); @@ -32114,7 +32125,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 77; __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_9)); __pyx_t_9 = 0; @@ -32156,14 +32167,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * i = 0 * skip = 0 */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__debug); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__debug); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_kp_s_90)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_90)); @@ -32171,7 +32182,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -32284,15 +32295,15 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * i = j+1 * if skip < 0: */ - __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__q3sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__q3sort); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyTuple_New(4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -32306,7 +32317,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S __pyx_t_1 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; @@ -32362,14 +32373,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * * '''Step 3: read off suffix array from inverse suffix array''' */ - __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__debug); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__debug); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyFloat_FromDouble((__pyx_f_3_sa_monitor_cpu() - __pyx_v_sort_start_time)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyFloat_FromDouble((__pyx_f_3_sa_monitor_cpu() - __pyx_v_sort_start_time)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_kp_s_91)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_91)); @@ -32377,7 +32388,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -32391,12 +32402,12 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * for i from 0 <= i < N: * j = isa.arr[i] */ - __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_93), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_93), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; @@ -32437,14 +32448,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S * * def q3sort(self, int i, int j, int h, IntList isa, pad=""): */ - __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyFloat_FromDouble((__pyx_f_3_sa_monitor_cpu() - __pyx_v_start_time)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyFloat_FromDouble((__pyx_f_3_sa_monitor_cpu() - __pyx_v_start_time)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_11); __Pyx_INCREF(((PyObject *)__pyx_kp_s_94)); PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_kp_s_94)); @@ -32452,7 +32463,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_10read_text(struct __pyx_obj_3_sa_S PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0; @@ -32512,17 +32523,17 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_13q3sort(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__j)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, 1); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, 1); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__h)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, 2); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, 2); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__isa)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, 3); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, 3); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (kw_args > 0) { @@ -32531,7 +32542,7 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_13q3sort(PyObject *__pyx_v_self, Py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "q3sort") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "q3sort") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -32544,21 +32555,21 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_13q3sort(PyObject *__pyx_v_self, Py default: goto __pyx_L5_argtuple_error; } } - __pyx_v_i = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_j = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_j == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_h = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_h == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_i = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_i == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_j = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_j == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_h = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_h == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_v_isa = ((struct __pyx_obj_3_sa_IntList *)values[3]); __pyx_v_pad = values[4]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("q3sort", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.SuffixArray.q3sort", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_isa), __pyx_ptype_3_sa_IntList, 1, "isa", 0))) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_isa), __pyx_ptype_3_sa_IntList, 1, "isa", 0))) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_3_sa_11SuffixArray_12q3sort(((struct __pyx_obj_3_sa_SuffixArray *)__pyx_v_self), __pyx_v_i, __pyx_v_j, __pyx_v_h, __pyx_v_isa, __pyx_v_pad); goto __pyx_L0; __pyx_L1_error:; @@ -32615,11 +32626,11 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_12q3sort(struct __pyx_obj_3_sa_Suff * if j-i == -1: # recursive base case -- empty interval * return */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -32627,20 +32638,20 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_12q3sort(struct __pyx_obj_3_sa_Suff __Pyx_GIVEREF(__pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_95), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_95), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[13]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[12]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; @@ -32978,17 +32989,17 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_12q3sort(struct __pyx_obj_3_sa_Suff * * # update suffixes with pivot value */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__q3sort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__q3sort); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyInt_FromLong((__pyx_v_phead - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_phead - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyNumber_Add(__pyx_v_pad, ((PyObject *)__pyx_kp_s_48)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Add(__pyx_v_pad, ((PyObject *)__pyx_kp_s_48)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyTuple_New(5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); @@ -33005,7 +33016,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_12q3sort(struct __pyx_obj_3_sa_Suff __pyx_t_2 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; - __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; @@ -33060,17 +33071,17 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_12q3sort(struct __pyx_obj_3_sa_Suff * * */ - __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__q3sort); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__q3sort); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = PyInt_FromLong((__pyx_v_ptail + 1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyInt_FromLong((__pyx_v_ptail + 1)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); - __pyx_t_3 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(__pyx_v_j); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromLong(__pyx_v_h); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyNumber_Add(__pyx_v_pad, ((PyObject *)__pyx_kp_s_48)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Add(__pyx_v_pad, ((PyObject *)__pyx_kp_s_48)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); @@ -33087,7 +33098,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_12q3sort(struct __pyx_obj_3_sa_Suff __pyx_t_3 = 0; __pyx_t_6 = 0; __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -33118,7 +33129,7 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_15write_text(PyObject *__pyx_v_self __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_text (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -33157,16 +33168,16 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_14write_text(struct __pyx_obj_3_sa_ * * def read_binary(self, char* filename): */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__write_text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s__write_text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 179; __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; @@ -33194,7 +33205,7 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_17read_binary(PyObject *__pyx_v_sel __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("read_binary (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -33280,7 +33291,7 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_19write_binary(PyObject *__pyx_v_se __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_binary (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -33366,7 +33377,7 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_21write_enhanced(PyObject *__pyx_v_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_enhanced (wrapper)", 0); assert(__pyx_arg_filename); { - __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -33419,9 +33430,9 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 * for a_i in self.sa: */ /*with:*/ { - __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __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)); @@ -33429,14 +33440,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__w)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____exit__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____enter__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____enter__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -33458,14 +33469,14 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 * for a_i in self.sa: * f.write("%d " % a_i) */ - __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s_27); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self->darray), __pyx_n_s_27); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_f); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_f); __Pyx_GIVEREF(__pyx_v_f); - __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -33482,7 +33493,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 __pyx_t_2 = ((PyObject *)__pyx_v_self->sa); __Pyx_INCREF(__pyx_t_2); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { - __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_self->sa)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_8 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_self->sa)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_9 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -33492,21 +33503,21 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; #endif } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; #endif } else { __pyx_t_1 = __pyx_t_9(__pyx_t_2); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L7_error;} } break; } @@ -33523,16 +33534,16 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 * f.write("\n") * for w_i in self.ha: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_a_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_a_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; @@ -33547,9 +33558,9 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 * for w_i in self.ha: * f.write("%d " % w_i) */ - __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_96), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_96), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -33565,7 +33576,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 __pyx_t_4 = ((PyObject *)__pyx_v_self->ha); __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0; __pyx_t_9 = NULL; } else { - __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_self->ha)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(((PyObject *)__pyx_v_self->ha)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; } @@ -33575,21 +33586,21 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; #endif } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_4)) { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; #endif } else { __pyx_t_2 = __pyx_t_9(__pyx_t_4); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + else {__pyx_filename = __pyx_f[12]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L7_error;} } break; } @@ -33606,16 +33617,16 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 * f.write("\n") * */ - __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_w_i); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_w_i); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_10)); __Pyx_GIVEREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; @@ -33630,9 +33641,9 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 * * cdef int __search_high(self, int word_id, int offset, int low, int high): */ - __pyx_t_4 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_4 = PyObject_GetAttr(__pyx_v_f, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_97), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_10 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_97), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; @@ -33656,11 +33667,11 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 */ /*except:*/ { __Pyx_AddTraceback("_sa.SuffixArray.write_enhanced", __pyx_clineno, __pyx_lineno, __pyx_filename); - if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_4); __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); @@ -33673,11 +33684,11 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 __Pyx_GIVEREF(__pyx_t_1); __pyx_t_12 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __Pyx_GOTREF(__pyx_t_12); __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_12); __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} __pyx_t_13 = (!__pyx_t_11); if (__pyx_t_13) { __Pyx_GIVEREF(__pyx_t_10); @@ -33685,7 +33696,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 __Pyx_GIVEREF(__pyx_t_1); __Pyx_ErrRestore(__pyx_t_10, __pyx_t_4, __pyx_t_1); __pyx_t_10 = 0; __pyx_t_4 = 0; __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} + {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;} goto __pyx_L22; } __pyx_L22:; @@ -33713,11 +33724,11 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_20write_enhanced(struct __pyx_obj_3 if (__pyx_t_3) { __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_98, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_7); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } } goto __pyx_L23; @@ -33948,7 +33959,7 @@ static PyObject *__pyx_f_3_sa_11SuffixArray___get_range(struct __pyx_obj_3_sa_Su * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___search_low(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_low, __pyx_v_midpoint)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___search_low(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_low, __pyx_v_midpoint)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); /* "/Users/vchahun/Sandbox/cdec/python/src/sa/suffix_array.pxi":231 @@ -33958,9 +33969,9 @@ static PyObject *__pyx_f_3_sa_11SuffixArray___get_range(struct __pyx_obj_3_sa_Su * * cdef __lookup_helper(self, int word_id, int offset, int low, int high): */ - __pyx_t_2 = PyInt_FromLong(((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___search_high(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_midpoint, __pyx_v_high)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___search_high(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_midpoint, __pyx_v_high)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 230; __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); @@ -34025,11 +34036,11 @@ static PyObject *__pyx_f_3_sa_11SuffixArray___lookup_helper(struct __pyx_obj_3_s * return None */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyInt_FromLong((__pyx_v_self->ha->arr[__pyx_v_word_id])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->ha->arr[__pyx_v_word_id])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromLong((__pyx_v_self->ha->arr[(__pyx_v_word_id + 1)])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_v_self->ha->arr[(__pyx_v_word_id + 1)])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -34096,7 +34107,7 @@ static PyObject *__pyx_f_3_sa_11SuffixArray___lookup_helper(struct __pyx_obj_3_s * return self.__lookup_helper(word_id, offset, low, midpoint) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___get_range(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_low, __pyx_v_high, __pyx_v_midpoint); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___get_range(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_low, __pyx_v_high, __pyx_v_midpoint); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; @@ -34123,7 +34134,7 @@ static PyObject *__pyx_f_3_sa_11SuffixArray___lookup_helper(struct __pyx_obj_3_s * return self.__lookup_helper(word_id, offset, midpoint+1, high) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___lookup_helper(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_low, __pyx_v_midpoint); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___lookup_helper(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, __pyx_v_low, __pyx_v_midpoint); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; @@ -34140,7 +34151,7 @@ static PyObject *__pyx_f_3_sa_11SuffixArray___lookup_helper(struct __pyx_obj_3_s * def lookup(self, word, int offset, int low, int high): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___lookup_helper(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, (__pyx_v_midpoint + 1), __pyx_v_high); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___lookup_helper(__pyx_v_self, __pyx_v_word_id, __pyx_v_offset, (__pyx_v_midpoint + 1), __pyx_v_high); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_r = __pyx_t_4; __pyx_t_4 = 0; @@ -34194,21 +34205,21 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_23lookup(PyObject *__pyx_v_self, Py case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__offset)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 1); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 1); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__low)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 2); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 2); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__high)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 3); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, 3); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lookup") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "lookup") < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { goto __pyx_L5_argtuple_error; @@ -34219,13 +34230,13 @@ static PyObject *__pyx_pw_3_sa_11SuffixArray_23lookup(PyObject *__pyx_v_self, Py values[3] = PyTuple_GET_ITEM(__pyx_args, 3); } __pyx_v_word = values[0]; - __pyx_v_offset = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_low = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_high = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_offset = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_offset == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_low = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_high = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("lookup", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[12]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_sa.SuffixArray.lookup", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -34298,7 +34309,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_22lookup(struct __pyx_obj_3_sa_Suff */ __pyx_t_2 = ((PyObject *)__pyx_v_self->sa); __Pyx_INCREF(__pyx_t_2); - __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_high = __pyx_t_3; goto __pyx_L4; @@ -34312,7 +34323,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_22lookup(struct __pyx_obj_3_sa_Suff * word_id = self.darray.word2id[word] * return self.__lookup_helper(word_id, offset, low, high) */ - __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->darray->word2id, __pyx_v_word))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->darray->word2id, __pyx_v_word))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { /* "/Users/vchahun/Sandbox/cdec/python/src/sa/suffix_array.pxi":256 @@ -34322,7 +34333,7 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_22lookup(struct __pyx_obj_3_sa_Suff * return self.__lookup_helper(word_id, offset, low, high) * else: */ - __pyx_t_2 = PyObject_GetItem(__pyx_v_self->darray->word2id, __pyx_v_word); if (!__pyx_t_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetItem(__pyx_v_self->darray->word2id, __pyx_v_word); if (!__pyx_t_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_v_word_id = __pyx_t_2; __pyx_t_2 = 0; @@ -34335,8 +34346,8 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_22lookup(struct __pyx_obj_3_sa_Suff * return None */ __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_word_id); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___lookup_helper(__pyx_v_self, __pyx_t_4, __pyx_v_offset, __pyx_v_low, __pyx_v_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_v_word_id); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_SuffixArray *)__pyx_v_self->__pyx_vtab)->__pyx___lookup_helper(__pyx_v_self, __pyx_t_4, __pyx_v_offset, __pyx_v_low, __pyx_v_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -34371,56 +34382,101 @@ static PyObject *__pyx_pf_3_sa_11SuffixArray_22lookup(struct __pyx_obj_3_sa_Suff } /* Python wrapper */ -static int __pyx_pw_3_sa_8TrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_3_sa_8TrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pw_3_sa_13FeatureVector_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_13FeatureVector_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; - __pyx_r = __pyx_pf_3_sa_8TrieNode___cinit__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self)); + __pyx_r = __pyx_pf_3_sa_13FeatureVector___cinit__(((struct __pyx_obj_3_sa_FeatureVector *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":21 - * cdef public children +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":7 * + * cdef class FeatureVector: * def __cinit__(self): # <<<<<<<<<<<<<< - * self.children = {} - * + * self.names = IntList(INITIAL_CAPACITY, INCREMENT) + * self.values = FloatList(INITIAL_CAPACITY, INCREMENT) */ -static int __pyx_pf_3_sa_8TrieNode___cinit__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self) { +static int __pyx_pf_3_sa_13FeatureVector___cinit__(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self) { int __pyx_r; __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("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":22 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":8 + * cdef class FeatureVector: * def __cinit__(self): - * self.children = {} # <<<<<<<<<<<<<< + * self.names = IntList(INITIAL_CAPACITY, INCREMENT) # <<<<<<<<<<<<<< + * self.values = FloatList(INITIAL_CAPACITY, INCREMENT) * - * cdef class ExtendedTrieNode(TrieNode): */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); - __Pyx_GOTREF(__pyx_v_self->children); - __Pyx_DECREF(__pyx_v_self->children); - __pyx_v_self->children = ((PyObject *)__pyx_t_1); + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__INITIAL_CAPACITY); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__INCREMENT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); __pyx_t_1 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->names); + __Pyx_DECREF(((PyObject *)__pyx_v_self->names)); + __pyx_v_self->names = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":9 + * def __cinit__(self): + * self.names = IntList(INITIAL_CAPACITY, INCREMENT) + * self.values = FloatList(INITIAL_CAPACITY, INCREMENT) # <<<<<<<<<<<<<< + * + * def set(self, unsigned name, float value): + */ + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__INITIAL_CAPACITY); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__INCREMENT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_FloatList)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->values); + __Pyx_DECREF(((PyObject *)__pyx_v_self->values)); + __pyx_v_self->values = ((struct __pyx_obj_3_sa_FloatList *)__pyx_t_3); + __pyx_t_3 = 0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_sa.TrieNode.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("_sa.FeatureVector.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -34428,120 +34484,20 @@ static int __pyx_pf_3_sa_8TrieNode___cinit__(struct __pyx_obj_3_sa_TrieNode *__p } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_8TrieNode_8children_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_8TrieNode_8children_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_3_sa_13FeatureVector_3set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3_sa_13FeatureVector_3set(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + unsigned int __pyx_v_name; + float __pyx_v_value; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_8TrieNode_8children___get__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":19 - * - * cdef class TrieNode: - * cdef public children # <<<<<<<<<<<<<< - * - * def __cinit__(self): - */ - -static PyObject *__pyx_pf_3_sa_8TrieNode_8children___get__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->children); - __pyx_r = __pyx_v_self->children; - 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_3_sa_8TrieNode_8children_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_8TrieNode_8children_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_8TrieNode_8children_2__set__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_3_sa_8TrieNode_8children_2__set__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->children); - __Pyx_DECREF(__pyx_v_self->children); - __pyx_v_self->children = __pyx_v_value; - - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_8TrieNode_8children_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_3_sa_8TrieNode_8children_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_8TrieNode_8children_4__del__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_3_sa_8TrieNode_8children_4__del__(struct __pyx_obj_3_sa_TrieNode *__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->children); - __Pyx_DECREF(__pyx_v_self->children); - __pyx_v_self->children = Py_None; - - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_phrase = 0; - PyObject *__pyx_v_phrase_location = 0; - PyObject *__pyx_v_suffix_link = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + __Pyx_RefNannySetupContext("set (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__phrase,&__pyx_n_s__phrase_location,&__pyx_n_s__suffix_link,0}; - PyObject* values[3] = {0,0,0}; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":29 - * cdef public suffix_link - * - * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): # <<<<<<<<<<<<<< - * self.phrase = phrase - * self.phrase_location = phrase_location - */ - values[0] = ((PyObject *)Py_None); - values[1] = ((PyObject *)Py_None); - values[2] = ((PyObject *)Py_None); + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,&__pyx_n_s__value,0}; + PyObject* values[2] = {0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; @@ -34550,371 +34506,834 @@ static int __pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(PyObject *__pyx_v_self, P kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__phrase); - if (value) { values[0] = value; kw_args--; } - } + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__name)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__phrase_location); - if (value) { values[1] = value; kw_args--; } - } - case 2: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__suffix_link); - if (value) { values[2] = value; kw_args--; } + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__value)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, 1); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); } - __pyx_v_phrase = values[0]; - __pyx_v_phrase_location = values[1]; - __pyx_v_suffix_link = values[2]; + __pyx_v_name = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_name == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_value = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("set", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.ExtendedTrieNode.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.FeatureVector.set", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); - return -1; + return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode___cinit__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), __pyx_v_phrase, __pyx_v_phrase_location, __pyx_v_suffix_link); + __pyx_r = __pyx_pf_3_sa_13FeatureVector_2set(((struct __pyx_obj_3_sa_FeatureVector *)__pyx_v_self), __pyx_v_name, __pyx_v_value); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_3_sa_16ExtendedTrieNode___cinit__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_phrase, PyObject *__pyx_v_phrase_location, PyObject *__pyx_v_suffix_link) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":30 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":11 + * self.values = FloatList(INITIAL_CAPACITY, INCREMENT) * - * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): - * self.phrase = phrase # <<<<<<<<<<<<<< - * self.phrase_location = phrase_location - * self.suffix_link = suffix_link + * def set(self, unsigned name, float value): # <<<<<<<<<<<<<< + * self.names.append(name) + * self.values.append(value) */ - __Pyx_INCREF(__pyx_v_phrase); - __Pyx_GIVEREF(__pyx_v_phrase); - __Pyx_GOTREF(__pyx_v_self->phrase); - __Pyx_DECREF(__pyx_v_self->phrase); - __pyx_v_self->phrase = __pyx_v_phrase; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":31 - * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): - * self.phrase = phrase - * self.phrase_location = phrase_location # <<<<<<<<<<<<<< - * self.suffix_link = suffix_link +static PyObject *__pyx_pf_3_sa_13FeatureVector_2set(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self, unsigned int __pyx_v_name, float __pyx_v_value) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":12 + * + * def set(self, unsigned name, float value): + * self.names.append(name) # <<<<<<<<<<<<<< + * self.values.append(value) * */ - __Pyx_INCREF(__pyx_v_phrase_location); - __Pyx_GIVEREF(__pyx_v_phrase_location); - __Pyx_GOTREF(__pyx_v_self->phrase_location); - __Pyx_DECREF(__pyx_v_self->phrase_location); - __pyx_v_self->phrase_location = __pyx_v_phrase_location; + __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_name); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->names), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":32 - * self.phrase = phrase - * self.phrase_location = phrase_location - * self.suffix_link = suffix_link # <<<<<<<<<<<<<< - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":13 + * def set(self, unsigned name, float value): + * self.names.append(name) + * self.values.append(value) # <<<<<<<<<<<<<< * + * def __iter__(self): */ - __Pyx_INCREF(__pyx_v_suffix_link); - __Pyx_GIVEREF(__pyx_v_suffix_link); - __Pyx_GOTREF(__pyx_v_self->suffix_link); - __Pyx_DECREF(__pyx_v_self->suffix_link); - __pyx_v_self->suffix_link = __pyx_v_suffix_link; + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->values), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_sa.FeatureVector.set", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } +static PyObject *__pyx_gb_3_sa_13FeatureVector_6generator4(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_6phrase_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_6phrase_1__get__(PyObject *__pyx_v_self) { +static PyObject *__pyx_pw_3_sa_13FeatureVector_5__iter__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_13FeatureVector_5__iter__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_6phrase___get__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_13FeatureVector_4__iter__(((struct __pyx_obj_3_sa_FeatureVector *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":25 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":15 + * self.values.append(value) * - * cdef class ExtendedTrieNode(TrieNode): - * cdef public phrase # <<<<<<<<<<<<<< - * cdef public phrase_location - * cdef public suffix_link + * def __iter__(self): # <<<<<<<<<<<<<< + * cdef unsigned i + * for i in range(self.names.len): */ -static PyObject *__pyx_pf_3_sa_16ExtendedTrieNode_6phrase___get__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { +static PyObject *__pyx_pf_3_sa_13FeatureVector_4__iter__(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self) { + struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->phrase); - __pyx_r = __pyx_v_self->phrase; - goto __pyx_L0; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__iter__", 0); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *)__pyx_ptype_3_sa___pyx_scope_struct_8___iter__->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_8___iter__, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_13FeatureVector_6generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 15; __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("_sa.FeatureVector.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; +static PyObject *__pyx_gb_3_sa_13FeatureVector_6generator4(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + int __pyx_t_1; + unsigned int __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_2__set__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} -static int __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_2__set__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->phrase); - __Pyx_DECREF(__pyx_v_self->phrase); - __pyx_v_self->phrase = __pyx_v_value; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":17 + * def __iter__(self): + * cdef unsigned i + * for i in range(self.names.len): # <<<<<<<<<<<<<< + * yield (FD.word(self.names[i]), self.values[i]) + * + */ + __pyx_t_1 = __pyx_cur_scope->__pyx_v_self->names->len; + for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { + __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - __pyx_r = 0; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":18 + * cdef unsigned i + * for i in range(self.names.len): + * yield (FD.word(self.names[i]), self.values[i]) # <<<<<<<<<<<<<< + * + * def __str__(self): + */ + __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self->names), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyBytes_FromString(((struct __pyx_vtabstruct_3_sa_StringMap *)__pyx_v_3_sa_FD->__pyx_vtab)->word(__pyx_v_3_sa_FD, __pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_5 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self->values), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_3 = 0; + __pyx_t_5 = 0; + __pyx_r = ((PyObject *)__pyx_t_6); + __pyx_t_6 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_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[13]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); - return __pyx_r; + return NULL; } /* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; +static PyObject *__pyx_pw_3_sa_13FeatureVector_8__str__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_13FeatureVector_8__str__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_4__del__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_13FeatureVector_7__str__(((struct __pyx_obj_3_sa_FeatureVector *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } +static PyObject *__pyx_gb_3_sa_13FeatureVector_7__str___2generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -static int __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_4__del__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { - int __pyx_r; +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":21 + * + * def __str__(self): + * return ' '.join('%s=%s' % feat for feat in self) # <<<<<<<<<<<<<< + * + * cdef class Scorer: + */ + +static PyObject *__pyx_pf_3_sa_13FeatureVector_7__str___genexpr(PyObject *__pyx_self) { + struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *__pyx_cur_scope; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->phrase); - __Pyx_DECREF(__pyx_v_self->phrase); - __pyx_v_self->phrase = Py_None; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("genexpr", 0); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *)__pyx_ptype_3_sa___pyx_scope_struct_10_genexpr->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_10_genexpr, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *) __pyx_self; + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_13FeatureVector_7__str___2generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } - __pyx_r = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_sa.FeatureVector.__str__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; +static PyObject *__pyx_gb_3_sa_13FeatureVector_7__str___2generator8(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location___get__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L6_resume_from_yield; + default: /* CPython raises the right error here */ + __Pyx_RefNannyFinishContext(); + return NULL; + } + __pyx_L3_first_run:; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + if (PyList_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) || PyTuple_CheckExact(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self))) { + __pyx_t_1 = ((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_feat); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_feat); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_cur_scope->__pyx_v_feat = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_99), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_r = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; + __Pyx_XGIVEREF(__pyx_t_1); + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __pyx_cur_scope->__pyx_t_2 = __pyx_t_3; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L6_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_cur_scope->__pyx_t_0 = 0; + __Pyx_XGOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); - return __pyx_r; + return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":26 - * cdef class ExtendedTrieNode(TrieNode): - * cdef public phrase - * cdef public phrase_location # <<<<<<<<<<<<<< - * cdef public suffix_link +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":20 + * yield (FD.word(self.names[i]), self.values[i]) + * + * def __str__(self): # <<<<<<<<<<<<<< + * return ' '.join('%s=%s' % feat for feat in self) * */ -static PyObject *__pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location___get__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { +static PyObject *__pyx_pf_3_sa_13FeatureVector_7__str__(struct __pyx_obj_3_sa_FeatureVector *__pyx_v_self) { + struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); + 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("__str__", 0); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *)__pyx_ptype_3_sa___pyx_scope_struct_9___str__->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_9___str__, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":21 + * + * def __str__(self): + * return ' '.join('%s=%s' % feat for feat in self) # <<<<<<<<<<<<<< + * + * cdef class Scorer: + */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->phrase_location); - __pyx_r = __pyx_v_self->phrase_location; + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_67), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __pyx_pf_3_sa_13FeatureVector_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __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[13]; __pyx_lineno = 21; __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[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_AddTraceback("_sa.FeatureVector.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { +static int __pyx_pw_3_sa_6Scorer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_6Scorer_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_models = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_2__set__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1; + __Pyx_INCREF(__pyx_args); + __pyx_v_models = __pyx_args; + __pyx_r = __pyx_pf_3_sa_6Scorer___init__(((struct __pyx_obj_3_sa_Scorer *)__pyx_v_self), __pyx_v_models); + __Pyx_XDECREF(__pyx_v_models); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_2__set__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_value) { +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":25 + * cdef class Scorer: + * cdef models + * def __init__(self, *models): # <<<<<<<<<<<<<< + * names = [FD.index(model.__name__) for model in models] + * self.models = zip(names, models) + */ + +static int __pyx_pf_3_sa_6Scorer___init__(struct __pyx_obj_3_sa_Scorer *__pyx_v_self, PyObject *__pyx_v_models) { + PyObject *__pyx_v_names = NULL; + PyObject *__pyx_v_model = NULL; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->phrase_location); - __Pyx_DECREF(__pyx_v_self->phrase_location); - __pyx_v_self->phrase_location = __pyx_v_value; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + char *__pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__init__", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":26 + * cdef models + * def __init__(self, *models): + * names = [FD.index(model.__name__) for model in models] # <<<<<<<<<<<<<< + * self.models = zip(names, models) + * + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = ((PyObject *)__pyx_v_models); __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + for (;;) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + __Pyx_XDECREF(__pyx_v_model); + __pyx_v_model = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_v_model, __pyx_n_s____name__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyInt_FromLong(((struct __pyx_vtabstruct_3_sa_StringMap *)__pyx_v_3_sa_FD->__pyx_vtab)->index(__pyx_v_3_sa_FD, ((char *)__pyx_t_5))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (unlikely(__Pyx_PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_INCREF(((PyObject *)__pyx_t_1)); + __pyx_v_names = __pyx_t_1; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":27 + * def __init__(self, *models): + * names = [FD.index(model.__name__) for model in models] + * self.models = zip(names, models) # <<<<<<<<<<<<<< + * + * cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, + */ + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_names)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_names)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_names)); + __Pyx_INCREF(((PyObject *)__pyx_v_models)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_models)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_models)); + __pyx_t_2 = PyObject_Call(__pyx_builtin_zip, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->models); + __Pyx_DECREF(__pyx_v_self->models); + __pyx_v_self->models = __pyx_t_2; + __pyx_t_2 = 0; __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("_sa.Scorer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_names); + __Pyx_XDECREF(__pyx_v_model); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_4__del__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":29 + * self.models = zip(names, models) + * + * cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, # <<<<<<<<<<<<<< + * unsigned paircount, unsigned fcount, unsigned fsample_count): + * cdef FeatureVector scores = FeatureVector() + */ -static int __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_4__del__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { - int __pyx_r; +static struct __pyx_obj_3_sa_FeatureVector *__pyx_f_3_sa_6Scorer_score(struct __pyx_obj_3_sa_Scorer *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_fphrase, struct __pyx_obj_3_sa_Phrase *__pyx_v_ephrase, unsigned int __pyx_v_paircount, unsigned int __pyx_v_fcount, unsigned int __pyx_v_fsample_count) { + struct __pyx_obj_3_sa_FeatureVector *__pyx_v_scores = 0; + PyObject *__pyx_v_name = NULL; + PyObject *__pyx_v_model = NULL; + struct __pyx_obj_3_sa_FeatureVector *__pyx_r = NULL; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->phrase_location); - __Pyx_DECREF(__pyx_v_self->phrase_location); - __pyx_v_self->phrase_location = Py_None; + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("score", 0); - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":31 + * cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, + * unsigned paircount, unsigned fcount, unsigned fsample_count): + * cdef FeatureVector scores = FeatureVector() # <<<<<<<<<<<<<< + * for name, model in self.models: + * scores.set(name, model(fphrase, ephrase, paircount, fcount, fsample_count)) + */ + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_FeatureVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_scores = ((struct __pyx_obj_3_sa_FeatureVector *)__pyx_t_1); + __pyx_t_1 = 0; -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link___get__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":32 + * unsigned paircount, unsigned fcount, unsigned fsample_count): + * cdef FeatureVector scores = FeatureVector() + * for name, model in self.models: # <<<<<<<<<<<<<< + * scores.set(name, model(fphrase, ephrase, paircount, fcount, fsample_count)) + * return scores + */ + if (PyList_CheckExact(__pyx_v_self->models) || PyTuple_CheckExact(__pyx_v_self->models)) { + __pyx_t_1 = __pyx_v_self->models; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_self->models); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[13]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + __Pyx_XDECREF(__pyx_v_name); + __pyx_v_name = __pyx_t_5; + __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_v_model); + __pyx_v_model = __pyx_t_6; + __pyx_t_6 = 0; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":27 - * cdef public phrase - * cdef public phrase_location - * cdef public suffix_link # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":33 + * cdef FeatureVector scores = FeatureVector() + * for name, model in self.models: + * scores.set(name, model(fphrase, ephrase, paircount, fcount, fsample_count)) # <<<<<<<<<<<<<< + * return scores * - * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): */ + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_paircount); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = PyLong_FromUnsignedLong(__pyx_v_fcount); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = PyLong_FromUnsignedLong(__pyx_v_fsample_count); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_9 = PyTuple_New(5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(((PyObject *)__pyx_v_fphrase)); + PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_v_fphrase)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphrase)); + __Pyx_INCREF(((PyObject *)__pyx_v_ephrase)); + PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject *)__pyx_v_ephrase)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_ephrase)); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_6 = 0; + __pyx_t_5 = 0; + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_v_model, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_v_name); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_name); + __Pyx_GIVEREF(__pyx_v_name); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; -static PyObject *__pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link___get__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->suffix_link); - __pyx_r = __pyx_v_self->suffix_link; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":34 + * for name, model in self.models: + * scores.set(name, model(fphrase, ephrase, paircount, fcount, fsample_count)) + * return scores # <<<<<<<<<<<<<< + * + * from libc.stdlib cimport malloc, realloc, free + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_scores)); + __pyx_r = __pyx_v_scores; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("_sa.Scorer.score", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); + __Pyx_XDECREF((PyObject *)__pyx_v_scores); + __Pyx_XDECREF(__pyx_v_name); + __Pyx_XDECREF(__pyx_v_model); + __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; +static void __pyx_pw_3_sa_13DefaultScorer_1__dealloc__(PyObject *__pyx_v_self); /*proto*/ +static void __pyx_pw_3_sa_13DefaultScorer_1__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_2__set__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); + __pyx_pf_3_sa_13DefaultScorer___dealloc__(((struct __pyx_obj_3_sa_DefaultScorer *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); - return __pyx_r; } -static int __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_2__set__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":53 + * cdef int* fid + * + * def __dealloc__(self): # <<<<<<<<<<<<<< + * free(self.fid) + * + */ + +static void __pyx_pf_3_sa_13DefaultScorer___dealloc__(struct __pyx_obj_3_sa_DefaultScorer *__pyx_v_self) { __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->suffix_link); - __Pyx_DECREF(__pyx_v_self->suffix_link); - __pyx_v_self->suffix_link = __pyx_v_value; + __Pyx_RefNannySetupContext("__dealloc__", 0); - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":54 + * + * def __dealloc__(self): + * free(self.fid) # <<<<<<<<<<<<<< + * + * def __init__(self, BiLex ttable): + */ + free(__pyx_v_self->fid); -/* Python wrapper */ -static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_4__del__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); - return __pyx_r; } -static int __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_4__del__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { +/* Python wrapper */ +static int __pyx_pw_3_sa_13DefaultScorer_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_13DefaultScorer_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_3_sa_BiLex *__pyx_v_ttable = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__", 0); - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->suffix_link); - __Pyx_DECREF(__pyx_v_self->suffix_link); - __pyx_v_self->suffix_link = Py_None; - - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_9TrieTable_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_3_sa_9TrieTable_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_extended = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__extended,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__ttable,0}; PyObject* values[1] = {0}; - values[0] = __pyx_k_99; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); @@ -34926,433 +35345,1071 @@ static int __pyx_pw_3_sa_9TrieTable_1__cinit__(PyObject *__pyx_v_self, PyObject kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__extended); - if (value) { values[0] = value; kw_args--; } - } + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ttable)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } + } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { + goto __pyx_L5_argtuple_error; } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } - __pyx_v_extended = values[0]; + __pyx_v_ttable = ((struct __pyx_obj_3_sa_BiLex *)values[0]); } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[13]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.TrieTable.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.DefaultScorer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_9TrieTable___cinit__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), __pyx_v_extended); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ttable), __pyx_ptype_3_sa_BiLex, 1, "ttable", 0))) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_13DefaultScorer_2__init__(((struct __pyx_obj_3_sa_DefaultScorer *)__pyx_v_self), __pyx_v_ttable); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":39 - * cdef public int count - * cdef public root - * def __cinit__(self, extended=False): # <<<<<<<<<<<<<< - * self.count = 0 - * self.extended = extended +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":56 + * free(self.fid) + * + * def __init__(self, BiLex ttable): # <<<<<<<<<<<<<< + * self.ttable = ttable + * self.fid = malloc(NFEATURES*sizeof(int)) */ -static int __pyx_pf_3_sa_9TrieTable___cinit__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_extended) { +static int __pyx_pf_3_sa_13DefaultScorer_2__init__(struct __pyx_obj_3_sa_DefaultScorer *__pyx_v_self, struct __pyx_obj_3_sa_BiLex *__pyx_v_ttable) { + unsigned int __pyx_v_i; + PyObject *__pyx_v_fnames = NULL; int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; PyObject *__pyx_t_3 = NULL; + size_t __pyx_t_4; + unsigned int __pyx_t_5; + Py_ssize_t __pyx_t_6; + char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":40 - * cdef public root - * def __cinit__(self, extended=False): - * self.count = 0 # <<<<<<<<<<<<<< - * self.extended = extended - * if extended: - */ - __pyx_v_self->count = 0; + __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":41 - * def __cinit__(self, extended=False): - * self.count = 0 - * self.extended = extended # <<<<<<<<<<<<<< - * if extended: - * self.root = ExtendedTrieNode() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":57 + * + * def __init__(self, BiLex ttable): + * self.ttable = ttable # <<<<<<<<<<<<<< + * self.fid = malloc(NFEATURES*sizeof(int)) + * cdef unsigned i */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_extended); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->extended = __pyx_t_1; + __Pyx_INCREF(((PyObject *)__pyx_v_ttable)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_ttable)); + __Pyx_GOTREF(__pyx_v_self->ttable); + __Pyx_DECREF(((PyObject *)__pyx_v_self->ttable)); + __pyx_v_self->ttable = __pyx_v_ttable; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":42 - * self.count = 0 - * self.extended = extended - * if extended: # <<<<<<<<<<<<<< - * self.root = ExtendedTrieNode() - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":58 + * def __init__(self, BiLex ttable): + * self.ttable = ttable + * self.fid = malloc(NFEATURES*sizeof(int)) # <<<<<<<<<<<<<< + * cdef unsigned i + * for i, fnames in enumerate(('EgivenFCoherent', 'SampleCountF', 'CountEF', */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_extended); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_2) { + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__NFEATURES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_PyInt_FromSize_t((sizeof(int))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyNumber_Multiply(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyInt_AsSize_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->fid = ((int *)malloc(__pyx_t_4)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":43 - * self.extended = extended - * if extended: - * self.root = ExtendedTrieNode() # <<<<<<<<<<<<<< - * else: - * self.root = TrieNode() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":60 + * self.fid = malloc(NFEATURES*sizeof(int)) + * cdef unsigned i + * for i, fnames in enumerate(('EgivenFCoherent', 'SampleCountF', 'CountEF', # <<<<<<<<<<<<<< + * 'MaxLexFgivenE', 'MaxLexEgivenF', 'IsSingletonF', 'IsSingletonFE')): + * self.fid[i] = FD.index(fnames) */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(__pyx_v_self->root); - __Pyx_DECREF(__pyx_v_self->root); - __pyx_v_self->root = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L3; - } - /*else*/ { + __pyx_t_5 = 0; + __pyx_t_3 = ((PyObject *)__pyx_k_tuple_100); __Pyx_INCREF(__pyx_t_3); __pyx_t_6 = 0; + for (;;) { + if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_6); __Pyx_INCREF(__pyx_t_2); __pyx_t_6++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + __Pyx_XDECREF(__pyx_v_fnames); + __pyx_v_fnames = __pyx_t_2; + __pyx_t_2 = 0; + __pyx_v_i = __pyx_t_5; + __pyx_t_5 = (__pyx_t_5 + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":45 - * self.root = ExtendedTrieNode() - * else: - * self.root = TrieNode() # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":62 + * for i, fnames in enumerate(('EgivenFCoherent', 'SampleCountF', 'CountEF', + * 'MaxLexFgivenE', 'MaxLexEgivenF', 'IsSingletonF', 'IsSingletonFE')): + * self.fid[i] = FD.index(fnames) # <<<<<<<<<<<<<< * - * # linked list structure for storing matches in BaselineRuleFactory + * cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(__pyx_v_self->root); - __Pyx_DECREF(__pyx_v_self->root); - __pyx_v_self->root = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_7 = PyBytes_AsString(__pyx_v_fnames); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + (__pyx_v_self->fid[__pyx_v_i]) = ((struct __pyx_vtabstruct_3_sa_StringMap *)__pyx_v_3_sa_FD->__pyx_vtab)->index(__pyx_v_3_sa_FD, __pyx_t_7); } - __pyx_L3:; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("_sa.TrieTable.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.DefaultScorer.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_fnames); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_9TrieTable_8extended_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_9TrieTable_8extended_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_8extended___get__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":36 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":64 + * self.fid[i] = FD.index(fnames) * - * cdef class TrieTable: - * cdef public int extended # <<<<<<<<<<<<<< - * cdef public int count - * cdef public root + * cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, # <<<<<<<<<<<<<< + * unsigned paircount, unsigned fcount, unsigned fsample_count): + * cdef FeatureVector scores = FeatureVector() */ -static PyObject *__pyx_pf_3_sa_9TrieTable_8extended___get__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self) { - PyObject *__pyx_r = NULL; +static struct __pyx_obj_3_sa_FeatureVector *__pyx_f_3_sa_13DefaultScorer_score(struct __pyx_obj_3_sa_DefaultScorer *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_fphrase, struct __pyx_obj_3_sa_Phrase *__pyx_v_ephrase, unsigned int __pyx_v_paircount, unsigned int __pyx_v_fcount, unsigned int __pyx_v_fsample_count) { + struct __pyx_obj_3_sa_FeatureVector *__pyx_v_scores = 0; + float __pyx_v_efc; + PyObject *__pyx_v_ewords = NULL; + float __pyx_v_mlfe; + float __pyx_v_max_score; + PyObject *__pyx_v_f = NULL; + PyObject *__pyx_v_e = NULL; + PyObject *__pyx_v_score = NULL; + PyObject *__pyx_v_fwords = NULL; + float __pyx_v_mlef; + struct __pyx_obj_3_sa_FeatureVector *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + PyObject *(*__pyx_t_6)(PyObject *); + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + float __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->extended); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_RefNannySetupContext("score", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":66 + * cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, + * unsigned paircount, unsigned fcount, unsigned fsample_count): + * cdef FeatureVector scores = FeatureVector() # <<<<<<<<<<<<<< + * + * # EgivenFCoherent + */ + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_FeatureVector)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_v_scores = ((struct __pyx_obj_3_sa_FeatureVector *)__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_sa.TrieTable.extended.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_9TrieTable_8extended_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_9TrieTable_8extended_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_8extended_2__set__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_3_sa_9TrieTable_8extended_2__set__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->extended = __pyx_t_1; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("_sa.TrieTable.extended.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_9TrieTable_5count_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_9TrieTable_5count_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_5count___get__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":69 + * + * # EgivenFCoherent + * cdef float efc = paircount/fsample_count # <<<<<<<<<<<<<< + * scores.set(self.fid[EgivenFCoherent], -log10(efc) if efc > 0 else MAXSCORE) + * + */ + if (unlikely(__pyx_v_fsample_count == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[13]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_efc = (((float)__pyx_v_paircount) / __pyx_v_fsample_count); -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":37 - * cdef class TrieTable: - * cdef public int extended - * cdef public int count # <<<<<<<<<<<<<< - * cdef public root - * def __cinit__(self, extended=False): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":70 + * # EgivenFCoherent + * cdef float efc = paircount/fsample_count + * scores.set(self.fid[EgivenFCoherent], -log10(efc) if efc > 0 else MAXSCORE) # <<<<<<<<<<<<<< + * + * # SampleCountF */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__EgivenFCoherent); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if ((__pyx_v_efc > 0.0)) { + __pyx_t_5 = PyFloat_FromDouble((-log10(__pyx_v_efc))); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __pyx_t_5; + __pyx_t_5 = 0; + } else { + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__MAXSCORE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = __pyx_t_5; + __pyx_t_5 = 0; + } + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; -static PyObject *__pyx_pf_3_sa_9TrieTable_5count___get__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":73 + * + * # SampleCountF + * scores.set(self.fid[SampleCountF], log10(1 + fsample_count)) # <<<<<<<<<<<<<< + * + * # CountEF + */ + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__SampleCountF); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyFloat_FromDouble(log10((1 + __pyx_v_fsample_count))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_5 = 0; __pyx_t_1 = 0; - goto __pyx_L0; + __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_sa.TrieTable.count.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":76 + * + * # CountEF + * scores.set(self.fid[CountEF], log10(1 + paircount)) # <<<<<<<<<<<<<< + * + * # MaxLexFgivenE TODO typify + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__CountEF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyFloat_FromDouble(log10((1 + __pyx_v_paircount))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; -/* Python wrapper */ -static int __pyx_pw_3_sa_9TrieTable_5count_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_9TrieTable_5count_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_5count_2__set__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":79 + * + * # MaxLexFgivenE TODO typify + * ewords = ephrase.words # <<<<<<<<<<<<<< + * ewords.append('NULL') + * cdef float mlfe = 0, max_score = -1 + */ + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_ephrase), __pyx_n_s__words); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_v_ewords = __pyx_t_4; + __pyx_t_4 = 0; -static int __pyx_pf_3_sa_9TrieTable_5count_2__set__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->count = __pyx_t_1; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":80 + * # MaxLexFgivenE TODO typify + * ewords = ephrase.words + * ewords.append('NULL') # <<<<<<<<<<<<<< + * cdef float mlfe = 0, max_score = -1 + * for f in fphrase.words: + */ + __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_ewords, ((PyObject *)__pyx_n_s__NULL)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("_sa.TrieTable.count.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":81 + * ewords = ephrase.words + * ewords.append('NULL') + * cdef float mlfe = 0, max_score = -1 # <<<<<<<<<<<<<< + * for f in fphrase.words: + * for e in ewords: + */ + __pyx_v_mlfe = 0.0; + __pyx_v_max_score = -1.0; -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_9TrieTable_4root_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_3_sa_9TrieTable_4root_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_4root___get__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":82 + * ewords.append('NULL') + * cdef float mlfe = 0, max_score = -1 + * for f in fphrase.words: # <<<<<<<<<<<<<< + * for e in ewords: + * score = self.ttable.get_score(f, e, 1) + */ + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_fphrase), __pyx_n_s__words); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { + __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + for (;;) { + if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_5)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_5)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_6(__pyx_t_5); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_f); + __pyx_v_f = __pyx_t_4; + __pyx_t_4 = 0; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":38 - * cdef public int extended - * cdef public int count - * cdef public root # <<<<<<<<<<<<<< - * def __cinit__(self, extended=False): - * self.count = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":83 + * cdef float mlfe = 0, max_score = -1 + * for f in fphrase.words: + * for e in ewords: # <<<<<<<<<<<<<< + * score = self.ttable.get_score(f, e, 1) + * if score > max_score: */ + if (PyList_CheckExact(__pyx_v_ewords) || PyTuple_CheckExact(__pyx_v_ewords)) { + __pyx_t_4 = __pyx_v_ewords; __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_ewords); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_8 = Py_TYPE(__pyx_t_4)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_4)) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_4)) { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++; + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_1 = __pyx_t_8(__pyx_t_4); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_XDECREF(__pyx_v_e); + __pyx_v_e = __pyx_t_1; + __pyx_t_1 = 0; -static PyObject *__pyx_pf_3_sa_9TrieTable_4root___get__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->root); - __pyx_r = __pyx_v_self->root; - goto __pyx_L0; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":84 + * for f in fphrase.words: + * for e in ewords: + * score = self.ttable.get_score(f, e, 1) # <<<<<<<<<<<<<< + * if score > max_score: + * max_score = score + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->ttable), __pyx_n_s__get_score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_f); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_f); + __Pyx_GIVEREF(__pyx_v_f); + __Pyx_INCREF(__pyx_v_e); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_e); + __Pyx_GIVEREF(__pyx_v_e); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_v_score); + __pyx_v_score = __pyx_t_9; + __pyx_t_9 = 0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":85 + * for e in ewords: + * score = self.ttable.get_score(f, e, 1) + * if score > max_score: # <<<<<<<<<<<<<< + * max_score = score + * mlfe += -log10(max_score) if max_score > 0 else MAXSCORE + */ + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_max_score); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PyObject_RichCompare(__pyx_v_score, __pyx_t_9, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_10) { -/* Python wrapper */ -static int __pyx_pw_3_sa_9TrieTable_4root_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_3_sa_9TrieTable_4root_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_4root_2__set__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":86 + * score = self.ttable.get_score(f, e, 1) + * if score > max_score: + * max_score = score # <<<<<<<<<<<<<< + * mlfe += -log10(max_score) if max_score > 0 else MAXSCORE + * scores.set(self.fid[MaxLexFgivenE], mlfe) + */ + __pyx_t_11 = __pyx_PyFloat_AsFloat(__pyx_v_score); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_max_score = __pyx_t_11; + goto __pyx_L7; + } + __pyx_L7:; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; -static int __pyx_pf_3_sa_9TrieTable_4root_2__set__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__", 0); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - __Pyx_GOTREF(__pyx_v_self->root); - __Pyx_DECREF(__pyx_v_self->root); - __pyx_v_self->root = __pyx_v_value; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":87 + * if score > max_score: + * max_score = score + * mlfe += -log10(max_score) if max_score > 0 else MAXSCORE # <<<<<<<<<<<<<< + * scores.set(self.fid[MaxLexFgivenE], mlfe) + * + */ + __pyx_t_4 = PyFloat_FromDouble(__pyx_v_mlfe); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if ((__pyx_v_max_score > 0.0)) { + __pyx_t_9 = PyFloat_FromDouble((-log10(__pyx_v_max_score))); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = __pyx_t_9; + __pyx_t_9 = 0; + } else { + __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__MAXSCORE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = __pyx_t_9; + __pyx_t_9 = 0; + } + __pyx_t_9 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_11 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_v_mlfe = __pyx_t_11; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":88 + * max_score = score + * mlfe += -log10(max_score) if max_score > 0 else MAXSCORE + * scores.set(self.fid[MaxLexFgivenE], mlfe) # <<<<<<<<<<<<<< + * + * # MaxLexEgivenF TODO same + */ + __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__MaxLexFgivenE); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_9); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_mlfe); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_9 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; -/* Python wrapper */ -static int __pyx_pw_3_sa_9TrieTable_4root_5__del__(PyObject *__pyx_v_self); /*proto*/ -static int __pyx_pw_3_sa_9TrieTable_4root_5__del__(PyObject *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_9TrieTable_4root_4__del__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":91 + * + * # MaxLexEgivenF TODO same + * fwords = fphrase.words # <<<<<<<<<<<<<< + * fwords.append('NULL') + * cdef float mlef = 0 + */ + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_fphrase), __pyx_n_s__words); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_fwords = __pyx_t_2; + __pyx_t_2 = 0; -static int __pyx_pf_3_sa_9TrieTable_4root_4__del__(struct __pyx_obj_3_sa_TrieTable *__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->root); - __Pyx_DECREF(__pyx_v_self->root); - __pyx_v_self->root = Py_None; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":92 + * # MaxLexEgivenF TODO same + * fwords = fphrase.words + * fwords.append('NULL') # <<<<<<<<<<<<<< + * cdef float mlef = 0 + * max_score = -1 + */ + __pyx_t_2 = __Pyx_PyObject_Append(__pyx_v_fwords, ((PyObject *)__pyx_n_s__NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":93 + * fwords = fphrase.words + * fwords.append('NULL') + * cdef float mlef = 0 # <<<<<<<<<<<<<< + * max_score = -1 + * for e in ephrase.words: + */ + __pyx_v_mlef = 0.0; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":65 - * - * # returns true if sent_id is contained - * cdef int contains(self, int sent_id): # <<<<<<<<<<<<<< - * return 1 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":94 + * fwords.append('NULL') + * cdef float mlef = 0 + * max_score = -1 # <<<<<<<<<<<<<< + * for e in ephrase.words: + * for f in fwords: */ + __pyx_v_max_score = -1.0; -static int __pyx_f_3_sa_14PhraseLocation_contains(CYTHON_UNUSED struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_self, CYTHON_UNUSED int __pyx_v_sent_id) { + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":95 + * cdef float mlef = 0 + * max_score = -1 + * for e in ephrase.words: # <<<<<<<<<<<<<< + * for f in fwords: + * score = self.ttable.get_score(f, e, 0) + */ + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_ephrase), __pyx_n_s__words); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { + __pyx_t_4 = __pyx_t_2; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + for (;;) { + if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_2 = __pyx_t_6(__pyx_t_4); + if (unlikely(!__pyx_t_2)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XDECREF(__pyx_v_e); + __pyx_v_e = __pyx_t_2; + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":96 + * max_score = -1 + * for e in ephrase.words: + * for f in fwords: # <<<<<<<<<<<<<< + * score = self.ttable.get_score(f, e, 0) + * if score > max_score: + */ + if (PyList_CheckExact(__pyx_v_fwords) || PyTuple_CheckExact(__pyx_v_fwords)) { + __pyx_t_2 = __pyx_v_fwords; __Pyx_INCREF(__pyx_t_2); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_fwords); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_8 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7); __Pyx_INCREF(__pyx_t_5); __pyx_t_7++; + #else + __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_5 = __pyx_t_8(__pyx_t_2); + if (unlikely(!__pyx_t_5)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[13]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_5); + } + __Pyx_XDECREF(__pyx_v_f); + __pyx_v_f = __pyx_t_5; + __pyx_t_5 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":97 + * for e in ephrase.words: + * for f in fwords: + * score = self.ttable.get_score(f, e, 0) # <<<<<<<<<<<<<< + * if score > max_score: + * max_score = score + */ + __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self->ttable), __pyx_n_s__get_score); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_INCREF(__pyx_v_f); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_f); + __Pyx_GIVEREF(__pyx_v_f); + __Pyx_INCREF(__pyx_v_e); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_e); + __Pyx_GIVEREF(__pyx_v_e); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_v_score); + __pyx_v_score = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":98 + * for f in fwords: + * score = self.ttable.get_score(f, e, 0) + * if score > max_score: # <<<<<<<<<<<<<< + * max_score = score + * mlef += -log10(max_score) if max_score > 0 else MAXSCORE + */ + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_max_score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyObject_RichCompare(__pyx_v_score, __pyx_t_1, Py_GT); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_10) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":99 + * score = self.ttable.get_score(f, e, 0) + * if score > max_score: + * max_score = score # <<<<<<<<<<<<<< + * mlef += -log10(max_score) if max_score > 0 else MAXSCORE + * scores.set(self.fid[MaxLexEgivenF], mlef) + */ + __pyx_t_11 = __pyx_PyFloat_AsFloat(__pyx_v_score); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_max_score = __pyx_t_11; + goto __pyx_L12; + } + __pyx_L12:; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":100 + * if score > max_score: + * max_score = score + * mlef += -log10(max_score) if max_score > 0 else MAXSCORE # <<<<<<<<<<<<<< + * scores.set(self.fid[MaxLexEgivenF], mlef) + * + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_mlef); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if ((__pyx_v_max_score > 0.0)) { + __pyx_t_1 = PyFloat_FromDouble((-log10(__pyx_v_max_score))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __pyx_t_1; + __pyx_t_1 = 0; + } else { + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__MAXSCORE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __pyx_t_1; + __pyx_t_1 = 0; + } + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_11 = __pyx_PyFloat_AsFloat(__pyx_t_1); if (unlikely((__pyx_t_11 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_mlef = __pyx_t_11; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":101 + * max_score = score + * mlef += -log10(max_score) if max_score > 0 else MAXSCORE + * scores.set(self.fid[MaxLexEgivenF], mlef) # <<<<<<<<<<<<<< + * + * # IsSingletonF + */ + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__MaxLexEgivenF); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = PyFloat_FromDouble(__pyx_v_mlef); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_1 = 0; + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":104 + * + * # IsSingletonF + * scores.set(self.fid[IsSingletonF], (fcount == 1)) # <<<<<<<<<<<<<< + * + * # IsSingletonFE + */ + __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__IsSingletonF); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_2); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_fcount == 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_2 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":107 + * + * # IsSingletonFE + * scores.set(self.fid[IsSingletonFE], (paircount == 1)) # <<<<<<<<<<<<<< + * + * return scores + */ + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_scores), __pyx_n_s__set); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__IsSingletonFE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyInt_FromLong((__pyx_v_self->fid[__pyx_t_3])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_9 = __Pyx_PyBool_FromLong((__pyx_v_paircount == 1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_1 = 0; + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":109 + * scores.set(self.fid[IsSingletonFE], (paircount == 1)) + * + * return scores # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_scores)); + __pyx_r = __pyx_v_scores; + goto __pyx_L0; + + __pyx_r = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("_sa.DefaultScorer.score", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_scores); + __Pyx_XDECREF(__pyx_v_ewords); + __Pyx_XDECREF(__pyx_v_f); + __Pyx_XDECREF(__pyx_v_e); + __Pyx_XDECREF(__pyx_v_score); + __Pyx_XDECREF(__pyx_v_fwords); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_8TrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_8TrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("contains", 0); + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} + if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; + __pyx_r = __pyx_pf_3_sa_8TrieNode___cinit__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":66 - * # returns true if sent_id is contained - * cdef int contains(self, int sent_id): - * return 1 # <<<<<<<<<<<<<< +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":23 + * cdef public children + * + * def __cinit__(self): # <<<<<<<<<<<<<< + * self.children = {} * - * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, */ - __pyx_r = 1; - goto __pyx_L0; + +static int __pyx_pf_3_sa_8TrieNode___cinit__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":24 + * + * def __cinit__(self): + * self.children = {} # <<<<<<<<<<<<<< + * + * cdef class ExtendedTrieNode(TrieNode): + */ + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __Pyx_GOTREF(__pyx_v_self->children); + __Pyx_DECREF(__pyx_v_self->children); + __pyx_v_self->children = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("_sa.TrieNode.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static int __pyx_pw_3_sa_14PhraseLocation_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_3_sa_14PhraseLocation_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_v_sa_low; - int __pyx_v_sa_high; - int __pyx_v_arr_low; - int __pyx_v_arr_high; - PyObject *__pyx_v_arr = 0; - int __pyx_v_num_subpatterns; +static PyObject *__pyx_pw_3_sa_8TrieNode_8children_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_8TrieNode_8children_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_8TrieNode_8children___get__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":21 + * + * cdef class TrieNode: + * cdef public children # <<<<<<<<<<<<<< + * + * def __cinit__(self): + */ + +static PyObject *__pyx_pf_3_sa_8TrieNode_8children___get__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->children); + __pyx_r = __pyx_v_self->children; + 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_3_sa_8TrieNode_8children_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_8TrieNode_8children_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_8TrieNode_8children_2__set__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_8TrieNode_8children_2__set__(struct __pyx_obj_3_sa_TrieNode *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->children); + __Pyx_DECREF(__pyx_v_self->children); + __pyx_v_self->children = __pyx_v_value; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_8TrieNode_8children_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_3_sa_8TrieNode_8children_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_8TrieNode_8children_4__del__(((struct __pyx_obj_3_sa_TrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_8TrieNode_8children_4__del__(struct __pyx_obj_3_sa_TrieNode *__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->children); + __Pyx_DECREF(__pyx_v_self->children); + __pyx_v_self->children = Py_None; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_phrase = 0; + PyObject *__pyx_v_phrase_location = 0; + PyObject *__pyx_v_suffix_link = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sa_low,&__pyx_n_s__sa_high,&__pyx_n_s__arr_low,&__pyx_n_s__arr_high,&__pyx_n_s__arr,&__pyx_n_s__num_subpatterns,0}; - PyObject* values[6] = {0,0,0,0,0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__phrase,&__pyx_n_s__phrase_location,&__pyx_n_s__suffix_link,0}; + PyObject* values[3] = {0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":69 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":31 + * cdef public suffix_link * - * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, - * arr=None, int num_subpatterns=1): # <<<<<<<<<<<<<< - * self.sa_low = sa_low - * self.sa_high = sa_high + * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): # <<<<<<<<<<<<<< + * self.phrase = phrase + * self.phrase_location = phrase_location */ - values[4] = ((PyObject *)Py_None); + values[0] = ((PyObject *)Py_None); + values[1] = ((PyObject *)Py_None); + values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -35363,43 +36420,25 @@ static int __pyx_pw_3_sa_14PhraseLocation_1__cinit__(PyObject *__pyx_v_self, PyO switch (pos_args) { case 0: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sa_low); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__phrase); if (value) { values[0] = value; kw_args--; } } case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sa_high); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__phrase_location); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arr_low); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__suffix_link); if (value) { values[2] = value; kw_args--; } } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arr_high); - if (value) { values[3] = value; kw_args--; } - } - case 4: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arr); - if (value) { values[4] = value; kw_args--; } - } - case 5: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_subpatterns); - if (value) { values[5] = value; kw_args--; } - } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __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[8]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -35407,147 +36446,348 @@ static int __pyx_pw_3_sa_14PhraseLocation_1__cinit__(PyObject *__pyx_v_self, PyO default: goto __pyx_L5_argtuple_error; } } - if (values[0]) { - __pyx_v_sa_low = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_sa_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_sa_low = ((int)-1); - } - if (values[1]) { - __pyx_v_sa_high = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_sa_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_sa_high = ((int)-1); - } - if (values[2]) { - __pyx_v_arr_low = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_arr_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_arr_low = ((int)-1); - } - if (values[3]) { - __pyx_v_arr_high = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_arr_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_arr_high = ((int)-1); - } - __pyx_v_arr = values[4]; - if (values[5]) { - __pyx_v_num_subpatterns = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_num_subpatterns == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_num_subpatterns = ((int)1); - } + __pyx_v_phrase = values[0]; + __pyx_v_phrase_location = values[1]; + __pyx_v_suffix_link = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.PhraseLocation.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.ExtendedTrieNode.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_14PhraseLocation___cinit__(((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_v_self), __pyx_v_sa_low, __pyx_v_sa_high, __pyx_v_arr_low, __pyx_v_arr_high, __pyx_v_arr, __pyx_v_num_subpatterns); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode___cinit__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), __pyx_v_phrase, __pyx_v_phrase_location, __pyx_v_suffix_link); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":68 - * return 1 - * - * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, # <<<<<<<<<<<<<< - * arr=None, int num_subpatterns=1): - * self.sa_low = sa_low - */ - -static int __pyx_pf_3_sa_14PhraseLocation___cinit__(struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_self, int __pyx_v_sa_low, int __pyx_v_sa_high, int __pyx_v_arr_low, int __pyx_v_arr_high, PyObject *__pyx_v_arr, int __pyx_v_num_subpatterns) { +static int __pyx_pf_3_sa_16ExtendedTrieNode___cinit__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_phrase, PyObject *__pyx_v_phrase_location, PyObject *__pyx_v_suffix_link) { int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":70 - * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, - * arr=None, int num_subpatterns=1): - * self.sa_low = sa_low # <<<<<<<<<<<<<< - * self.sa_high = sa_high - * self.arr_low = arr_low + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":32 + * + * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): + * self.phrase = phrase # <<<<<<<<<<<<<< + * self.phrase_location = phrase_location + * self.suffix_link = suffix_link */ - __pyx_v_self->sa_low = __pyx_v_sa_low; + __Pyx_INCREF(__pyx_v_phrase); + __Pyx_GIVEREF(__pyx_v_phrase); + __Pyx_GOTREF(__pyx_v_self->phrase); + __Pyx_DECREF(__pyx_v_self->phrase); + __pyx_v_self->phrase = __pyx_v_phrase; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":71 - * arr=None, int num_subpatterns=1): - * self.sa_low = sa_low - * self.sa_high = sa_high # <<<<<<<<<<<<<< - * self.arr_low = arr_low - * self.arr_high = arr_high + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":33 + * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): + * self.phrase = phrase + * self.phrase_location = phrase_location # <<<<<<<<<<<<<< + * self.suffix_link = suffix_link + * */ - __pyx_v_self->sa_high = __pyx_v_sa_high; + __Pyx_INCREF(__pyx_v_phrase_location); + __Pyx_GIVEREF(__pyx_v_phrase_location); + __Pyx_GOTREF(__pyx_v_self->phrase_location); + __Pyx_DECREF(__pyx_v_self->phrase_location); + __pyx_v_self->phrase_location = __pyx_v_phrase_location; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":72 - * self.sa_low = sa_low - * self.sa_high = sa_high - * self.arr_low = arr_low # <<<<<<<<<<<<<< - * self.arr_high = arr_high - * self.arr = arr + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":34 + * self.phrase = phrase + * self.phrase_location = phrase_location + * self.suffix_link = suffix_link # <<<<<<<<<<<<<< + * + * */ - __pyx_v_self->arr_low = __pyx_v_arr_low; + __Pyx_INCREF(__pyx_v_suffix_link); + __Pyx_GIVEREF(__pyx_v_suffix_link); + __Pyx_GOTREF(__pyx_v_self->suffix_link); + __Pyx_DECREF(__pyx_v_self->suffix_link); + __pyx_v_self->suffix_link = __pyx_v_suffix_link; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":73 - * self.sa_high = sa_high - * self.arr_low = arr_low - * self.arr_high = arr_high # <<<<<<<<<<<<<< - * self.arr = arr - * self.num_subpatterns = num_subpatterns - */ - __pyx_v_self->arr_high = __pyx_v_arr_high; + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":74 - * self.arr_low = arr_low - * self.arr_high = arr_high - * self.arr = arr # <<<<<<<<<<<<<< - * self.num_subpatterns = num_subpatterns - * - */ - if (!(likely(((__pyx_v_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_arr, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_INCREF(__pyx_v_arr); - __Pyx_GIVEREF(__pyx_v_arr); - __Pyx_GOTREF(__pyx_v_self->arr); - __Pyx_DECREF(((PyObject *)__pyx_v_self->arr)); - __pyx_v_self->arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_v_arr); +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_6phrase_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_6phrase_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_6phrase___get__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":75 - * self.arr_high = arr_high - * self.arr = arr - * self.num_subpatterns = num_subpatterns # <<<<<<<<<<<<<< - * +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":27 * + * cdef class ExtendedTrieNode(TrieNode): + * cdef public phrase # <<<<<<<<<<<<<< + * cdef public phrase_location + * cdef public suffix_link */ - __pyx_v_self->num_subpatterns = __pyx_v_num_subpatterns; - __pyx_r = 0; +static PyObject *__pyx_pf_3_sa_16ExtendedTrieNode_6phrase___get__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->phrase); + __pyx_r = __pyx_v_self->phrase; goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("_sa.PhraseLocation.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; + + __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_3_sa_7Sampler_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_3_sa_7Sampler_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_v_sample_size; - struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray = 0; +static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sample_size,&__pyx_n_s__fsarray,0}; - PyObject* values[2] = {0,0}; + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_2__set__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_2__set__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->phrase); + __Pyx_DECREF(__pyx_v_self->phrase); + __pyx_v_self->phrase = __pyx_v_value; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_4__del__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_16ExtendedTrieNode_6phrase_4__del__(struct __pyx_obj_3_sa_ExtendedTrieNode *__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->phrase); + __Pyx_DECREF(__pyx_v_self->phrase); + __pyx_v_self->phrase = Py_None; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location___get__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":28 + * cdef class ExtendedTrieNode(TrieNode): + * cdef public phrase + * cdef public phrase_location # <<<<<<<<<<<<<< + * cdef public suffix_link + * + */ + +static PyObject *__pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location___get__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->phrase_location); + __pyx_r = __pyx_v_self->phrase_location; + 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_3_sa_16ExtendedTrieNode_15phrase_location_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_2__set__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_2__set__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->phrase_location); + __Pyx_DECREF(__pyx_v_self->phrase_location); + __pyx_v_self->phrase_location = __pyx_v_value; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_4__del__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_16ExtendedTrieNode_15phrase_location_4__del__(struct __pyx_obj_3_sa_ExtendedTrieNode *__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->phrase_location); + __Pyx_DECREF(__pyx_v_self->phrase_location); + __pyx_v_self->phrase_location = Py_None; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link___get__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":29 + * cdef public phrase + * cdef public phrase_location + * cdef public suffix_link # <<<<<<<<<<<<<< + * + * def __cinit__(self, phrase=None, phrase_location=None, suffix_link=None): + */ + +static PyObject *__pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link___get__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->suffix_link); + __pyx_r = __pyx_v_self->suffix_link; + 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_3_sa_16ExtendedTrieNode_11suffix_link_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_2__set__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_2__set__(struct __pyx_obj_3_sa_ExtendedTrieNode *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->suffix_link); + __Pyx_DECREF(__pyx_v_self->suffix_link); + __pyx_v_self->suffix_link = __pyx_v_value; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_4__del__(((struct __pyx_obj_3_sa_ExtendedTrieNode *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +static int __pyx_pf_3_sa_16ExtendedTrieNode_11suffix_link_4__del__(struct __pyx_obj_3_sa_ExtendedTrieNode *__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->suffix_link); + __Pyx_DECREF(__pyx_v_self->suffix_link); + __pyx_v_self->suffix_link = Py_None; + + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_9TrieTable_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_9TrieTable_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_extended = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__extended,0}; + PyObject* values[1] = {0}; + values[0] = __pyx_k_101; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; default: goto __pyx_L5_argtuple_error; @@ -35555,153 +36795,124 @@ static int __pyx_pw_3_sa_7Sampler_1__cinit__(PyObject *__pyx_v_self, PyObject *_ kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_size)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fsarray)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__extended); + if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __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[8]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } } - __pyx_v_sample_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_sample_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_v_fsarray = ((struct __pyx_obj_3_sa_SuffixArray *)values[1]); + __pyx_v_extended = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.Sampler.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.TrieTable.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fsarray), __pyx_ptype_3_sa_SuffixArray, 1, "fsarray", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_7Sampler___cinit__(((struct __pyx_obj_3_sa_Sampler *)__pyx_v_self), __pyx_v_sample_size, __pyx_v_fsarray); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; + __pyx_r = __pyx_pf_3_sa_9TrieTable___cinit__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), __pyx_v_extended); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":86 - * cdef IntList sa - * - * def __cinit__(self, int sample_size, SuffixArray fsarray): # <<<<<<<<<<<<<< - * self.sample_size = sample_size - * self.sa = fsarray.sa +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":41 + * cdef public int count + * cdef public root + * def __cinit__(self, extended=False): # <<<<<<<<<<<<<< + * self.count = 0 + * self.extended = extended */ -static int __pyx_pf_3_sa_7Sampler___cinit__(struct __pyx_obj_3_sa_Sampler *__pyx_v_self, int __pyx_v_sample_size, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray) { +static int __pyx_pf_3_sa_9TrieTable___cinit__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_extended) { int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":87 - * - * def __cinit__(self, int sample_size, SuffixArray fsarray): - * self.sample_size = sample_size # <<<<<<<<<<<<<< - * self.sa = fsarray.sa - * if sample_size > 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":42 + * cdef public root + * def __cinit__(self, extended=False): + * self.count = 0 # <<<<<<<<<<<<<< + * self.extended = extended + * if extended: */ - __pyx_v_self->sample_size = __pyx_v_sample_size; + __pyx_v_self->count = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":88 - * def __cinit__(self, int sample_size, SuffixArray fsarray): - * self.sample_size = sample_size - * self.sa = fsarray.sa # <<<<<<<<<<<<<< - * if sample_size > 0: - * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":43 + * def __cinit__(self, extended=False): + * self.count = 0 + * self.extended = extended # <<<<<<<<<<<<<< + * if extended: + * self.root = ExtendedTrieNode() */ - __Pyx_INCREF(((PyObject *)__pyx_v_fsarray->sa)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fsarray->sa)); - __Pyx_GOTREF(__pyx_v_self->sa); - __Pyx_DECREF(((PyObject *)__pyx_v_self->sa)); - __pyx_v_self->sa = __pyx_v_fsarray->sa; + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_extended); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->extended = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":89 - * self.sample_size = sample_size - * self.sa = fsarray.sa - * if sample_size > 0: # <<<<<<<<<<<<<< - * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":44 + * self.count = 0 + * self.extended = extended + * if extended: # <<<<<<<<<<<<<< + * self.root = ExtendedTrieNode() * else: */ - __pyx_t_1 = (__pyx_v_sample_size > 0); - if (__pyx_t_1) { + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_extended); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":90 - * self.sa = fsarray.sa - * if sample_size > 0: - * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":45 + * self.extended = extended + * if extended: + * self.root = ExtendedTrieNode() # <<<<<<<<<<<<<< * else: - * logger.info("Sampling strategy: no sampling") + * self.root = TrieNode() */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_sample_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_100)); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_100)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_100)); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->root); + __Pyx_DECREF(__pyx_v_self->root); + __pyx_v_self->root = __pyx_t_3; + __pyx_t_3 = 0; goto __pyx_L3; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":92 - * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":47 + * self.root = ExtendedTrieNode() * else: - * logger.info("Sampling strategy: no sampling") # <<<<<<<<<<<<<< + * self.root = TrieNode() # <<<<<<<<<<<<<< * - * def sample(self, PhraseLocation phrase_location): + * # linked list structure for storing matches in BaselineRuleFactory */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_102), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_self->root); + __Pyx_DECREF(__pyx_v_self->root); + __pyx_v_self->root = __pyx_t_3; + __pyx_t_3 = 0; } __pyx_L3:; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("_sa.Sampler.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.TrieTable.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); @@ -35709,535 +36920,269 @@ static int __pyx_pf_3_sa_7Sampler___cinit__(struct __pyx_obj_3_sa_Sampler *__pyx } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_7Sampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase_location); /*proto*/ -static char __pyx_doc_3_sa_7Sampler_2sample[] = "Returns a sample of the locations for\n the phrase. If there are less than self.sample_size\n locations, return all of them; otherwise, return\n up to self.sample_size locations. In the latter case,\n we choose to sample UNIFORMLY -- that is, the locations\n are chosen at uniform intervals over the entire set, rather\n than randomly. This makes the algorithm deterministic, which\n is good for things like MERT"; -static PyObject *__pyx_pw_3_sa_7Sampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase_location) { +static PyObject *__pyx_pw_3_sa_9TrieTable_8extended_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_9TrieTable_8extended_1__get__(PyObject *__pyx_v_self) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("sample (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_phrase_location), __pyx_ptype_3_sa_PhraseLocation, 1, "phrase_location", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_7Sampler_2sample(((struct __pyx_obj_3_sa_Sampler *)__pyx_v_self), ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_v_phrase_location)); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_8extended___get__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":94 - * logger.info("Sampling strategy: no sampling") +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":38 * - * def sample(self, PhraseLocation phrase_location): # <<<<<<<<<<<<<< - * '''Returns a sample of the locations for - * the phrase. If there are less than self.sample_size + * cdef class TrieTable: + * cdef public int extended # <<<<<<<<<<<<<< + * cdef public int count + * cdef public root */ -static PyObject *__pyx_pf_3_sa_7Sampler_2sample(struct __pyx_obj_3_sa_Sampler *__pyx_v_self, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_phrase_location) { - struct __pyx_obj_3_sa_IntList *__pyx_v_sample = 0; - double __pyx_v_i; - double __pyx_v_stepsize; - int __pyx_v_num_locations; - int __pyx_v_val; - int __pyx_v_j; +static PyObject *__pyx_pf_3_sa_9TrieTable_8extended___get__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self) { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("sample", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":107 - * cdef int num_locations, val, j - * - * sample = IntList() # <<<<<<<<<<<<<< - * if phrase_location.arr is None: - * num_locations = phrase_location.sa_high - phrase_location.sa_low - */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->extended); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_v_sample = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_r = __pyx_t_1; __pyx_t_1 = 0; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":108 - * - * sample = IntList() - * if phrase_location.arr is None: # <<<<<<<<<<<<<< - * num_locations = phrase_location.sa_high - phrase_location.sa_low - * if self.sample_size == -1 or num_locations <= self.sample_size: - */ - __pyx_t_2 = (((PyObject *)__pyx_v_phrase_location->arr) == Py_None); - if (__pyx_t_2) { + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("_sa.TrieTable.extended.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":109 - * sample = IntList() - * if phrase_location.arr is None: - * num_locations = phrase_location.sa_high - phrase_location.sa_low # <<<<<<<<<<<<<< - * if self.sample_size == -1 or num_locations <= self.sample_size: - * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) - */ - __pyx_v_num_locations = (__pyx_v_phrase_location->sa_high - __pyx_v_phrase_location->sa_low); +/* Python wrapper */ +static int __pyx_pw_3_sa_9TrieTable_8extended_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_9TrieTable_8extended_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_8extended_2__set__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":110 - * if phrase_location.arr is None: - * num_locations = phrase_location.sa_high - phrase_location.sa_low - * if self.sample_size == -1 or num_locations <= self.sample_size: # <<<<<<<<<<<<<< - * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) - * else: - */ - __pyx_t_2 = (__pyx_v_self->sample_size == -1); - if (!__pyx_t_2) { - __pyx_t_3 = (__pyx_v_num_locations <= __pyx_v_self->sample_size); - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (__pyx_t_4) { +static int __pyx_pf_3_sa_9TrieTable_8extended_2__set__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__set__", 0); + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->extended = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":111 - * num_locations = phrase_location.sa_high - phrase_location.sa_low - * if self.sample_size == -1 or num_locations <= self.sample_size: - * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) # <<<<<<<<<<<<<< - * else: - * stepsize = float(num_locations)/float(self.sample_size) - */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_sample->__pyx_vtab)->_extend_arr(__pyx_v_sample, (__pyx_v_self->sa->arr + __pyx_v_phrase_location->sa_low), __pyx_v_num_locations); - goto __pyx_L4; - } - /*else*/ { + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_sa.TrieTable.extended.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":113 - * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) - * else: - * stepsize = float(num_locations)/float(self.sample_size) # <<<<<<<<<<<<<< - * i = phrase_location.sa_low - * while i < phrase_location.sa_high and sample.len < self.sample_size: - */ - if (unlikely(((double)__pyx_v_self->sample_size) == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_stepsize = (((double)__pyx_v_num_locations) / ((double)__pyx_v_self->sample_size)); +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_9TrieTable_5count_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_9TrieTable_5count_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_5count___get__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":114 - * else: - * stepsize = float(num_locations)/float(self.sample_size) - * i = phrase_location.sa_low # <<<<<<<<<<<<<< - * while i < phrase_location.sa_high and sample.len < self.sample_size: - * '''Note: int(i) not guaranteed to have the desired - */ - __pyx_v_i = __pyx_v_phrase_location->sa_low; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":115 - * stepsize = float(num_locations)/float(self.sample_size) - * i = phrase_location.sa_low - * while i < phrase_location.sa_high and sample.len < self.sample_size: # <<<<<<<<<<<<<< - * '''Note: int(i) not guaranteed to have the desired - * effect, according to the python documentation''' - */ - while (1) { - __pyx_t_4 = (__pyx_v_i < __pyx_v_phrase_location->sa_high); - if (__pyx_t_4) { - __pyx_t_2 = (__pyx_v_sample->len < __pyx_v_self->sample_size); - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_4; - } - if (!__pyx_t_3) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":118 - * '''Note: int(i) not guaranteed to have the desired - * effect, according to the python documentation''' - * if fmod(i,1.0) > 0.5: # <<<<<<<<<<<<<< - * val = int(ceil(i)) - * else: - */ - __pyx_t_3 = (fmod(__pyx_v_i, 1.0) > 0.5); - if (__pyx_t_3) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":119 - * effect, according to the python documentation''' - * if fmod(i,1.0) > 0.5: - * val = int(ceil(i)) # <<<<<<<<<<<<<< - * else: - * val = int(floor(i)) - */ - __pyx_v_val = ((int)ceil(__pyx_v_i)); - goto __pyx_L7; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":121 - * val = int(ceil(i)) - * else: - * val = int(floor(i)) # <<<<<<<<<<<<<< - * sample._append(self.sa.arr[val]) - * i = i + stepsize - */ - __pyx_v_val = ((int)floor(__pyx_v_i)); - } - __pyx_L7:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":122 - * else: - * val = int(floor(i)) - * sample._append(self.sa.arr[val]) # <<<<<<<<<<<<<< - * i = i + stepsize - * else: - */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_sample->__pyx_vtab)->_append(__pyx_v_sample, (__pyx_v_self->sa->arr[__pyx_v_val])); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":123 - * val = int(floor(i)) - * sample._append(self.sa.arr[val]) - * i = i + stepsize # <<<<<<<<<<<<<< - * else: - * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns - */ - __pyx_v_i = (__pyx_v_i + __pyx_v_stepsize); - } - } - __pyx_L4:; - goto __pyx_L3; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":125 - * i = i + stepsize - * else: - * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns # <<<<<<<<<<<<<< - * if self.sample_size == -1 or num_locations <= self.sample_size: - * sample = phrase_location.arr - */ - __pyx_t_5 = (__pyx_v_phrase_location->arr_high - __pyx_v_phrase_location->arr_low); - if (unlikely(__pyx_v_phrase_location->num_subpatterns == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_phrase_location->num_subpatterns == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_5))) { - PyErr_Format(PyExc_OverflowError, "value too large to perform division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_num_locations = __Pyx_div_int(__pyx_t_5, __pyx_v_phrase_location->num_subpatterns); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":126 - * else: - * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns - * if self.sample_size == -1 or num_locations <= self.sample_size: # <<<<<<<<<<<<<< - * sample = phrase_location.arr - * else: - */ - __pyx_t_3 = (__pyx_v_self->sample_size == -1); - if (!__pyx_t_3) { - __pyx_t_4 = (__pyx_v_num_locations <= __pyx_v_self->sample_size); - __pyx_t_2 = __pyx_t_4; - } else { - __pyx_t_2 = __pyx_t_3; - } - if (__pyx_t_2) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":127 - * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns - * if self.sample_size == -1 or num_locations <= self.sample_size: - * sample = phrase_location.arr # <<<<<<<<<<<<<< - * else: - * stepsize = float(num_locations)/float(self.sample_size) - */ - __Pyx_INCREF(((PyObject *)__pyx_v_phrase_location->arr)); - __Pyx_DECREF(((PyObject *)__pyx_v_sample)); - __pyx_v_sample = __pyx_v_phrase_location->arr; - goto __pyx_L8; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":129 - * sample = phrase_location.arr - * else: - * stepsize = float(num_locations)/float(self.sample_size) # <<<<<<<<<<<<<< - * i = phrase_location.arr_low - * while i < num_locations and sample.len < self.sample_size * phrase_location.num_subpatterns: - */ - if (unlikely(((double)__pyx_v_self->sample_size) == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_stepsize = (((double)__pyx_v_num_locations) / ((double)__pyx_v_self->sample_size)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":130 - * else: - * stepsize = float(num_locations)/float(self.sample_size) - * i = phrase_location.arr_low # <<<<<<<<<<<<<< - * while i < num_locations and sample.len < self.sample_size * phrase_location.num_subpatterns: - * '''Note: int(i) not guaranteed to have the desired - */ - __pyx_v_i = __pyx_v_phrase_location->arr_low; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":131 - * stepsize = float(num_locations)/float(self.sample_size) - * i = phrase_location.arr_low - * while i < num_locations and sample.len < self.sample_size * phrase_location.num_subpatterns: # <<<<<<<<<<<<<< - * '''Note: int(i) not guaranteed to have the desired - * effect, according to the python documentation''' - */ - while (1) { - __pyx_t_2 = (__pyx_v_i < __pyx_v_num_locations); - if (__pyx_t_2) { - __pyx_t_3 = (__pyx_v_sample->len < (__pyx_v_self->sample_size * __pyx_v_phrase_location->num_subpatterns)); - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (!__pyx_t_4) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":134 - * '''Note: int(i) not guaranteed to have the desired - * effect, according to the python documentation''' - * if fmod(i,1.0) > 0.5: # <<<<<<<<<<<<<< - * val = int(ceil(i)) - * else: - */ - __pyx_t_4 = (fmod(__pyx_v_i, 1.0) > 0.5); - if (__pyx_t_4) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":135 - * effect, according to the python documentation''' - * if fmod(i,1.0) > 0.5: - * val = int(ceil(i)) # <<<<<<<<<<<<<< - * else: - * val = int(floor(i)) - */ - __pyx_v_val = ((int)ceil(__pyx_v_i)); - goto __pyx_L11; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":137 - * val = int(ceil(i)) - * else: - * val = int(floor(i)) # <<<<<<<<<<<<<< - * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) - * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) - */ - __pyx_v_val = ((int)floor(__pyx_v_i)); - } - __pyx_L11:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":138 - * else: - * val = int(floor(i)) - * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) # <<<<<<<<<<<<<< - * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) - * i = i + stepsize - */ - __pyx_v_j = (__pyx_v_phrase_location->arr_low + (__pyx_v_val * __pyx_v_phrase_location->num_subpatterns)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":139 - * val = int(floor(i)) - * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) - * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) # <<<<<<<<<<<<<< - * i = i + stepsize - * return sample - */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_sample->__pyx_vtab)->_extend_arr(__pyx_v_sample, (__pyx_v_phrase_location->arr->arr + __pyx_v_j), __pyx_v_phrase_location->num_subpatterns); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":140 - * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) - * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) - * i = i + stepsize # <<<<<<<<<<<<<< - * return sample - * +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":39 + * cdef class TrieTable: + * cdef public int extended + * cdef public int count # <<<<<<<<<<<<<< + * cdef public root + * def __cinit__(self, extended=False): */ - __pyx_v_i = (__pyx_v_i + __pyx_v_stepsize); - } - } - __pyx_L8:; - } - __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":141 - * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) - * i = i + stepsize - * return sample # <<<<<<<<<<<<<< - * - * - */ +static PyObject *__pyx_pf_3_sa_9TrieTable_5count___get__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_sample)); - __pyx_r = ((PyObject *)__pyx_v_sample); + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->count); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("_sa.Sampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.TrieTable.count.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_sample); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":153 - * - * - * cdef void assign_matching(Matching* m, int* arr, int start, int step, int* sent_id_arr): # <<<<<<<<<<<<<< - * m.arr = arr - * m.start = start - */ +/* Python wrapper */ +static int __pyx_pw_3_sa_9TrieTable_5count_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_9TrieTable_5count_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_5count_2__set__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), ((PyObject *)__pyx_v_value)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} -static void __pyx_f_3_sa_assign_matching(struct __pyx_t_3_sa_Matching *__pyx_v_m, int *__pyx_v_arr, int __pyx_v_start, int __pyx_v_step, int *__pyx_v_sent_id_arr) { +static int __pyx_pf_3_sa_9TrieTable_5count_2__set__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("assign_matching", 0); + int __pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__set__", 0); + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->count = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":154 - * - * cdef void assign_matching(Matching* m, int* arr, int start, int step, int* sent_id_arr): - * m.arr = arr # <<<<<<<<<<<<<< - * m.start = start - * m.end = start + step - */ - __pyx_v_m->arr = __pyx_v_arr; + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_sa.TrieTable.count.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":155 - * cdef void assign_matching(Matching* m, int* arr, int start, int step, int* sent_id_arr): - * m.arr = arr - * m.start = start # <<<<<<<<<<<<<< - * m.end = start + step - * m.sent_id = sent_id_arr[arr[start]] - */ - __pyx_v_m->start = __pyx_v_start; +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_9TrieTable_4root_1__get__(PyObject *__pyx_v_self); /*proto*/ +static PyObject *__pyx_pw_3_sa_9TrieTable_4root_1__get__(PyObject *__pyx_v_self) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_4root___get__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":156 - * m.arr = arr - * m.start = start - * m.end = start + step # <<<<<<<<<<<<<< - * m.sent_id = sent_id_arr[arr[start]] - * m.size = step +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":40 + * cdef public int extended + * cdef public int count + * cdef public root # <<<<<<<<<<<<<< + * def __cinit__(self, extended=False): + * self.count = 0 */ - __pyx_v_m->end = (__pyx_v_start + __pyx_v_step); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":157 - * m.start = start - * m.end = start + step - * m.sent_id = sent_id_arr[arr[start]] # <<<<<<<<<<<<<< - * m.size = step - * - */ - __pyx_v_m->sent_id = (__pyx_v_sent_id_arr[(__pyx_v_arr[__pyx_v_start])]); +static PyObject *__pyx_pf_3_sa_9TrieTable_4root___get__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__get__", 0); + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_self->root); + __pyx_r = __pyx_v_self->root; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":158 - * m.end = start + step - * m.sent_id = sent_id_arr[arr[start]] - * m.size = step # <<<<<<<<<<<<<< - * - * - */ - __pyx_v_m->size = __pyx_v_step; + __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_3_sa_9TrieTable_4root_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ +static int __pyx_pw_3_sa_9TrieTable_4root_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_4root_2__set__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self), ((PyObject *)__pyx_v_value)); __Pyx_RefNannyFinishContext(); + return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":161 - * - * - * cdef int* append_combined_matching(int* arr, Matching* loc1, Matching* loc2, # <<<<<<<<<<<<<< - * int offset_by_one, int num_subpatterns, int* result_len): - * cdef int i, new_len - */ +static int __pyx_pf_3_sa_9TrieTable_4root_2__set__(struct __pyx_obj_3_sa_TrieTable *__pyx_v_self, PyObject *__pyx_v_value) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_value); + __Pyx_GIVEREF(__pyx_v_value); + __Pyx_GOTREF(__pyx_v_self->root); + __Pyx_DECREF(__pyx_v_self->root); + __pyx_v_self->root = __pyx_v_value; -static int *__pyx_f_3_sa_append_combined_matching(int *__pyx_v_arr, struct __pyx_t_3_sa_Matching *__pyx_v_loc1, struct __pyx_t_3_sa_Matching *__pyx_v_loc2, CYTHON_UNUSED int __pyx_v_offset_by_one, int __pyx_v_num_subpatterns, int *__pyx_v_result_len) { - int __pyx_v_i; - int __pyx_v_new_len; - int *__pyx_r; + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static int __pyx_pw_3_sa_9TrieTable_4root_5__del__(PyObject *__pyx_v_self); /*proto*/ +static int __pyx_pw_3_sa_9TrieTable_4root_5__del__(PyObject *__pyx_v_self) { + int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - __Pyx_RefNannySetupContext("append_combined_matching", 0); + __Pyx_RefNannySetupContext("__del__ (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_9TrieTable_4root_4__del__(((struct __pyx_obj_3_sa_TrieTable *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":165 - * cdef int i, new_len - * - * new_len = result_len[0] + num_subpatterns # <<<<<<<<<<<<<< - * arr = realloc(arr, new_len*sizeof(int)) - * - */ - __pyx_v_new_len = ((__pyx_v_result_len[0]) + __pyx_v_num_subpatterns); +static int __pyx_pf_3_sa_9TrieTable_4root_4__del__(struct __pyx_obj_3_sa_TrieTable *__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->root); + __Pyx_DECREF(__pyx_v_self->root); + __pyx_v_self->root = Py_None; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":166 - * - * new_len = result_len[0] + num_subpatterns - * arr = realloc(arr, new_len*sizeof(int)) # <<<<<<<<<<<<<< - * - * for i from 0 <= i < loc1.size: - */ - __pyx_v_arr = ((int *)realloc(__pyx_v_arr, (__pyx_v_new_len * (sizeof(int))))); + __pyx_r = 0; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":168 - * arr = realloc(arr, new_len*sizeof(int)) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":67 * - * for i from 0 <= i < loc1.size: # <<<<<<<<<<<<<< - * arr[result_len[0]+i] = loc1.arr[loc1.start+i] - * if num_subpatterns > loc1.size: - */ - __pyx_t_1 = __pyx_v_loc1->size; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":169 + * # returns true if sent_id is contained + * cdef int contains(self, int sent_id): # <<<<<<<<<<<<<< + * return 1 * - * for i from 0 <= i < loc1.size: - * arr[result_len[0]+i] = loc1.arr[loc1.start+i] # <<<<<<<<<<<<<< - * if num_subpatterns > loc1.size: - * arr[new_len-1] = loc2.arr[loc2.end-1] - */ - (__pyx_v_arr[((__pyx_v_result_len[0]) + __pyx_v_i)]) = (__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]); - } - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":170 - * for i from 0 <= i < loc1.size: - * arr[result_len[0]+i] = loc1.arr[loc1.start+i] - * if num_subpatterns > loc1.size: # <<<<<<<<<<<<<< - * arr[new_len-1] = loc2.arr[loc2.end-1] - * result_len[0] = new_len - */ - __pyx_t_2 = (__pyx_v_num_subpatterns > __pyx_v_loc1->size); - if (__pyx_t_2) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":171 - * arr[result_len[0]+i] = loc1.arr[loc1.start+i] - * if num_subpatterns > loc1.size: - * arr[new_len-1] = loc2.arr[loc2.end-1] # <<<<<<<<<<<<<< - * result_len[0] = new_len - * return arr */ - (__pyx_v_arr[(__pyx_v_new_len - 1)]) = (__pyx_v_loc2->arr[(__pyx_v_loc2->end - 1)]); - goto __pyx_L5; - } - __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":172 - * if num_subpatterns > loc1.size: - * arr[new_len-1] = loc2.arr[loc2.end-1] - * result_len[0] = new_len # <<<<<<<<<<<<<< - * return arr - * - */ - (__pyx_v_result_len[0]) = __pyx_v_new_len; +static int __pyx_f_3_sa_14PhraseLocation_contains(CYTHON_UNUSED struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_self, CYTHON_UNUSED int __pyx_v_sent_id) { + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("contains", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":173 - * arr[new_len-1] = loc2.arr[loc2.end-1] - * result_len[0] = new_len - * return arr # <<<<<<<<<<<<<< - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":68 + * # returns true if sent_id is contained + * cdef int contains(self, int sent_id): + * return 1 # <<<<<<<<<<<<<< * + * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, */ - __pyx_r = __pyx_v_arr; + __pyx_r = 1; goto __pyx_L0; __pyx_r = 0; @@ -36246,293 +37191,34 @@ static int *__pyx_f_3_sa_append_combined_matching(int *__pyx_v_arr, struct __pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":176 - * - * - * cdef int* extend_arr(int* arr, int* arr_len, int* appendix, int appendix_len): # <<<<<<<<<<<<<< - * cdef int new_len - * - */ - -static int *__pyx_f_3_sa_extend_arr(int *__pyx_v_arr, int *__pyx_v_arr_len, int *__pyx_v_appendix, int __pyx_v_appendix_len) { - int __pyx_v_new_len; - int *__pyx_r; +/* Python wrapper */ +static int __pyx_pw_3_sa_14PhraseLocation_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_14PhraseLocation_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_sa_low; + int __pyx_v_sa_high; + int __pyx_v_arr_low; + int __pyx_v_arr_high; + PyObject *__pyx_v_arr = 0; + int __pyx_v_num_subpatterns; + int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("extend_arr", 0); + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sa_low,&__pyx_n_s__sa_high,&__pyx_n_s__arr_low,&__pyx_n_s__arr_high,&__pyx_n_s__arr,&__pyx_n_s__num_subpatterns,0}; + PyObject* values[6] = {0,0,0,0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":179 - * cdef int new_len + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":71 * - * new_len = arr_len[0] + appendix_len # <<<<<<<<<<<<<< - * arr = realloc(arr, new_len*sizeof(int)) - * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) + * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, + * arr=None, int num_subpatterns=1): # <<<<<<<<<<<<<< + * self.sa_low = sa_low + * self.sa_high = sa_high */ - __pyx_v_new_len = ((__pyx_v_arr_len[0]) + __pyx_v_appendix_len); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":180 - * - * new_len = arr_len[0] + appendix_len - * arr = realloc(arr, new_len*sizeof(int)) # <<<<<<<<<<<<<< - * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) - * arr_len[0] = new_len - */ - __pyx_v_arr = ((int *)realloc(__pyx_v_arr, (__pyx_v_new_len * (sizeof(int))))); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":181 - * new_len = arr_len[0] + appendix_len - * arr = realloc(arr, new_len*sizeof(int)) - * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) # <<<<<<<<<<<<<< - * arr_len[0] = new_len - * return arr - */ - memcpy((__pyx_v_arr + (__pyx_v_arr_len[0])), __pyx_v_appendix, (__pyx_v_appendix_len * (sizeof(int)))); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":182 - * arr = realloc(arr, new_len*sizeof(int)) - * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) - * arr_len[0] = new_len # <<<<<<<<<<<<<< - * return arr - * - */ - (__pyx_v_arr_len[0]) = __pyx_v_new_len; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":183 - * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) - * arr_len[0] = new_len - * return arr # <<<<<<<<<<<<<< - * - * cdef int median(int low, int high, int step): - */ - __pyx_r = __pyx_v_arr; - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":185 - * return arr - * - * cdef int median(int low, int high, int step): # <<<<<<<<<<<<<< - * return low + (((high - low)/step)/2)*step - * - */ - -static int __pyx_f_3_sa_median(int __pyx_v_low, int __pyx_v_high, int __pyx_v_step) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("median", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":186 - * - * cdef int median(int low, int high, int step): - * return low + (((high - low)/step)/2)*step # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = (__pyx_v_high - __pyx_v_low); - if (unlikely(__pyx_v_step == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_step == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_1))) { - PyErr_Format(PyExc_OverflowError, "value too large to perform division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_r = (__pyx_v_low + (__Pyx_div_long(__Pyx_div_int(__pyx_t_1, __pyx_v_step), 2) * __pyx_v_step)); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_WriteUnraisable("_sa.median", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":189 - * - * - * cdef void find_comparable_matchings(int low, int high, int* arr, int step, int loc, int* loc_minus, int* loc_plus): # <<<<<<<<<<<<<< - * # Returns (minus, plus) indices for the portion of the array - * # in which all matchings have the same first index as the one - */ - -static void __pyx_f_3_sa_find_comparable_matchings(int __pyx_v_low, int __pyx_v_high, int *__pyx_v_arr, int __pyx_v_step, int __pyx_v_loc, int *__pyx_v_loc_minus, int *__pyx_v_loc_plus) { - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - __Pyx_RefNannySetupContext("find_comparable_matchings", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":193 - * # in which all matchings have the same first index as the one - * # starting at loc - * loc_plus[0] = loc + step # <<<<<<<<<<<<<< - * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: - * loc_plus[0] = loc_plus[0] + step - */ - (__pyx_v_loc_plus[0]) = (__pyx_v_loc + __pyx_v_step); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":194 - * # starting at loc - * loc_plus[0] = loc + step - * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: # <<<<<<<<<<<<<< - * loc_plus[0] = loc_plus[0] + step - * loc_minus[0] = loc - */ - while (1) { - __pyx_t_1 = ((__pyx_v_loc_plus[0]) < __pyx_v_high); - if (__pyx_t_1) { - __pyx_t_2 = ((__pyx_v_arr[(__pyx_v_loc_plus[0])]) == (__pyx_v_arr[__pyx_v_loc])); - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_1; - } - if (!__pyx_t_3) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":195 - * loc_plus[0] = loc + step - * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: - * loc_plus[0] = loc_plus[0] + step # <<<<<<<<<<<<<< - * loc_minus[0] = loc - * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: - */ - (__pyx_v_loc_plus[0]) = ((__pyx_v_loc_plus[0]) + __pyx_v_step); - } - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":196 - * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: - * loc_plus[0] = loc_plus[0] + step - * loc_minus[0] = loc # <<<<<<<<<<<<<< - * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: - * loc_minus[0] = loc_minus[0] - step - */ - (__pyx_v_loc_minus[0]) = __pyx_v_loc; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":197 - * loc_plus[0] = loc_plus[0] + step - * loc_minus[0] = loc - * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: # <<<<<<<<<<<<<< - * loc_minus[0] = loc_minus[0] - step - * - */ - while (1) { - __pyx_t_3 = (((__pyx_v_loc_minus[0]) - __pyx_v_step) >= __pyx_v_low); - if (__pyx_t_3) { - __pyx_t_1 = ((__pyx_v_arr[((__pyx_v_loc_minus[0]) - __pyx_v_step)]) == (__pyx_v_arr[__pyx_v_loc])); - __pyx_t_2 = __pyx_t_1; - } else { - __pyx_t_2 = __pyx_t_3; - } - if (!__pyx_t_2) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":198 - * loc_minus[0] = loc - * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: - * loc_minus[0] = loc_minus[0] - step # <<<<<<<<<<<<<< - * - * - */ - (__pyx_v_loc_minus[0]) = ((__pyx_v_loc_minus[0]) - __pyx_v_step); - } - - __Pyx_RefNannyFinishContext(); -} - -/* Python wrapper */ -static int __pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_3_sa_Alignment *__pyx_v_alignment = 0; - float __pyx_v_by_slack_factor; - char *__pyx_v_category; - PyObject *__pyx_v_max_chunks = 0; - unsigned int __pyx_v_max_initial_size; - unsigned int __pyx_v_max_length; - unsigned int __pyx_v_max_nonterminals; - PyObject *__pyx_v_max_target_chunks = 0; - PyObject *__pyx_v_max_target_length = 0; - unsigned int __pyx_v_min_gap_size; - PyObject *__pyx_v_precompute_file = 0; - unsigned int __pyx_v_precompute_secondary_rank; - unsigned int __pyx_v_precompute_rank; - int __pyx_v_require_aligned_terminal; - int __pyx_v_require_aligned_chunks; - unsigned int __pyx_v_train_max_initial_size; - unsigned int __pyx_v_train_min_gap_size; - int __pyx_v_tight_phrases; - int __pyx_v_use_baeza_yates; - int __pyx_v_use_collocations; - int __pyx_v_use_index; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alignment,&__pyx_n_s__by_slack_factor,&__pyx_n_s__category,&__pyx_n_s__max_chunks,&__pyx_n_s__max_initial_size,&__pyx_n_s__max_length,&__pyx_n_s__max_nonterminals,&__pyx_n_s__max_target_chunks,&__pyx_n_s__max_target_length,&__pyx_n_s__min_gap_size,&__pyx_n_s__precompute_file,&__pyx_n_s_70,&__pyx_n_s__precompute_rank,&__pyx_n_s_103,&__pyx_n_s_104,&__pyx_n_s_71,&__pyx_n_s__train_min_gap_size,&__pyx_n_s__tight_phrases,&__pyx_n_s__use_baeza_yates,&__pyx_n_s__use_collocations,&__pyx_n_s__use_index,0}; - PyObject* values[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":257 - * char* category="[X]", - * # maximum number of contiguous chunks of terminal symbols in RHS of a rule. If None, defaults to max_nonterminals+1 - * max_chunks=None, # <<<<<<<<<<<<<< - * # maximum span of a grammar rule in TEST DATA - * unsigned max_initial_size=10, - */ - values[3] = ((PyObject *)Py_None); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":265 - * unsigned max_nonterminals=2, - * # maximum number of contiguous chunks of terminal symbols in target-side RHS of a rule. If None, defaults to max_nonterminals+1 - * max_target_chunks=None, # <<<<<<<<<<<<<< - * # maximum number of target side symbols (both T and NT) allowed in a rule. If None, defaults to max_initial_size - * max_target_length=None, - */ - values[7] = ((PyObject *)Py_None); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":267 - * max_target_chunks=None, - * # maximum number of target side symbols (both T and NT) allowed in a rule. If None, defaults to max_initial_size - * max_target_length=None, # <<<<<<<<<<<<<< - * # minimum span of a nonterminal in the RHS of a rule in TEST DATA - * unsigned min_gap_size=2, - */ - values[8] = ((PyObject *)Py_None); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":271 - * unsigned min_gap_size=2, - * # filename of file containing precomputed collocations - * precompute_file=None, # <<<<<<<<<<<<<< - * # maximum frequency rank of patterns used to compute triples (don't set higher than 20). - * unsigned precompute_secondary_rank=20, - */ - values[10] = ((PyObject *)Py_None); + values[4] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { - case 21: values[20] = PyTuple_GET_ITEM(__pyx_args, 20); - case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19); - case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18); - case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); - case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); - case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); - case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); - case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); - case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); - case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); - case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); - case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); - case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); - case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); - case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); @@ -36545,7382 +37231,6667 @@ static int __pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(PyObject *__pyx_v_ kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alignment)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sa_low); + if (value) { values[0] = value; kw_args--; } + } case 1: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__by_slack_factor); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sa_high); if (value) { values[1] = value; kw_args--; } } case 2: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__category); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arr_low); if (value) { values[2] = value; kw_args--; } } case 3: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_chunks); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arr_high); if (value) { values[3] = value; kw_args--; } } case 4: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_initial_size); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__arr); if (value) { values[4] = value; kw_args--; } } case 5: if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_length); + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__num_subpatterns); if (value) { values[5] = value; kw_args--; } } - case 6: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_nonterminals); - if (value) { values[6] = value; kw_args--; } - } - case 7: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_target_chunks); - if (value) { values[7] = value; kw_args--; } - } - case 8: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_target_length); - if (value) { values[8] = value; kw_args--; } - } - case 9: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_gap_size); - if (value) { values[9] = value; kw_args--; } - } - case 10: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__precompute_file); - if (value) { values[10] = value; kw_args--; } - } - case 11: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_70); - if (value) { values[11] = value; kw_args--; } - } - case 12: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__precompute_rank); - if (value) { values[12] = value; kw_args--; } - } - case 13: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_103); - if (value) { values[13] = value; kw_args--; } - } - case 14: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_104); - if (value) { values[14] = value; kw_args--; } - } - case 15: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_71); - if (value) { values[15] = value; kw_args--; } - } - case 16: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__train_min_gap_size); - if (value) { values[16] = value; kw_args--; } - } - case 17: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tight_phrases); - if (value) { values[17] = value; kw_args--; } - } - case 18: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_baeza_yates); - if (value) { values[18] = value; kw_args--; } - } - case 19: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_collocations); - if (value) { values[19] = value; kw_args--; } - } - case 20: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_index); - if (value) { values[20] = value; kw_args--; } - } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 249; __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[8]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { - case 21: values[20] = PyTuple_GET_ITEM(__pyx_args, 20); - case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19); - case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18); - case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); - case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); - case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); - case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); - case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); - case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); - case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); - case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); - case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); - case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); - case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); - case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; + case 0: break; default: goto __pyx_L5_argtuple_error; } } - __pyx_v_alignment = ((struct __pyx_obj_3_sa_Alignment *)values[0]); + if (values[0]) { + __pyx_v_sa_low = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_sa_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_sa_low = ((int)-1); + } if (values[1]) { - __pyx_v_by_slack_factor = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_by_slack_factor == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_sa_high = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_sa_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":253 - * Alignment alignment, - * # parameter for double-binary search; doesn't seem to matter much - * float by_slack_factor=1.0, # <<<<<<<<<<<<<< - * # name of generic nonterminal used by Hiero - * char* category="[X]", - */ - __pyx_v_by_slack_factor = ((float)1.0); + __pyx_v_sa_high = ((int)-1); } if (values[2]) { - __pyx_v_category = PyBytes_AsString(values[2]); if (unlikely((!__pyx_v_category) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_arr_low = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_arr_low == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { - __pyx_v_category = ((char *)__pyx_k_105); + __pyx_v_arr_low = ((int)-1); } - __pyx_v_max_chunks = values[3]; - if (values[4]) { - __pyx_v_max_initial_size = __Pyx_PyInt_AsUnsignedInt(values[4]); if (unlikely((__pyx_v_max_initial_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 259; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (values[3]) { + __pyx_v_arr_high = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_arr_high == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { - __pyx_v_max_initial_size = ((unsigned int)10); + __pyx_v_arr_high = ((int)-1); } + __pyx_v_arr = values[4]; if (values[5]) { - __pyx_v_max_length = __Pyx_PyInt_AsUnsignedInt(values[5]); if (unlikely((__pyx_v_max_length == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_max_length = ((unsigned int)5); - } - if (values[6]) { - __pyx_v_max_nonterminals = __Pyx_PyInt_AsUnsignedInt(values[6]); if (unlikely((__pyx_v_max_nonterminals == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_max_nonterminals = ((unsigned int)2); - } - __pyx_v_max_target_chunks = values[7]; - __pyx_v_max_target_length = values[8]; - if (values[9]) { - __pyx_v_min_gap_size = __Pyx_PyInt_AsUnsignedInt(values[9]); if (unlikely((__pyx_v_min_gap_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_min_gap_size = ((unsigned int)2); - } - __pyx_v_precompute_file = values[10]; - if (values[11]) { - __pyx_v_precompute_secondary_rank = __Pyx_PyInt_AsUnsignedInt(values[11]); if (unlikely((__pyx_v_precompute_secondary_rank == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 273; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_precompute_secondary_rank = ((unsigned int)20); - } - if (values[12]) { - __pyx_v_precompute_rank = __Pyx_PyInt_AsUnsignedInt(values[12]); if (unlikely((__pyx_v_precompute_rank == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_precompute_rank = ((unsigned int)100); - } - if (values[13]) { - __pyx_v_require_aligned_terminal = __Pyx_PyObject_IsTrue(values[13]); if (unlikely((__pyx_v_require_aligned_terminal == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":277 - * unsigned precompute_rank=100, - * # require extracted rules to have at least one aligned word - * bint require_aligned_terminal=True, # <<<<<<<<<<<<<< - * # require each contiguous chunk of extracted rules to have at least one aligned word - * bint require_aligned_chunks=False, - */ - __pyx_v_require_aligned_terminal = ((int)1); - } - if (values[14]) { - __pyx_v_require_aligned_chunks = __Pyx_PyObject_IsTrue(values[14]); if (unlikely((__pyx_v_require_aligned_chunks == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":279 - * bint require_aligned_terminal=True, - * # require each contiguous chunk of extracted rules to have at least one aligned word - * bint require_aligned_chunks=False, # <<<<<<<<<<<<<< - * # maximum span of a grammar rule extracted from TRAINING DATA - * unsigned train_max_initial_size=10, - */ - __pyx_v_require_aligned_chunks = ((int)0); - } - if (values[15]) { - __pyx_v_train_max_initial_size = __Pyx_PyInt_AsUnsignedInt(values[15]); if (unlikely((__pyx_v_train_max_initial_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_train_max_initial_size = ((unsigned int)10); - } - if (values[16]) { - __pyx_v_train_min_gap_size = __Pyx_PyInt_AsUnsignedInt(values[16]); if (unlikely((__pyx_v_train_min_gap_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - __pyx_v_train_min_gap_size = ((unsigned int)2); - } - if (values[17]) { - __pyx_v_tight_phrases = __Pyx_PyObject_IsTrue(values[17]); if (unlikely((__pyx_v_tight_phrases == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":285 - * unsigned train_min_gap_size=2, - * # True if phrases should be tight, False otherwise (False == slower but better results) - * bint tight_phrases=False, # <<<<<<<<<<<<<< - * # True to require use of double-binary alg, false otherwise - * bint use_baeza_yates=True, - */ - __pyx_v_tight_phrases = ((int)0); - } - if (values[18]) { - __pyx_v_use_baeza_yates = __Pyx_PyObject_IsTrue(values[18]); if (unlikely((__pyx_v_use_baeza_yates == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":287 - * bint tight_phrases=False, - * # True to require use of double-binary alg, false otherwise - * bint use_baeza_yates=True, # <<<<<<<<<<<<<< - * # True to enable used of precomputed collocations - * bint use_collocations=True, - */ - __pyx_v_use_baeza_yates = ((int)1); - } - if (values[19]) { - __pyx_v_use_collocations = __Pyx_PyObject_IsTrue(values[19]); if (unlikely((__pyx_v_use_collocations == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":289 - * bint use_baeza_yates=True, - * # True to enable used of precomputed collocations - * bint use_collocations=True, # <<<<<<<<<<<<<< - * # True to enable use of precomputed inverted indices - * bint use_index=True): - */ - __pyx_v_use_collocations = ((int)1); - } - if (values[20]) { - __pyx_v_use_index = __Pyx_PyObject_IsTrue(values[20]); if (unlikely((__pyx_v_use_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_num_subpatterns = __Pyx_PyInt_AsInt(values[5]); if (unlikely((__pyx_v_num_subpatterns == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } else { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":291 - * bint use_collocations=True, - * # True to enable use of precomputed inverted indices - * bint use_index=True): # <<<<<<<<<<<<<< - * '''Note: we make a distinction between the min_gap_size - * and max_initial_size used in test and train. The latter - */ - __pyx_v_use_index = ((int)1); + __pyx_v_num_subpatterns = ((int)1); } } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 21, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 249; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.PhraseLocation.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alignment), __pyx_ptype_3_sa_Alignment, 1, "alignment", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory___cinit__(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_alignment, __pyx_v_by_slack_factor, __pyx_v_category, __pyx_v_max_chunks, __pyx_v_max_initial_size, __pyx_v_max_length, __pyx_v_max_nonterminals, __pyx_v_max_target_chunks, __pyx_v_max_target_length, __pyx_v_min_gap_size, __pyx_v_precompute_file, __pyx_v_precompute_secondary_rank, __pyx_v_precompute_rank, __pyx_v_require_aligned_terminal, __pyx_v_require_aligned_chunks, __pyx_v_train_max_initial_size, __pyx_v_train_min_gap_size, __pyx_v_tight_phrases, __pyx_v_use_baeza_yates, __pyx_v_use_collocations, __pyx_v_use_index); - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; + __pyx_r = __pyx_pf_3_sa_14PhraseLocation___cinit__(((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_v_self), __pyx_v_sa_low, __pyx_v_sa_high, __pyx_v_arr_low, __pyx_v_arr_high, __pyx_v_arr, __pyx_v_num_subpatterns); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":249 - * cdef IntList findexes1 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":70 + * return 1 * - * def __cinit__(self, # <<<<<<<<<<<<<< - * # compiled alignment object (REQUIRED) - * Alignment alignment, + * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, # <<<<<<<<<<<<<< + * arr=None, int num_subpatterns=1): + * self.sa_low = sa_low */ -static int __pyx_pf_3_sa_23HieroCachingRuleFactory___cinit__(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Alignment *__pyx_v_alignment, float __pyx_v_by_slack_factor, char *__pyx_v_category, PyObject *__pyx_v_max_chunks, unsigned int __pyx_v_max_initial_size, unsigned int __pyx_v_max_length, unsigned int __pyx_v_max_nonterminals, PyObject *__pyx_v_max_target_chunks, PyObject *__pyx_v_max_target_length, unsigned int __pyx_v_min_gap_size, PyObject *__pyx_v_precompute_file, unsigned int __pyx_v_precompute_secondary_rank, unsigned int __pyx_v_precompute_rank, int __pyx_v_require_aligned_terminal, int __pyx_v_require_aligned_chunks, unsigned int __pyx_v_train_max_initial_size, unsigned int __pyx_v_train_min_gap_size, int __pyx_v_tight_phrases, int __pyx_v_use_baeza_yates, int __pyx_v_use_collocations, int __pyx_v_use_index) { +static int __pyx_pf_3_sa_14PhraseLocation___cinit__(struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_self, int __pyx_v_sa_low, int __pyx_v_sa_high, int __pyx_v_arr_low, int __pyx_v_arr_high, PyObject *__pyx_v_arr, int __pyx_v_num_subpatterns) { int __pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":297 - * respectively. This is because Chiang's model does not require - * them to be the same, therefore we don't either.''' - * self.rules = TrieTable(True) # cache # <<<<<<<<<<<<<< - * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) - * if alignment is None: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":72 + * def __cinit__(self, int sa_low=-1, int sa_high=-1, int arr_low=-1, int arr_high=-1, + * arr=None, int num_subpatterns=1): + * self.sa_low = sa_low # <<<<<<<<<<<<<< + * self.sa_high = sa_high + * self.arr_low = arr_low */ - __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieTable)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->rules); - __Pyx_DECREF(((PyObject *)__pyx_v_self->rules)); - __pyx_v_self->rules = ((struct __pyx_obj_3_sa_TrieTable *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_v_self->sa_low = __pyx_v_sa_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":298 - * them to be the same, therefore we don't either.''' - * self.rules = TrieTable(True) # cache - * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) # <<<<<<<<<<<<<< - * if alignment is None: - * raise Exception("Must specify an alignment object") + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":73 + * arr=None, int num_subpatterns=1): + * self.sa_low = sa_low + * self.sa_high = sa_high # <<<<<<<<<<<<<< + * self.arr_low = arr_low + * self.arr_high = arr_high */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_self->rules->root); - __Pyx_DECREF(__pyx_v_self->rules->root); - __pyx_v_self->rules->root = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_self->sa_high = __pyx_v_sa_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":299 - * self.rules = TrieTable(True) # cache - * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) - * if alignment is None: # <<<<<<<<<<<<<< - * raise Exception("Must specify an alignment object") - * self.alignment = alignment + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":74 + * self.sa_low = sa_low + * self.sa_high = sa_high + * self.arr_low = arr_low # <<<<<<<<<<<<<< + * self.arr_high = arr_high + * self.arr = arr */ - __pyx_t_3 = (((PyObject *)__pyx_v_alignment) == Py_None); - if (__pyx_t_3) { + __pyx_v_self->arr_low = __pyx_v_arr_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":300 - * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) - * if alignment is None: - * raise Exception("Must specify an alignment object") # <<<<<<<<<<<<<< - * self.alignment = alignment - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":75 + * self.sa_high = sa_high + * self.arr_low = arr_low + * self.arr_high = arr_high # <<<<<<<<<<<<<< + * self.arr = arr + * self.num_subpatterns = num_subpatterns */ - __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_k_tuple_107), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L3; - } - __pyx_L3:; + __pyx_v_self->arr_high = __pyx_v_arr_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":301 - * if alignment is None: - * raise Exception("Must specify an alignment object") - * self.alignment = alignment # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":76 + * self.arr_low = arr_low + * self.arr_high = arr_high + * self.arr = arr # <<<<<<<<<<<<<< + * self.num_subpatterns = num_subpatterns * - * # grammar parameters and settings */ - __Pyx_INCREF(((PyObject *)__pyx_v_alignment)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_alignment)); - __Pyx_GOTREF(__pyx_v_self->alignment); - __Pyx_DECREF(((PyObject *)__pyx_v_self->alignment)); - __pyx_v_self->alignment = __pyx_v_alignment; + if (!(likely(((__pyx_v_arr) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_arr, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_arr); + __Pyx_GIVEREF(__pyx_v_arr); + __Pyx_GOTREF(__pyx_v_self->arr); + __Pyx_DECREF(((PyObject *)__pyx_v_self->arr)); + __pyx_v_self->arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_v_arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":305 - * # grammar parameters and settings - * # NOTE: setting max_nonterminals > 2 is not currently supported in Hiero - * self.max_length = max_length # <<<<<<<<<<<<<< - * self.max_nonterminals = max_nonterminals - * self.max_initial_size = max_initial_size + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":77 + * self.arr_high = arr_high + * self.arr = arr + * self.num_subpatterns = num_subpatterns # <<<<<<<<<<<<<< + * + * */ - __pyx_v_self->max_length = __pyx_v_max_length; + __pyx_v_self->num_subpatterns = __pyx_v_num_subpatterns; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":306 - * # NOTE: setting max_nonterminals > 2 is not currently supported in Hiero - * self.max_length = max_length - * self.max_nonterminals = max_nonterminals # <<<<<<<<<<<<<< - * self.max_initial_size = max_initial_size - * self.train_max_initial_size = train_max_initial_size - */ - __pyx_v_self->max_nonterminals = __pyx_v_max_nonterminals; + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_sa.PhraseLocation.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":307 - * self.max_length = max_length - * self.max_nonterminals = max_nonterminals - * self.max_initial_size = max_initial_size # <<<<<<<<<<<<<< - * self.train_max_initial_size = train_max_initial_size - * self.min_gap_size = min_gap_size - */ - __pyx_v_self->max_initial_size = __pyx_v_max_initial_size; +/* Python wrapper */ +static int __pyx_pw_3_sa_7Sampler_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_7Sampler_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + int __pyx_v_sample_size; + struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray = 0; + int __pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__sample_size,&__pyx_n_s__fsarray,0}; + PyObject* values[2] = {0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sample_size)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fsarray)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + } + __pyx_v_sample_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_sample_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_fsarray = ((struct __pyx_obj_3_sa_SuffixArray *)values[1]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("_sa.Sampler.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fsarray), __pyx_ptype_3_sa_SuffixArray, 1, "fsarray", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_7Sampler___cinit__(((struct __pyx_obj_3_sa_Sampler *)__pyx_v_self), __pyx_v_sample_size, __pyx_v_fsarray); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":308 - * self.max_nonterminals = max_nonterminals - * self.max_initial_size = max_initial_size - * self.train_max_initial_size = train_max_initial_size # <<<<<<<<<<<<<< - * self.min_gap_size = min_gap_size - * self.train_min_gap_size = train_min_gap_size +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":87 + * cdef IntList sa + * + * def __cinit__(self, int sample_size, SuffixArray fsarray): # <<<<<<<<<<<<<< + * self.sample_size = sample_size + * self.sa = fsarray.sa */ - __pyx_v_self->train_max_initial_size = __pyx_v_train_max_initial_size; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":309 - * self.max_initial_size = max_initial_size - * self.train_max_initial_size = train_max_initial_size - * self.min_gap_size = min_gap_size # <<<<<<<<<<<<<< - * self.train_min_gap_size = train_min_gap_size - * self.category = sym_fromstring(category, False) - */ - __pyx_v_self->min_gap_size = __pyx_v_min_gap_size; +static int __pyx_pf_3_sa_7Sampler___cinit__(struct __pyx_obj_3_sa_Sampler *__pyx_v_self, int __pyx_v_sample_size, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":310 - * self.train_max_initial_size = train_max_initial_size - * self.min_gap_size = min_gap_size - * self.train_min_gap_size = train_min_gap_size # <<<<<<<<<<<<<< - * self.category = sym_fromstring(category, False) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":88 * + * def __cinit__(self, int sample_size, SuffixArray fsarray): + * self.sample_size = sample_size # <<<<<<<<<<<<<< + * self.sa = fsarray.sa + * if sample_size > 0: */ - __pyx_v_self->train_min_gap_size = __pyx_v_train_min_gap_size; + __pyx_v_self->sample_size = __pyx_v_sample_size; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":311 - * self.min_gap_size = min_gap_size - * self.train_min_gap_size = train_min_gap_size - * self.category = sym_fromstring(category, False) # <<<<<<<<<<<<<< - * - * if max_chunks is None: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":89 + * def __cinit__(self, int sample_size, SuffixArray fsarray): + * self.sample_size = sample_size + * self.sa = fsarray.sa # <<<<<<<<<<<<<< + * if sample_size > 0: + * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyBytes_FromString(__pyx_v_category); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_1 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_self->category = __pyx_t_6; + __Pyx_INCREF(((PyObject *)__pyx_v_fsarray->sa)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fsarray->sa)); + __Pyx_GOTREF(__pyx_v_self->sa); + __Pyx_DECREF(((PyObject *)__pyx_v_self->sa)); + __pyx_v_self->sa = __pyx_v_fsarray->sa; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":313 - * self.category = sym_fromstring(category, False) - * - * if max_chunks is None: # <<<<<<<<<<<<<< - * self.max_chunks = self.max_nonterminals + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":90 + * self.sample_size = sample_size + * self.sa = fsarray.sa + * if sample_size > 0: # <<<<<<<<<<<<<< + * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) * else: */ - __pyx_t_3 = (__pyx_v_max_chunks == Py_None); - if (__pyx_t_3) { + __pyx_t_1 = (__pyx_v_sample_size > 0); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":314 - * - * if max_chunks is None: - * self.max_chunks = self.max_nonterminals + 1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":91 + * self.sa = fsarray.sa + * if sample_size > 0: + * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) # <<<<<<<<<<<<<< * else: - * self.max_chunks = max_chunks + * logger.info("Sampling strategy: no sampling") */ - __pyx_v_self->max_chunks = (__pyx_v_self->max_nonterminals + 1); - goto __pyx_L4; + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong(__pyx_v_sample_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_102)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_102)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_102)); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L3; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":316 - * self.max_chunks = self.max_nonterminals + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":93 + * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) * else: - * self.max_chunks = max_chunks # <<<<<<<<<<<<<< + * logger.info("Sampling strategy: no sampling") # <<<<<<<<<<<<<< * - * if max_target_chunks is None: + * def sample(self, PhraseLocation phrase_location): */ - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_max_chunks); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->max_chunks = __pyx_t_6; + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_104), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } - __pyx_L4:; + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":318 - * self.max_chunks = max_chunks - * - * if max_target_chunks is None: # <<<<<<<<<<<<<< - * self.max_target_chunks = self.max_nonterminals + 1 - * else: - */ - __pyx_t_3 = (__pyx_v_max_target_chunks == Py_None); - if (__pyx_t_3) { + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("_sa.Sampler.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":319 - * - * if max_target_chunks is None: - * self.max_target_chunks = self.max_nonterminals + 1 # <<<<<<<<<<<<<< - * else: - * self.max_target_chunks = max_target_chunks - */ - __pyx_v_self->max_target_chunks = (__pyx_v_self->max_nonterminals + 1); - goto __pyx_L5; - } - /*else*/ { +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_7Sampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase_location); /*proto*/ +static char __pyx_doc_3_sa_7Sampler_2sample[] = "Returns a sample of the locations for\n the phrase. If there are less than self.sample_size\n locations, return all of them; otherwise, return\n up to self.sample_size locations. In the latter case,\n we choose to sample UNIFORMLY -- that is, the locations\n are chosen at uniform intervals over the entire set, rather\n than randomly. This makes the algorithm deterministic, which\n is good for things like MERT"; +static PyObject *__pyx_pw_3_sa_7Sampler_3sample(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase_location) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("sample (wrapper)", 0); + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_phrase_location), __pyx_ptype_3_sa_PhraseLocation, 1, "phrase_location", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_7Sampler_2sample(((struct __pyx_obj_3_sa_Sampler *)__pyx_v_self), ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_v_phrase_location)); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":321 - * self.max_target_chunks = self.max_nonterminals + 1 - * else: - * self.max_target_chunks = max_target_chunks # <<<<<<<<<<<<<< +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":95 + * logger.info("Sampling strategy: no sampling") * - * if max_target_length is None: + * def sample(self, PhraseLocation phrase_location): # <<<<<<<<<<<<<< + * '''Returns a sample of the locations for + * the phrase. If there are less than self.sample_size */ - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_max_target_chunks); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->max_target_chunks = __pyx_t_6; - } - __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":323 - * self.max_target_chunks = max_target_chunks - * - * if max_target_length is None: # <<<<<<<<<<<<<< - * self.max_target_length = max_initial_size - * else: - */ - __pyx_t_3 = (__pyx_v_max_target_length == Py_None); - if (__pyx_t_3) { +static PyObject *__pyx_pf_3_sa_7Sampler_2sample(struct __pyx_obj_3_sa_Sampler *__pyx_v_self, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_phrase_location) { + struct __pyx_obj_3_sa_IntList *__pyx_v_sample = 0; + double __pyx_v_i; + double __pyx_v_stepsize; + int __pyx_v_num_locations; + int __pyx_v_val; + int __pyx_v_j; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("sample", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":324 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":108 + * cdef int num_locations, val, j * - * if max_target_length is None: - * self.max_target_length = max_initial_size # <<<<<<<<<<<<<< - * else: - * self.max_target_length = max_target_length + * sample = IntList() # <<<<<<<<<<<<<< + * if phrase_location.arr is None: + * num_locations = phrase_location.sa_high - phrase_location.sa_low */ - __pyx_v_self->max_target_length = __pyx_v_max_initial_size; - goto __pyx_L6; - } - /*else*/ { + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_sample = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":326 - * self.max_target_length = max_initial_size - * else: - * self.max_target_length = max_target_length # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":109 * - * # algorithmic parameters and settings + * sample = IntList() + * if phrase_location.arr is None: # <<<<<<<<<<<<<< + * num_locations = phrase_location.sa_high - phrase_location.sa_low + * if self.sample_size == -1 or num_locations <= self.sample_size: */ - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_max_target_length); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->max_target_length = __pyx_t_6; - } - __pyx_L6:; + __pyx_t_2 = (((PyObject *)__pyx_v_phrase_location->arr) == Py_None); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":329 - * - * # algorithmic parameters and settings - * self.precomputed_collocations = {} # <<<<<<<<<<<<<< - * self.precomputed_index = {} - * self.use_index = use_index + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":110 + * sample = IntList() + * if phrase_location.arr is None: + * num_locations = phrase_location.sa_high - phrase_location.sa_low # <<<<<<<<<<<<<< + * if self.sample_size == -1 or num_locations <= self.sample_size: + * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) */ - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __Pyx_GOTREF(__pyx_v_self->precomputed_collocations); - __Pyx_DECREF(__pyx_v_self->precomputed_collocations); - __pyx_v_self->precomputed_collocations = ((PyObject *)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_v_num_locations = (__pyx_v_phrase_location->sa_high - __pyx_v_phrase_location->sa_low); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":330 - * # algorithmic parameters and settings - * self.precomputed_collocations = {} - * self.precomputed_index = {} # <<<<<<<<<<<<<< - * self.use_index = use_index - * self.use_collocations = use_collocations + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":111 + * if phrase_location.arr is None: + * num_locations = phrase_location.sa_high - phrase_location.sa_low + * if self.sample_size == -1 or num_locations <= self.sample_size: # <<<<<<<<<<<<<< + * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) + * else: */ - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __Pyx_GOTREF(__pyx_v_self->precomputed_index); - __Pyx_DECREF(__pyx_v_self->precomputed_index); - __pyx_v_self->precomputed_index = ((PyObject *)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_t_2 = (__pyx_v_self->sample_size == -1); + if (!__pyx_t_2) { + __pyx_t_3 = (__pyx_v_num_locations <= __pyx_v_self->sample_size); + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_2; + } + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":331 - * self.precomputed_collocations = {} - * self.precomputed_index = {} - * self.use_index = use_index # <<<<<<<<<<<<<< - * self.use_collocations = use_collocations - * self.max_rank = {} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":112 + * num_locations = phrase_location.sa_high - phrase_location.sa_low + * if self.sample_size == -1 or num_locations <= self.sample_size: + * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) # <<<<<<<<<<<<<< + * else: + * stepsize = float(num_locations)/float(self.sample_size) */ - __pyx_v_self->use_index = __pyx_v_use_index; + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_sample->__pyx_vtab)->_extend_arr(__pyx_v_sample, (__pyx_v_self->sa->arr + __pyx_v_phrase_location->sa_low), __pyx_v_num_locations); + goto __pyx_L4; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":332 - * self.precomputed_index = {} - * self.use_index = use_index - * self.use_collocations = use_collocations # <<<<<<<<<<<<<< - * self.max_rank = {} - * self.precompute_file = precompute_file + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":114 + * sample._extend_arr(self.sa.arr + phrase_location.sa_low, num_locations) + * else: + * stepsize = float(num_locations)/float(self.sample_size) # <<<<<<<<<<<<<< + * i = phrase_location.sa_low + * while i < phrase_location.sa_high and sample.len < self.sample_size: */ - __pyx_v_self->use_collocations = __pyx_v_use_collocations; + if (unlikely(((double)__pyx_v_self->sample_size) == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_stepsize = (((double)__pyx_v_num_locations) / ((double)__pyx_v_self->sample_size)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":333 - * self.use_index = use_index - * self.use_collocations = use_collocations - * self.max_rank = {} # <<<<<<<<<<<<<< - * self.precompute_file = precompute_file - * self.precompute_rank = precompute_rank + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":115 + * else: + * stepsize = float(num_locations)/float(self.sample_size) + * i = phrase_location.sa_low # <<<<<<<<<<<<<< + * while i < phrase_location.sa_high and sample.len < self.sample_size: + * '''Note: int(i) not guaranteed to have the desired */ - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __Pyx_GOTREF(__pyx_v_self->max_rank); - __Pyx_DECREF(__pyx_v_self->max_rank); - __pyx_v_self->max_rank = ((PyObject *)__pyx_t_4); - __pyx_t_4 = 0; + __pyx_v_i = __pyx_v_phrase_location->sa_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":334 - * self.use_collocations = use_collocations - * self.max_rank = {} - * self.precompute_file = precompute_file # <<<<<<<<<<<<<< - * self.precompute_rank = precompute_rank - * self.precompute_secondary_rank = precompute_secondary_rank - */ - __Pyx_INCREF(__pyx_v_precompute_file); - __Pyx_GIVEREF(__pyx_v_precompute_file); - __Pyx_GOTREF(__pyx_v_self->precompute_file); - __Pyx_DECREF(__pyx_v_self->precompute_file); - __pyx_v_self->precompute_file = __pyx_v_precompute_file; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":335 - * self.max_rank = {} - * self.precompute_file = precompute_file - * self.precompute_rank = precompute_rank # <<<<<<<<<<<<<< - * self.precompute_secondary_rank = precompute_secondary_rank - * self.use_baeza_yates = use_baeza_yates + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":116 + * stepsize = float(num_locations)/float(self.sample_size) + * i = phrase_location.sa_low + * while i < phrase_location.sa_high and sample.len < self.sample_size: # <<<<<<<<<<<<<< + * '''Note: int(i) not guaranteed to have the desired + * effect, according to the python documentation''' */ - __pyx_v_self->precompute_rank = __pyx_v_precompute_rank; + while (1) { + __pyx_t_4 = (__pyx_v_i < __pyx_v_phrase_location->sa_high); + if (__pyx_t_4) { + __pyx_t_2 = (__pyx_v_sample->len < __pyx_v_self->sample_size); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_4; + } + if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":336 - * self.precompute_file = precompute_file - * self.precompute_rank = precompute_rank - * self.precompute_secondary_rank = precompute_secondary_rank # <<<<<<<<<<<<<< - * self.use_baeza_yates = use_baeza_yates - * self.by_slack_factor = by_slack_factor + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":119 + * '''Note: int(i) not guaranteed to have the desired + * effect, according to the python documentation''' + * if fmod(i,1.0) > 0.5: # <<<<<<<<<<<<<< + * val = int(ceil(i)) + * else: */ - __pyx_v_self->precompute_secondary_rank = __pyx_v_precompute_secondary_rank; + __pyx_t_3 = (fmod(__pyx_v_i, 1.0) > 0.5); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":337 - * self.precompute_rank = precompute_rank - * self.precompute_secondary_rank = precompute_secondary_rank - * self.use_baeza_yates = use_baeza_yates # <<<<<<<<<<<<<< - * self.by_slack_factor = by_slack_factor - * if tight_phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":120 + * effect, according to the python documentation''' + * if fmod(i,1.0) > 0.5: + * val = int(ceil(i)) # <<<<<<<<<<<<<< + * else: + * val = int(floor(i)) */ - __pyx_v_self->use_baeza_yates = __pyx_v_use_baeza_yates; + __pyx_v_val = ((int)ceil(__pyx_v_i)); + goto __pyx_L7; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":338 - * self.precompute_secondary_rank = precompute_secondary_rank - * self.use_baeza_yates = use_baeza_yates - * self.by_slack_factor = by_slack_factor # <<<<<<<<<<<<<< - * if tight_phrases: - * self.tight_phrases = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":122 + * val = int(ceil(i)) + * else: + * val = int(floor(i)) # <<<<<<<<<<<<<< + * sample._append(self.sa.arr[val]) + * i = i + stepsize */ - __pyx_v_self->by_slack_factor = __pyx_v_by_slack_factor; + __pyx_v_val = ((int)floor(__pyx_v_i)); + } + __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":339 - * self.use_baeza_yates = use_baeza_yates - * self.by_slack_factor = by_slack_factor - * if tight_phrases: # <<<<<<<<<<<<<< - * self.tight_phrases = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":123 + * else: + * val = int(floor(i)) + * sample._append(self.sa.arr[val]) # <<<<<<<<<<<<<< + * i = i + stepsize * else: */ - if (__pyx_v_tight_phrases) { + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_sample->__pyx_vtab)->_append(__pyx_v_sample, (__pyx_v_self->sa->arr[__pyx_v_val])); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":340 - * self.by_slack_factor = by_slack_factor - * if tight_phrases: - * self.tight_phrases = 1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":124 + * val = int(floor(i)) + * sample._append(self.sa.arr[val]) + * i = i + stepsize # <<<<<<<<<<<<<< * else: - * self.tight_phrases = 0 + * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns */ - __pyx_v_self->tight_phrases = 1; - goto __pyx_L7; + __pyx_v_i = (__pyx_v_i + __pyx_v_stepsize); + } + } + __pyx_L4:; + goto __pyx_L3; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":342 - * self.tight_phrases = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":126 + * i = i + stepsize * else: - * self.tight_phrases = 0 # <<<<<<<<<<<<<< - * - * if require_aligned_chunks: + * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns # <<<<<<<<<<<<<< + * if self.sample_size == -1 or num_locations <= self.sample_size: + * sample = phrase_location.arr */ - __pyx_v_self->tight_phrases = 0; - } - __pyx_L7:; + __pyx_t_5 = (__pyx_v_phrase_location->arr_high - __pyx_v_phrase_location->arr_low); + if (unlikely(__pyx_v_phrase_location->num_subpatterns == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_phrase_location->num_subpatterns == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_5))) { + PyErr_Format(PyExc_OverflowError, "value too large to perform division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_num_locations = __Pyx_div_int(__pyx_t_5, __pyx_v_phrase_location->num_subpatterns); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":344 - * self.tight_phrases = 0 - * - * if require_aligned_chunks: # <<<<<<<<<<<<<< - * # one condition is a stronger version of the other. - * self.require_aligned_chunks = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":127 + * else: + * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns + * if self.sample_size == -1 or num_locations <= self.sample_size: # <<<<<<<<<<<<<< + * sample = phrase_location.arr + * else: */ - if (__pyx_v_require_aligned_chunks) { + __pyx_t_3 = (__pyx_v_self->sample_size == -1); + if (!__pyx_t_3) { + __pyx_t_4 = (__pyx_v_num_locations <= __pyx_v_self->sample_size); + __pyx_t_2 = __pyx_t_4; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":346 - * if require_aligned_chunks: - * # one condition is a stronger version of the other. - * self.require_aligned_chunks = 1 # <<<<<<<<<<<<<< - * self.require_aligned_terminal = 1 - * elif require_aligned_terminal: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":128 + * num_locations = (phrase_location.arr_high - phrase_location.arr_low) / phrase_location.num_subpatterns + * if self.sample_size == -1 or num_locations <= self.sample_size: + * sample = phrase_location.arr # <<<<<<<<<<<<<< + * else: + * stepsize = float(num_locations)/float(self.sample_size) */ - __pyx_v_self->require_aligned_chunks = 1; + __Pyx_INCREF(((PyObject *)__pyx_v_phrase_location->arr)); + __Pyx_DECREF(((PyObject *)__pyx_v_sample)); + __pyx_v_sample = __pyx_v_phrase_location->arr; + goto __pyx_L8; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":347 - * # one condition is a stronger version of the other. - * self.require_aligned_chunks = 1 - * self.require_aligned_terminal = 1 # <<<<<<<<<<<<<< - * elif require_aligned_terminal: - * self.require_aligned_chunks = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":130 + * sample = phrase_location.arr + * else: + * stepsize = float(num_locations)/float(self.sample_size) # <<<<<<<<<<<<<< + * i = phrase_location.arr_low + * while i < num_locations and sample.len < self.sample_size * phrase_location.num_subpatterns: */ - __pyx_v_self->require_aligned_terminal = 1; - goto __pyx_L8; - } + if (unlikely(((double)__pyx_v_self->sample_size) == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_stepsize = (((double)__pyx_v_num_locations) / ((double)__pyx_v_self->sample_size)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":348 - * self.require_aligned_chunks = 1 - * self.require_aligned_terminal = 1 - * elif require_aligned_terminal: # <<<<<<<<<<<<<< - * self.require_aligned_chunks = 0 - * self.require_aligned_terminal = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":131 + * else: + * stepsize = float(num_locations)/float(self.sample_size) + * i = phrase_location.arr_low # <<<<<<<<<<<<<< + * while i < num_locations and sample.len < self.sample_size * phrase_location.num_subpatterns: + * '''Note: int(i) not guaranteed to have the desired */ - if (__pyx_v_require_aligned_terminal) { + __pyx_v_i = __pyx_v_phrase_location->arr_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":349 - * self.require_aligned_terminal = 1 - * elif require_aligned_terminal: - * self.require_aligned_chunks = 0 # <<<<<<<<<<<<<< - * self.require_aligned_terminal = 1 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":132 + * stepsize = float(num_locations)/float(self.sample_size) + * i = phrase_location.arr_low + * while i < num_locations and sample.len < self.sample_size * phrase_location.num_subpatterns: # <<<<<<<<<<<<<< + * '''Note: int(i) not guaranteed to have the desired + * effect, according to the python documentation''' */ - __pyx_v_self->require_aligned_chunks = 0; + while (1) { + __pyx_t_2 = (__pyx_v_i < __pyx_v_num_locations); + if (__pyx_t_2) { + __pyx_t_3 = (__pyx_v_sample->len < (__pyx_v_self->sample_size * __pyx_v_phrase_location->num_subpatterns)); + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_2; + } + if (!__pyx_t_4) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":350 - * elif require_aligned_terminal: - * self.require_aligned_chunks = 0 - * self.require_aligned_terminal = 1 # <<<<<<<<<<<<<< - * else: - * self.require_aligned_chunks = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":135 + * '''Note: int(i) not guaranteed to have the desired + * effect, according to the python documentation''' + * if fmod(i,1.0) > 0.5: # <<<<<<<<<<<<<< + * val = int(ceil(i)) + * else: */ - __pyx_v_self->require_aligned_terminal = 1; - goto __pyx_L8; - } - /*else*/ { + __pyx_t_4 = (fmod(__pyx_v_i, 1.0) > 0.5); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":352 - * self.require_aligned_terminal = 1 - * else: - * self.require_aligned_chunks = 0 # <<<<<<<<<<<<<< - * self.require_aligned_terminal = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":136 + * effect, according to the python documentation''' + * if fmod(i,1.0) > 0.5: + * val = int(ceil(i)) # <<<<<<<<<<<<<< + * else: + * val = int(floor(i)) */ - __pyx_v_self->require_aligned_chunks = 0; + __pyx_v_val = ((int)ceil(__pyx_v_i)); + goto __pyx_L11; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":353 - * else: - * self.require_aligned_chunks = 0 - * self.require_aligned_terminal = 0 # <<<<<<<<<<<<<< - * - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":138 + * val = int(ceil(i)) + * else: + * val = int(floor(i)) # <<<<<<<<<<<<<< + * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) + * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) */ - __pyx_v_self->require_aligned_terminal = 0; - } - __pyx_L8:; + __pyx_v_val = ((int)floor(__pyx_v_i)); + } + __pyx_L11:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":357 - * - * # diagnostics - * self.prev_norm_prefix = () # <<<<<<<<<<<<<< - * - * self.findexes = IntList(initial_len=10) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":139 + * else: + * val = int(floor(i)) + * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) # <<<<<<<<<<<<<< + * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) + * i = i + stepsize */ - __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); - __Pyx_GIVEREF(((PyObject *)__pyx_empty_tuple)); - __Pyx_GOTREF(__pyx_v_self->prev_norm_prefix); - __Pyx_DECREF(__pyx_v_self->prev_norm_prefix); - __pyx_v_self->prev_norm_prefix = ((PyObject *)__pyx_empty_tuple); + __pyx_v_j = (__pyx_v_phrase_location->arr_low + (__pyx_v_val * __pyx_v_phrase_location->num_subpatterns)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":359 - * self.prev_norm_prefix = () - * - * self.findexes = IntList(initial_len=10) # <<<<<<<<<<<<<< - * self.findexes1 = IntList(initial_len=10) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":140 + * val = int(floor(i)) + * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) + * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) # <<<<<<<<<<<<<< + * i = i + stepsize + * return sample + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_sample->__pyx_vtab)->_extend_arr(__pyx_v_sample, (__pyx_v_phrase_location->arr->arr + __pyx_v_j), __pyx_v_phrase_location->num_subpatterns); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":141 + * j = phrase_location.arr_low + (val*phrase_location.num_subpatterns) + * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) + * i = i + stepsize # <<<<<<<<<<<<<< + * return sample * */ - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__initial_len), __pyx_int_10) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_GIVEREF(__pyx_t_5); - __Pyx_GOTREF(__pyx_v_self->findexes); - __Pyx_DECREF(((PyObject *)__pyx_v_self->findexes)); - __pyx_v_self->findexes = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_v_i = (__pyx_v_i + __pyx_v_stepsize); + } + } + __pyx_L8:; + } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":360 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":142 + * sample._extend_arr(phrase_location.arr.arr + j, phrase_location.num_subpatterns) + * i = i + stepsize + * return sample # <<<<<<<<<<<<<< * - * self.findexes = IntList(initial_len=10) - * self.findexes1 = IntList(initial_len=10) # <<<<<<<<<<<<<< * - * def configure(self, SuffixArray fsarray, DataArray edarray, Sampler sampler): */ - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__initial_len), __pyx_int_10) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __Pyx_GIVEREF(__pyx_t_4); - __Pyx_GOTREF(__pyx_v_self->findexes1); - __Pyx_DECREF(((PyObject *)__pyx_v_self->findexes1)); - __pyx_v_self->findexes1 = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_4); - __pyx_t_4 = 0; - - __pyx_r = 0; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_sample)); + __pyx_r = ((PyObject *)__pyx_v_sample); goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_3configure(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_3_sa_23HieroCachingRuleFactory_2configure[] = "This gives the RuleFactory access to the Context object.\n Here we also use it to precompute the most expensive intersections\n in the corpus quickly."; -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_3configure(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray = 0; - struct __pyx_obj_3_sa_DataArray *__pyx_v_edarray = 0; - struct __pyx_obj_3_sa_Sampler *__pyx_v_sampler = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("configure (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fsarray,&__pyx_n_s__edarray,&__pyx_n_s__sampler,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fsarray)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__edarray)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("configure", 1, 3, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sampler)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("configure", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "configure") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_fsarray = ((struct __pyx_obj_3_sa_SuffixArray *)values[0]); - __pyx_v_edarray = ((struct __pyx_obj_3_sa_DataArray *)values[1]); - __pyx_v_sampler = ((struct __pyx_obj_3_sa_Sampler *)values[2]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("configure", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.configure", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fsarray), __pyx_ptype_3_sa_SuffixArray, 1, "fsarray", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_edarray), __pyx_ptype_3_sa_DataArray, 1, "edarray", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sampler), __pyx_ptype_3_sa_Sampler, 1, "sampler", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_2configure(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fsarray, __pyx_v_edarray, __pyx_v_sampler); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_AddTraceback("_sa.Sampler.sample", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_sample); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":362 - * self.findexes1 = IntList(initial_len=10) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":154 * - * def configure(self, SuffixArray fsarray, DataArray edarray, Sampler sampler): # <<<<<<<<<<<<<< - * '''This gives the RuleFactory access to the Context object. - * Here we also use it to precompute the most expensive intersections + * + * cdef void assign_matching(Matching* m, int* arr, int start, int step, int* sent_id_arr): # <<<<<<<<<<<<<< + * m.arr = arr + * m.start = start */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_2configure(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray, struct __pyx_obj_3_sa_DataArray *__pyx_v_edarray, struct __pyx_obj_3_sa_Sampler *__pyx_v_sampler) { - PyObject *__pyx_r = NULL; +static void __pyx_f_3_sa_assign_matching(struct __pyx_t_3_sa_Matching *__pyx_v_m, int *__pyx_v_arr, int __pyx_v_start, int __pyx_v_step, int *__pyx_v_sent_id_arr) { __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("configure", 0); + __Pyx_RefNannySetupContext("assign_matching", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":366 - * Here we also use it to precompute the most expensive intersections - * in the corpus quickly.''' - * self.fsa = fsarray # <<<<<<<<<<<<<< - * self.fda = fsarray.darray - * self.eda = edarray + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":155 + * + * cdef void assign_matching(Matching* m, int* arr, int start, int step, int* sent_id_arr): + * m.arr = arr # <<<<<<<<<<<<<< + * m.start = start + * m.end = start + step */ - __Pyx_INCREF(((PyObject *)__pyx_v_fsarray)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fsarray)); - __Pyx_GOTREF(__pyx_v_self->fsa); - __Pyx_DECREF(((PyObject *)__pyx_v_self->fsa)); - __pyx_v_self->fsa = __pyx_v_fsarray; + __pyx_v_m->arr = __pyx_v_arr; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":367 - * in the corpus quickly.''' - * self.fsa = fsarray - * self.fda = fsarray.darray # <<<<<<<<<<<<<< - * self.eda = edarray - * self.fid2symid = self.set_idmap(self.fda) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":156 + * cdef void assign_matching(Matching* m, int* arr, int start, int step, int* sent_id_arr): + * m.arr = arr + * m.start = start # <<<<<<<<<<<<<< + * m.end = start + step + * m.sent_id = sent_id_arr[arr[start]] */ - __Pyx_INCREF(((PyObject *)__pyx_v_fsarray->darray)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fsarray->darray)); - __Pyx_GOTREF(__pyx_v_self->fda); - __Pyx_DECREF(((PyObject *)__pyx_v_self->fda)); - __pyx_v_self->fda = __pyx_v_fsarray->darray; + __pyx_v_m->start = __pyx_v_start; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":368 - * self.fsa = fsarray - * self.fda = fsarray.darray - * self.eda = edarray # <<<<<<<<<<<<<< - * self.fid2symid = self.set_idmap(self.fda) - * self.eid2symid = self.set_idmap(self.eda) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":157 + * m.arr = arr + * m.start = start + * m.end = start + step # <<<<<<<<<<<<<< + * m.sent_id = sent_id_arr[arr[start]] + * m.size = step */ - __Pyx_INCREF(((PyObject *)__pyx_v_edarray)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_edarray)); - __Pyx_GOTREF(__pyx_v_self->eda); - __Pyx_DECREF(((PyObject *)__pyx_v_self->eda)); - __pyx_v_self->eda = __pyx_v_edarray; + __pyx_v_m->end = (__pyx_v_start + __pyx_v_step); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":369 - * self.fda = fsarray.darray - * self.eda = edarray - * self.fid2symid = self.set_idmap(self.fda) # <<<<<<<<<<<<<< - * self.eid2symid = self.set_idmap(self.eda) - * self.precompute() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":158 + * m.start = start + * m.end = start + step + * m.sent_id = sent_id_arr[arr[start]] # <<<<<<<<<<<<<< + * m.size = step + * */ - __pyx_t_1 = ((PyObject *)__pyx_v_self->fda); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->set_idmap(__pyx_v_self, ((struct __pyx_obj_3_sa_DataArray *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_self->fid2symid); - __Pyx_DECREF(((PyObject *)__pyx_v_self->fid2symid)); - __pyx_v_self->fid2symid = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); - __pyx_t_2 = 0; + __pyx_v_m->sent_id = (__pyx_v_sent_id_arr[(__pyx_v_arr[__pyx_v_start])]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":370 - * self.eda = edarray - * self.fid2symid = self.set_idmap(self.fda) - * self.eid2symid = self.set_idmap(self.eda) # <<<<<<<<<<<<<< - * self.precompute() - * self.sampler = sampler + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":159 + * m.end = start + step + * m.sent_id = sent_id_arr[arr[start]] + * m.size = step # <<<<<<<<<<<<<< + * + * */ - __pyx_t_2 = ((PyObject *)__pyx_v_self->eda); - __Pyx_INCREF(__pyx_t_2); - __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->set_idmap(__pyx_v_self, ((struct __pyx_obj_3_sa_DataArray *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->eid2symid); - __Pyx_DECREF(((PyObject *)__pyx_v_self->eid2symid)); - __pyx_v_self->eid2symid = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_v_m->size = __pyx_v_step; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":371 - * self.fid2symid = self.set_idmap(self.fda) - * self.eid2symid = self.set_idmap(self.eda) - * self.precompute() # <<<<<<<<<<<<<< - * self.sampler = sampler - * - */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__precompute); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 371; __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[8]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_RefNannyFinishContext(); +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":372 - * self.eid2symid = self.set_idmap(self.eda) - * self.precompute() - * self.sampler = sampler # <<<<<<<<<<<<<< +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":162 * - * cdef set_idmap(self, DataArray darray): + * + * cdef int* append_combined_matching(int* arr, Matching* loc1, Matching* loc2, # <<<<<<<<<<<<<< + * int offset_by_one, int num_subpatterns, int* result_len): + * cdef int i, new_len */ - __Pyx_INCREF(((PyObject *)__pyx_v_sampler)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_sampler)); - __Pyx_GOTREF(__pyx_v_self->sampler); - __Pyx_DECREF(((PyObject *)__pyx_v_self->sampler)); - __pyx_v_self->sampler = __pyx_v_sampler; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.configure", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} +static int *__pyx_f_3_sa_append_combined_matching(int *__pyx_v_arr, struct __pyx_t_3_sa_Matching *__pyx_v_loc1, struct __pyx_t_3_sa_Matching *__pyx_v_loc2, CYTHON_UNUSED int __pyx_v_offset_by_one, int __pyx_v_num_subpatterns, int *__pyx_v_result_len) { + int __pyx_v_i; + int __pyx_v_new_len; + int *__pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_t_2; + __Pyx_RefNannySetupContext("append_combined_matching", 0); -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":374 - * self.sampler = sampler + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":166 + * cdef int i, new_len + * + * new_len = result_len[0] + num_subpatterns # <<<<<<<<<<<<<< + * arr = realloc(arr, new_len*sizeof(int)) * - * cdef set_idmap(self, DataArray darray): # <<<<<<<<<<<<<< - * cdef int word_id, new_word_id, N - * cdef IntList idmap */ + __pyx_v_new_len = ((__pyx_v_result_len[0]) + __pyx_v_num_subpatterns); -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_set_idmap(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_DataArray *__pyx_v_darray) { - int __pyx_v_word_id; - int __pyx_v_new_word_id; - int __pyx_v_N; - struct __pyx_obj_3_sa_IntList *__pyx_v_idmap = 0; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("set_idmap", 0); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":167 + * + * new_len = result_len[0] + num_subpatterns + * arr = realloc(arr, new_len*sizeof(int)) # <<<<<<<<<<<<<< + * + * for i from 0 <= i < loc1.size: + */ + __pyx_v_arr = ((int *)realloc(__pyx_v_arr, (__pyx_v_new_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":378 - * cdef IntList idmap + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":169 + * arr = realloc(arr, new_len*sizeof(int)) * - * N = len(darray.id2word) # <<<<<<<<<<<<<< - * idmap = IntList(initial_len=N) - * for word_id from 0 <= word_id < N: + * for i from 0 <= i < loc1.size: # <<<<<<<<<<<<<< + * arr[result_len[0]+i] = loc1.arr[loc1.start+i] + * if num_subpatterns > loc1.size: */ - __pyx_t_1 = __pyx_v_darray->id2word; - __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_N = __pyx_t_2; + __pyx_t_1 = __pyx_v_loc1->size; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":379 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":170 * - * N = len(darray.id2word) - * idmap = IntList(initial_len=N) # <<<<<<<<<<<<<< - * for word_id from 0 <= word_id < N: - * new_word_id = sym_fromstring(darray.id2word[word_id], True) + * for i from 0 <= i < loc1.size: + * arr[result_len[0]+i] = loc1.arr[loc1.start+i] # <<<<<<<<<<<<<< + * if num_subpatterns > loc1.size: + * arr[new_len-1] = loc2.arr[loc2.end-1] */ - __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_3 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_v_idmap = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); - __pyx_t_3 = 0; + (__pyx_v_arr[((__pyx_v_result_len[0]) + __pyx_v_i)]) = (__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":380 - * N = len(darray.id2word) - * idmap = IntList(initial_len=N) - * for word_id from 0 <= word_id < N: # <<<<<<<<<<<<<< - * new_word_id = sym_fromstring(darray.id2word[word_id], True) - * idmap.arr[word_id] = new_word_id + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":171 + * for i from 0 <= i < loc1.size: + * arr[result_len[0]+i] = loc1.arr[loc1.start+i] + * if num_subpatterns > loc1.size: # <<<<<<<<<<<<<< + * arr[new_len-1] = loc2.arr[loc2.end-1] + * result_len[0] = new_len */ - __pyx_t_4 = __pyx_v_N; - for (__pyx_v_word_id = 0; __pyx_v_word_id < __pyx_t_4; __pyx_v_word_id++) { + __pyx_t_2 = (__pyx_v_num_subpatterns > __pyx_v_loc1->size); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":381 - * idmap = IntList(initial_len=N) - * for word_id from 0 <= word_id < N: - * new_word_id = sym_fromstring(darray.id2word[word_id], True) # <<<<<<<<<<<<<< - * idmap.arr[word_id] = new_word_id - * return idmap + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":172 + * arr[result_len[0]+i] = loc1.arr[loc1.start+i] + * if num_subpatterns > loc1.size: + * arr[new_len-1] = loc2.arr[loc2.end-1] # <<<<<<<<<<<<<< + * result_len[0] = new_len + * return arr */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_darray->id2word, __pyx_v_word_id, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_1 = 0; - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_new_word_id = __pyx_t_7; + (__pyx_v_arr[(__pyx_v_new_len - 1)]) = (__pyx_v_loc2->arr[(__pyx_v_loc2->end - 1)]); + goto __pyx_L5; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":382 - * for word_id from 0 <= word_id < N: - * new_word_id = sym_fromstring(darray.id2word[word_id], True) - * idmap.arr[word_id] = new_word_id # <<<<<<<<<<<<<< - * return idmap + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":173 + * if num_subpatterns > loc1.size: + * arr[new_len-1] = loc2.arr[loc2.end-1] + * result_len[0] = new_len # <<<<<<<<<<<<<< + * return arr * */ - (__pyx_v_idmap->arr[__pyx_v_word_id]) = __pyx_v_new_word_id; - } + (__pyx_v_result_len[0]) = __pyx_v_new_len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":383 - * new_word_id = sym_fromstring(darray.id2word[word_id], True) - * idmap.arr[word_id] = new_word_id - * return idmap # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":174 + * arr[new_len-1] = loc2.arr[loc2.end-1] + * result_len[0] = new_len + * return arr # <<<<<<<<<<<<<< * * */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_idmap)); - __pyx_r = ((PyObject *)__pyx_v_idmap); + __pyx_r = __pyx_v_arr; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.set_idmap", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_idmap); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_5pattern2phrase(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_5pattern2phrase(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pattern2phrase (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_4pattern2phrase(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_pattern)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":386 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":177 * * - * def pattern2phrase(self, pattern): # <<<<<<<<<<<<<< - * # pattern is a tuple, which we must convert to a hiero Phrase - * result = () + * cdef int* extend_arr(int* arr, int* arr_len, int* appendix, int appendix_len): # <<<<<<<<<<<<<< + * cdef int new_len + * */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_4pattern2phrase(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_pattern) { - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_v_arity = NULL; - PyObject *__pyx_v_word_id = NULL; - PyObject *__pyx_v_new_id = NULL; - PyObject *__pyx_r = NULL; +static int *__pyx_f_3_sa_extend_arr(int *__pyx_v_arr, int *__pyx_v_arr_len, int *__pyx_v_appendix, int __pyx_v_appendix_len) { + int __pyx_v_new_len; + int *__pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("pattern2phrase", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":388 - * def pattern2phrase(self, pattern): - * # pattern is a tuple, which we must convert to a hiero Phrase - * result = () # <<<<<<<<<<<<<< - * arity = 0 - * for word_id in pattern: - */ - __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); - __pyx_v_result = __pyx_empty_tuple; + __Pyx_RefNannySetupContext("extend_arr", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":389 - * # pattern is a tuple, which we must convert to a hiero Phrase - * result = () - * arity = 0 # <<<<<<<<<<<<<< - * for word_id in pattern: - * if word_id == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":180 + * cdef int new_len + * + * new_len = arr_len[0] + appendix_len # <<<<<<<<<<<<<< + * arr = realloc(arr, new_len*sizeof(int)) + * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) */ - __Pyx_INCREF(__pyx_int_0); - __pyx_v_arity = __pyx_int_0; + __pyx_v_new_len = ((__pyx_v_arr_len[0]) + __pyx_v_appendix_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":390 - * result = () - * arity = 0 - * for word_id in pattern: # <<<<<<<<<<<<<< - * if word_id == -1: - * arity = arity + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":181 + * + * new_len = arr_len[0] + appendix_len + * arr = realloc(arr, new_len*sizeof(int)) # <<<<<<<<<<<<<< + * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) + * arr_len[0] = new_len */ - if (PyList_CheckExact(__pyx_v_pattern) || PyTuple_CheckExact(__pyx_v_pattern)) { - __pyx_t_1 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; - } - for (;;) { - if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF(__pyx_v_word_id); - __pyx_v_word_id = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_v_arr = ((int *)realloc(__pyx_v_arr, (__pyx_v_new_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":391 - * arity = 0 - * for word_id in pattern: - * if word_id == -1: # <<<<<<<<<<<<<< - * arity = arity + 1 - * new_id = sym_setindex(self.category, arity) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":182 + * new_len = arr_len[0] + appendix_len + * arr = realloc(arr, new_len*sizeof(int)) + * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) # <<<<<<<<<<<<<< + * arr_len[0] = new_len + * return arr */ - __pyx_t_4 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { + memcpy((__pyx_v_arr + (__pyx_v_arr_len[0])), __pyx_v_appendix, (__pyx_v_appendix_len * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":392 - * for word_id in pattern: - * if word_id == -1: - * arity = arity + 1 # <<<<<<<<<<<<<< - * new_id = sym_setindex(self.category, arity) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":183 + * arr = realloc(arr, new_len*sizeof(int)) + * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) + * arr_len[0] = new_len # <<<<<<<<<<<<<< + * return arr + * */ - __pyx_t_4 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_v_arity); - __pyx_v_arity = __pyx_t_4; - __pyx_t_4 = 0; + (__pyx_v_arr_len[0]) = __pyx_v_new_len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":393 - * if word_id == -1: - * arity = arity + 1 - * new_id = sym_setindex(self.category, arity) # <<<<<<<<<<<<<< - * else: - * new_id = sym_fromstring(self.fda.id2word[word_id], True) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":184 + * memcpy(arr+arr_len[0], appendix, appendix_len*sizeof(int)) + * arr_len[0] = new_len + * return arr # <<<<<<<<<<<<<< + * + * cdef int median(int low, int high, int step): */ - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_arity); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_v_new_id); - __pyx_v_new_id = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L5; - } - /*else*/ { + __pyx_r = __pyx_v_arr; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":395 - * new_id = sym_setindex(self.category, arity) - * else: - * new_id = sym_fromstring(self.fda.id2word[word_id], True) # <<<<<<<<<<<<<< - * result = result + (new_id,) - * return Phrase(result) - */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = PyObject_GetItem(__pyx_v_self->fda->id2word, __pyx_v_word_id); if (!__pyx_t_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __pyx_t_7 = 0; - __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_XDECREF(__pyx_v_new_id); - __pyx_v_new_id = __pyx_t_8; - __pyx_t_8 = 0; - } - __pyx_L5:; + __pyx_r = 0; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":396 - * else: - * new_id = sym_fromstring(self.fda.id2word[word_id], True) - * result = result + (new_id,) # <<<<<<<<<<<<<< - * return Phrase(result) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":186 + * return arr + * + * cdef int median(int low, int high, int step): # <<<<<<<<<<<<<< + * return low + (((high - low)/step)/2)*step * */ - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_v_new_id); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_new_id); - __Pyx_GIVEREF(__pyx_v_new_id); - __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_result)); - __pyx_v_result = __pyx_t_9; - __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":397 - * new_id = sym_fromstring(self.fda.id2word[word_id], True) - * result = result + (new_id,) - * return Phrase(result) # <<<<<<<<<<<<<< +static int __pyx_f_3_sa_median(int __pyx_v_low, int __pyx_v_high, int __pyx_v_step) { + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("median", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":187 + * + * cdef int median(int low, int high, int step): + * return low + (((high - low)/step)/2)*step # <<<<<<<<<<<<<< + * * - * def pattern2phrase_plus(self, pattern): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_result)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_result)); - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_r = __pyx_t_9; - __pyx_t_9 = 0; + __pyx_t_1 = (__pyx_v_high - __pyx_v_low); + if (unlikely(__pyx_v_step == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_step == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_1))) { + PyErr_Format(PyExc_OverflowError, "value too large to perform division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_r = (__pyx_v_low + (__Pyx_div_long(__Pyx_div_int(__pyx_t_1, __pyx_v_step), 2) * __pyx_v_step)); goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.pattern2phrase", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_WriteUnraisable("_sa.median", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_arity); - __Pyx_XDECREF(__pyx_v_word_id); - __Pyx_XDECREF(__pyx_v_new_id); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_7pattern2phrase_plus(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_7pattern2phrase_plus(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pattern2phrase_plus (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_6pattern2phrase_plus(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_pattern)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":399 - * return Phrase(result) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":190 * - * def pattern2phrase_plus(self, pattern): # <<<<<<<<<<<<<< - * # returns a list containing both the pattern, and pattern - * # suffixed/prefixed with the NT category. + * + * cdef void find_comparable_matchings(int low, int high, int* arr, int step, int loc, int* loc_minus, int* loc_plus): # <<<<<<<<<<<<<< + * # Returns (minus, plus) indices for the portion of the array + * # in which all matchings have the same first index as the one */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_6pattern2phrase_plus(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_pattern) { - PyObject *__pyx_v_patterns = NULL; - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_v_arity = NULL; - PyObject *__pyx_v_word_id = NULL; - PyObject *__pyx_v_new_id = NULL; - PyObject *__pyx_r = NULL; +static void __pyx_f_3_sa_find_comparable_matchings(int __pyx_v_low, int __pyx_v_high, int *__pyx_v_arr, int __pyx_v_step, int __pyx_v_loc, int *__pyx_v_loc_minus, int *__pyx_v_loc_plus) { __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - int __pyx_t_10; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("pattern2phrase_plus", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":402 - * # returns a list containing both the pattern, and pattern - * # suffixed/prefixed with the NT category. - * patterns = [] # <<<<<<<<<<<<<< - * result = () - * arity = 0 - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 402; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_patterns = __pyx_t_1; - __pyx_t_1 = 0; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("find_comparable_matchings", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":403 - * # suffixed/prefixed with the NT category. - * patterns = [] - * result = () # <<<<<<<<<<<<<< - * arity = 0 - * for word_id in pattern: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":194 + * # in which all matchings have the same first index as the one + * # starting at loc + * loc_plus[0] = loc + step # <<<<<<<<<<<<<< + * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: + * loc_plus[0] = loc_plus[0] + step */ - __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); - __pyx_v_result = __pyx_empty_tuple; + (__pyx_v_loc_plus[0]) = (__pyx_v_loc + __pyx_v_step); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":404 - * patterns = [] - * result = () - * arity = 0 # <<<<<<<<<<<<<< - * for word_id in pattern: - * if word_id == -1: - */ - __Pyx_INCREF(__pyx_int_0); - __pyx_v_arity = __pyx_int_0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":405 - * result = () - * arity = 0 - * for word_id in pattern: # <<<<<<<<<<<<<< - * if word_id == -1: - * arity = arity + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":195 + * # starting at loc + * loc_plus[0] = loc + step + * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: # <<<<<<<<<<<<<< + * loc_plus[0] = loc_plus[0] + step + * loc_minus[0] = loc */ - if (PyList_CheckExact(__pyx_v_pattern) || PyTuple_CheckExact(__pyx_v_pattern)) { - __pyx_t_1 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; - } - for (;;) { - if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif + while (1) { + __pyx_t_1 = ((__pyx_v_loc_plus[0]) < __pyx_v_high); + if (__pyx_t_1) { + __pyx_t_2 = ((__pyx_v_arr[(__pyx_v_loc_plus[0])]) == (__pyx_v_arr[__pyx_v_loc])); + __pyx_t_3 = __pyx_t_2; } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF(__pyx_v_word_id); - __pyx_v_word_id = __pyx_t_4; - __pyx_t_4 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":406 - * arity = 0 - * for word_id in pattern: - * if word_id == -1: # <<<<<<<<<<<<<< - * arity = arity + 1 - * new_id = sym_setindex(self.category, arity) - */ - __pyx_t_4 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":407 - * for word_id in pattern: - * if word_id == -1: - * arity = arity + 1 # <<<<<<<<<<<<<< - * new_id = sym_setindex(self.category, arity) - * else: - */ - __pyx_t_4 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_v_arity); - __pyx_v_arity = __pyx_t_4; - __pyx_t_4 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":408 - * if word_id == -1: - * arity = arity + 1 - * new_id = sym_setindex(self.category, arity) # <<<<<<<<<<<<<< - * else: - * new_id = sym_fromstring(self.fda.id2word[word_id], True) - */ - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_arity); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_v_new_id); - __pyx_v_new_id = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L5; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":410 - * new_id = sym_setindex(self.category, arity) - * else: - * new_id = sym_fromstring(self.fda.id2word[word_id], True) # <<<<<<<<<<<<<< - * result = result + (new_id,) - * patterns.append(Phrase(result)) - */ - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = PyObject_GetItem(__pyx_v_self->fda->id2word, __pyx_v_word_id); if (!__pyx_t_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __pyx_t_7 = 0; - __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_XDECREF(__pyx_v_new_id); - __pyx_v_new_id = __pyx_t_8; - __pyx_t_8 = 0; + __pyx_t_3 = __pyx_t_1; } - __pyx_L5:; + if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":411 - * else: - * new_id = sym_fromstring(self.fda.id2word[word_id], True) - * result = result + (new_id,) # <<<<<<<<<<<<<< - * patterns.append(Phrase(result)) - * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":196 + * loc_plus[0] = loc + step + * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: + * loc_plus[0] = loc_plus[0] + step # <<<<<<<<<<<<<< + * loc_minus[0] = loc + * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: */ - __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_INCREF(__pyx_v_new_id); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_new_id); - __Pyx_GIVEREF(__pyx_v_new_id); - __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_result)); - __pyx_v_result = __pyx_t_9; - __pyx_t_9 = 0; + (__pyx_v_loc_plus[0]) = ((__pyx_v_loc_plus[0]) + __pyx_v_step); } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":412 - * new_id = sym_fromstring(self.fda.id2word[word_id], True) - * result = result + (new_id,) - * patterns.append(Phrase(result)) # <<<<<<<<<<<<<< - * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) - * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) - */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_result)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_result)); - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_10 = PyList_Append(__pyx_v_patterns, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":413 - * result = result + (new_id,) - * patterns.append(Phrase(result)) - * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) # <<<<<<<<<<<<<< - * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) - * return patterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":197 + * while loc_plus[0] < high and arr[loc_plus[0]] == arr[loc]: + * loc_plus[0] = loc_plus[0] + step + * loc_minus[0] = loc # <<<<<<<<<<<<<< + * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: + * loc_minus[0] = loc_minus[0] - step */ - __pyx_t_9 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, 1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); - __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_10 = PyList_Append(__pyx_v_patterns, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + (__pyx_v_loc_minus[0]) = __pyx_v_loc; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":414 - * patterns.append(Phrase(result)) - * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) - * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) # <<<<<<<<<<<<<< - * return patterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":198 + * loc_plus[0] = loc_plus[0] + step + * loc_minus[0] = loc + * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: # <<<<<<<<<<<<<< + * loc_minus[0] = loc_minus[0] - step * */ - __pyx_t_9 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, 1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_v_result)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); - __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_10 = PyList_Append(__pyx_v_patterns, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + while (1) { + __pyx_t_3 = (((__pyx_v_loc_minus[0]) - __pyx_v_step) >= __pyx_v_low); + if (__pyx_t_3) { + __pyx_t_1 = ((__pyx_v_arr[((__pyx_v_loc_minus[0]) - __pyx_v_step)]) == (__pyx_v_arr[__pyx_v_loc])); + __pyx_t_2 = __pyx_t_1; + } else { + __pyx_t_2 = __pyx_t_3; + } + if (!__pyx_t_2) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":415 - * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) - * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) - * return patterns # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":199 + * loc_minus[0] = loc + * while loc_minus[0]-step >= low and arr[loc_minus[0]-step] == arr[loc]: + * loc_minus[0] = loc_minus[0] - step # <<<<<<<<<<<<<< + * * - * def precompute(self): */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_patterns)); - __pyx_r = ((PyObject *)__pyx_v_patterns); - goto __pyx_L0; + (__pyx_v_loc_minus[0]) = ((__pyx_v_loc_minus[0]) - __pyx_v_step); + } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.pattern2phrase_plus", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_patterns); - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_arity); - __Pyx_XDECREF(__pyx_v_word_id); - __Pyx_XDECREF(__pyx_v_new_id); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); - return __pyx_r; } /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_9precompute(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_9precompute(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("precompute (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_8precompute(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":417 - * return patterns - * - * def precompute(self): # <<<<<<<<<<<<<< - * cdef Precomputation pre - * - */ - -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_8precompute(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self) { - struct __pyx_obj_3_sa_Precomputation *__pyx_v_pre = 0; - PyObject *__pyx_v_start_time = NULL; - PyObject *__pyx_v_pattern = NULL; - PyObject *__pyx_v_arr = NULL; - PyObject *__pyx_v_phrases = NULL; - PyObject *__pyx_v_phrase = NULL; - PyObject *__pyx_v_stop_time = NULL; - PyObject *__pyx_r = NULL; +static int __pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static int __pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_3_sa_Alignment *__pyx_v_alignment = 0; + float __pyx_v_by_slack_factor; + char *__pyx_v_category; + PyObject *__pyx_v_max_chunks = 0; + unsigned int __pyx_v_max_initial_size; + unsigned int __pyx_v_max_length; + unsigned int __pyx_v_max_nonterminals; + PyObject *__pyx_v_max_target_chunks = 0; + PyObject *__pyx_v_max_target_length = 0; + unsigned int __pyx_v_min_gap_size; + PyObject *__pyx_v_precompute_file = 0; + unsigned int __pyx_v_precompute_secondary_rank; + unsigned int __pyx_v_precompute_rank; + int __pyx_v_require_aligned_terminal; + int __pyx_v_require_aligned_chunks; + unsigned int __pyx_v_train_max_initial_size; + unsigned int __pyx_v_train_min_gap_size; + int __pyx_v_tight_phrases; + int __pyx_v_use_baeza_yates; + int __pyx_v_use_collocations; + int __pyx_v_use_index; + int __pyx_r; __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - Py_ssize_t __pyx_t_7; - int __pyx_t_8; - int __pyx_t_9; - Py_ssize_t __pyx_t_10; - PyObject *(*__pyx_t_11)(PyObject *); - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("precompute", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":420 - * cdef Precomputation pre - * - * if self.precompute_file is not None: # <<<<<<<<<<<<<< - * start_time = monitor_cpu() - * logger.info("Reading precomputed data from file %s... ", self.precompute_file) - */ - __pyx_t_1 = (__pyx_v_self->precompute_file != Py_None); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":421 - * - * if self.precompute_file is not None: - * start_time = monitor_cpu() # <<<<<<<<<<<<<< - * logger.info("Reading precomputed data from file %s... ", self.precompute_file) - * pre = Precomputation(from_binary=self.precompute_file) - */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_start_time = __pyx_t_2; - __pyx_t_2 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":422 - * if self.precompute_file is not None: - * start_time = monitor_cpu() - * logger.info("Reading precomputed data from file %s... ", self.precompute_file) # <<<<<<<<<<<<<< - * pre = Precomputation(from_binary=self.precompute_file) - * # check parameters of precomputation -- some are critical and some are not - */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_108)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_108)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_108)); - __Pyx_INCREF(__pyx_v_self->precompute_file); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->precompute_file); - __Pyx_GIVEREF(__pyx_v_self->precompute_file); - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":423 - * start_time = monitor_cpu() - * logger.info("Reading precomputed data from file %s... ", self.precompute_file) - * pre = Precomputation(from_binary=self.precompute_file) # <<<<<<<<<<<<<< - * # check parameters of precomputation -- some are critical and some are not - * if pre.max_nonterminals != self.max_nonterminals: - */ - __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__from_binary), __pyx_v_self->precompute_file) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Precomputation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_v_pre = ((struct __pyx_obj_3_sa_Precomputation *)__pyx_t_2); - __pyx_t_2 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":425 - * pre = Precomputation(from_binary=self.precompute_file) - * # check parameters of precomputation -- some are critical and some are not - * if pre.max_nonterminals != self.max_nonterminals: # <<<<<<<<<<<<<< - * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) - * if pre.max_length != self.max_length: - */ - __pyx_t_1 = (__pyx_v_pre->max_nonterminals != __pyx_v_self->max_nonterminals); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":426 - * # check parameters of precomputation -- some are critical and some are not - * if pre.max_nonterminals != self.max_nonterminals: - * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) # <<<<<<<<<<<<<< - * if pre.max_length != self.max_length: - * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) - */ - __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__warn); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_pre->max_nonterminals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromLong(__pyx_v_self->max_nonterminals); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_109)); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_109)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109)); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_2 = 0; - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - goto __pyx_L4; - } - __pyx_L4:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":427 - * if pre.max_nonterminals != self.max_nonterminals: - * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) - * if pre.max_length != self.max_length: # <<<<<<<<<<<<<< - * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) - * if pre.train_max_initial_size != self.train_max_initial_size: - */ - __pyx_t_1 = (__pyx_v_pre->max_length != __pyx_v_self->max_length); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":428 - * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) - * if pre.max_length != self.max_length: - * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) # <<<<<<<<<<<<<< - * if pre.train_max_initial_size != self.train_max_initial_size: - * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) - */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__warn); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyInt_FromLong(__pyx_v_pre->max_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyInt_FromLong(__pyx_v_self->max_length); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_110)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_110)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_110)); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_3 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 428; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L5; - } - __pyx_L5:; + __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alignment,&__pyx_n_s__by_slack_factor,&__pyx_n_s__category,&__pyx_n_s__max_chunks,&__pyx_n_s__max_initial_size,&__pyx_n_s__max_length,&__pyx_n_s__max_nonterminals,&__pyx_n_s__max_target_chunks,&__pyx_n_s__max_target_length,&__pyx_n_s__min_gap_size,&__pyx_n_s__precompute_file,&__pyx_n_s_70,&__pyx_n_s__precompute_rank,&__pyx_n_s_105,&__pyx_n_s_106,&__pyx_n_s_71,&__pyx_n_s__train_min_gap_size,&__pyx_n_s__tight_phrases,&__pyx_n_s__use_baeza_yates,&__pyx_n_s__use_collocations,&__pyx_n_s__use_index,0}; + PyObject* values[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":429 - * if pre.max_length != self.max_length: - * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) - * if pre.train_max_initial_size != self.train_max_initial_size: # <<<<<<<<<<<<<< - * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) - * if pre.train_min_gap_size != self.train_min_gap_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":259 + * char* category="[X]", + * # maximum number of contiguous chunks of terminal symbols in RHS of a rule. If None, defaults to max_nonterminals+1 + * max_chunks=None, # <<<<<<<<<<<<<< + * # maximum span of a grammar rule in TEST DATA + * unsigned max_initial_size=10, */ - __pyx_t_1 = (__pyx_v_pre->train_max_initial_size != __pyx_v_self->train_max_initial_size); - if (__pyx_t_1) { + values[3] = ((PyObject *)Py_None); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":430 - * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) - * if pre.train_max_initial_size != self.train_max_initial_size: - * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) # <<<<<<<<<<<<<< - * if pre.train_min_gap_size != self.train_min_gap_size: - * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":267 + * unsigned max_nonterminals=2, + * # maximum number of contiguous chunks of terminal symbols in target-side RHS of a rule. If None, defaults to max_nonterminals+1 + * max_target_chunks=None, # <<<<<<<<<<<<<< + * # maximum number of target side symbols (both T and NT) allowed in a rule. If None, defaults to max_initial_size + * max_target_length=None, */ - __pyx_t_4 = PyInt_FromLong(__pyx_v_pre->train_max_initial_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->train_max_initial_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_4 = 0; - __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_111), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L6; - } - __pyx_L6:; + values[7] = ((PyObject *)Py_None); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":431 - * if pre.train_max_initial_size != self.train_max_initial_size: - * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) - * if pre.train_min_gap_size != self.train_min_gap_size: # <<<<<<<<<<<<<< - * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) - * if self.use_index: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":269 + * max_target_chunks=None, + * # maximum number of target side symbols (both T and NT) allowed in a rule. If None, defaults to max_initial_size + * max_target_length=None, # <<<<<<<<<<<<<< + * # minimum span of a nonterminal in the RHS of a rule in TEST DATA + * unsigned min_gap_size=2, */ - __pyx_t_1 = (__pyx_v_pre->train_min_gap_size != __pyx_v_self->train_min_gap_size); - if (__pyx_t_1) { + values[8] = ((PyObject *)Py_None); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":432 - * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) - * if pre.train_min_gap_size != self.train_min_gap_size: - * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) # <<<<<<<<<<<<<< - * if self.use_index: - * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":273 + * unsigned min_gap_size=2, + * # filename of file containing precomputed collocations + * precompute_file=None, # <<<<<<<<<<<<<< + * # maximum frequency rank of patterns used to compute triples (don't set higher than 20). + * unsigned precompute_secondary_rank=20, */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_pre->train_min_gap_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyInt_FromLong(__pyx_v_self->train_min_gap_size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_2 = 0; - __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_112), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_5, 0, 0, 0); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; + values[10] = ((PyObject *)Py_None); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 21: values[20] = PyTuple_GET_ITEM(__pyx_args, 20); + case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19); + case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18); + case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); + case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); + case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); + case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); + case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); + case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); + case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); + case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); + case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); + case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alignment)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__by_slack_factor); + if (value) { values[1] = value; kw_args--; } + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__category); + if (value) { values[2] = value; kw_args--; } + } + case 3: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_chunks); + if (value) { values[3] = value; kw_args--; } + } + case 4: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_initial_size); + if (value) { values[4] = value; kw_args--; } + } + case 5: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_length); + if (value) { values[5] = value; kw_args--; } + } + case 6: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_nonterminals); + if (value) { values[6] = value; kw_args--; } + } + case 7: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_target_chunks); + if (value) { values[7] = value; kw_args--; } + } + case 8: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__max_target_length); + if (value) { values[8] = value; kw_args--; } + } + case 9: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_gap_size); + if (value) { values[9] = value; kw_args--; } + } + case 10: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__precompute_file); + if (value) { values[10] = value; kw_args--; } + } + case 11: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_70); + if (value) { values[11] = value; kw_args--; } + } + case 12: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__precompute_rank); + if (value) { values[12] = value; kw_args--; } + } + case 13: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_105); + if (value) { values[13] = value; kw_args--; } + } + case 14: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_106); + if (value) { values[14] = value; kw_args--; } + } + case 15: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_71); + if (value) { values[15] = value; kw_args--; } + } + case 16: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__train_min_gap_size); + if (value) { values[16] = value; kw_args--; } + } + case 17: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tight_phrases); + if (value) { values[17] = value; kw_args--; } + } + case 18: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_baeza_yates); + if (value) { values[18] = value; kw_args--; } + } + case 19: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_collocations); + if (value) { values[19] = value; kw_args--; } + } + case 20: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_index); + if (value) { values[20] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 21: values[20] = PyTuple_GET_ITEM(__pyx_args, 20); + case 20: values[19] = PyTuple_GET_ITEM(__pyx_args, 19); + case 19: values[18] = PyTuple_GET_ITEM(__pyx_args, 18); + case 18: values[17] = PyTuple_GET_ITEM(__pyx_args, 17); + case 17: values[16] = PyTuple_GET_ITEM(__pyx_args, 16); + case 16: values[15] = PyTuple_GET_ITEM(__pyx_args, 15); + case 15: values[14] = PyTuple_GET_ITEM(__pyx_args, 14); + case 14: values[13] = PyTuple_GET_ITEM(__pyx_args, 13); + case 13: values[12] = PyTuple_GET_ITEM(__pyx_args, 12); + case 12: values[11] = PyTuple_GET_ITEM(__pyx_args, 11); + case 11: values[10] = PyTuple_GET_ITEM(__pyx_args, 10); + case 10: values[9] = PyTuple_GET_ITEM(__pyx_args, 9); + case 9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8); + case 8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7); + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } } - __pyx_L7:; + __pyx_v_alignment = ((struct __pyx_obj_3_sa_Alignment *)values[0]); + if (values[1]) { + __pyx_v_by_slack_factor = __pyx_PyFloat_AsFloat(values[1]); if (unlikely((__pyx_v_by_slack_factor == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":433 - * if pre.train_min_gap_size != self.train_min_gap_size: - * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) - * if self.use_index: # <<<<<<<<<<<<<< - * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) - * for pattern, arr in pre.precomputed_index.iteritems(): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":255 + * Alignment alignment, + * # parameter for double-binary search; doesn't seem to matter much + * float by_slack_factor=1.0, # <<<<<<<<<<<<<< + * # name of generic nonterminal used by Hiero + * char* category="[X]", */ - if (__pyx_v_self->use_index) { + __pyx_v_by_slack_factor = ((float)1.0); + } + if (values[2]) { + __pyx_v_category = PyBytes_AsString(values[2]); if (unlikely((!__pyx_v_category) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_category = ((char *)__pyx_k_107); + } + __pyx_v_max_chunks = values[3]; + if (values[4]) { + __pyx_v_max_initial_size = __Pyx_PyInt_AsUnsignedInt(values[4]); if (unlikely((__pyx_v_max_initial_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_max_initial_size = ((unsigned int)10); + } + if (values[5]) { + __pyx_v_max_length = __Pyx_PyInt_AsUnsignedInt(values[5]); if (unlikely((__pyx_v_max_length == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_max_length = ((unsigned int)5); + } + if (values[6]) { + __pyx_v_max_nonterminals = __Pyx_PyInt_AsUnsignedInt(values[6]); if (unlikely((__pyx_v_max_nonterminals == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_max_nonterminals = ((unsigned int)2); + } + __pyx_v_max_target_chunks = values[7]; + __pyx_v_max_target_length = values[8]; + if (values[9]) { + __pyx_v_min_gap_size = __Pyx_PyInt_AsUnsignedInt(values[9]); if (unlikely((__pyx_v_min_gap_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_min_gap_size = ((unsigned int)2); + } + __pyx_v_precompute_file = values[10]; + if (values[11]) { + __pyx_v_precompute_secondary_rank = __Pyx_PyInt_AsUnsignedInt(values[11]); if (unlikely((__pyx_v_precompute_secondary_rank == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 275; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_precompute_secondary_rank = ((unsigned int)20); + } + if (values[12]) { + __pyx_v_precompute_rank = __Pyx_PyInt_AsUnsignedInt(values[12]); if (unlikely((__pyx_v_precompute_rank == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_precompute_rank = ((unsigned int)100); + } + if (values[13]) { + __pyx_v_require_aligned_terminal = __Pyx_PyObject_IsTrue(values[13]); if (unlikely((__pyx_v_require_aligned_terminal == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":434 - * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) - * if self.use_index: - * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) # <<<<<<<<<<<<<< - * for pattern, arr in pre.precomputed_index.iteritems(): - * phrases = self.pattern2phrase_plus(pattern) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":279 + * unsigned precompute_rank=100, + * # require extracted rules to have at least one aligned word + * bint require_aligned_terminal=True, # <<<<<<<<<<<<<< + * # require each contiguous chunk of extracted rules to have at least one aligned word + * bint require_aligned_chunks=False, */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__info); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __pyx_v_pre->precomputed_index; - __Pyx_INCREF(__pyx_t_5); - __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_113)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_113)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_113)); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_require_aligned_terminal = ((int)1); + } + if (values[14]) { + __pyx_v_require_aligned_chunks = __Pyx_PyObject_IsTrue(values[14]); if (unlikely((__pyx_v_require_aligned_chunks == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":435 - * if self.use_index: - * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) - * for pattern, arr in pre.precomputed_index.iteritems(): # <<<<<<<<<<<<<< - * phrases = self.pattern2phrase_plus(pattern) - * for phrase in phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":281 + * bint require_aligned_terminal=True, + * # require each contiguous chunk of extracted rules to have at least one aligned word + * bint require_aligned_chunks=False, # <<<<<<<<<<<<<< + * # maximum span of a grammar rule extracted from TRAINING DATA + * unsigned train_max_initial_size=10, */ - __pyx_t_6 = 0; - if (unlikely(__pyx_v_pre->precomputed_index == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_pre->precomputed_index, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_5); - __pyx_t_5 = __pyx_t_2; - __pyx_t_2 = 0; - while (1) { - __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_7, &__pyx_t_6, &__pyx_t_2, &__pyx_t_4, NULL, __pyx_t_8); - if (unlikely(__pyx_t_9 == 0)) break; - if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_v_pattern); - __pyx_v_pattern = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_v_arr); - __pyx_v_arr = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_v_require_aligned_chunks = ((int)0); + } + if (values[15]) { + __pyx_v_train_max_initial_size = __Pyx_PyInt_AsUnsignedInt(values[15]); if (unlikely((__pyx_v_train_max_initial_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_train_max_initial_size = ((unsigned int)10); + } + if (values[16]) { + __pyx_v_train_min_gap_size = __Pyx_PyInt_AsUnsignedInt(values[16]); if (unlikely((__pyx_v_train_min_gap_size == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { + __pyx_v_train_min_gap_size = ((unsigned int)2); + } + if (values[17]) { + __pyx_v_tight_phrases = __Pyx_PyObject_IsTrue(values[17]); if (unlikely((__pyx_v_tight_phrases == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":436 - * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) - * for pattern, arr in pre.precomputed_index.iteritems(): - * phrases = self.pattern2phrase_plus(pattern) # <<<<<<<<<<<<<< - * for phrase in phrases: - * self.precomputed_index[phrase] = arr + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":287 + * unsigned train_min_gap_size=2, + * # True if phrases should be tight, False otherwise (False == slower but better results) + * bint tight_phrases=False, # <<<<<<<<<<<<<< + * # True to require use of double-binary alg, false otherwise + * bint use_baeza_yates=True, */ - __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pattern2phrase_plus); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_pattern); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pattern); - __Pyx_GIVEREF(__pyx_v_pattern); - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_v_phrases); - __pyx_v_phrases = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_v_tight_phrases = ((int)0); + } + if (values[18]) { + __pyx_v_use_baeza_yates = __Pyx_PyObject_IsTrue(values[18]); if (unlikely((__pyx_v_use_baeza_yates == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":437 - * for pattern, arr in pre.precomputed_index.iteritems(): - * phrases = self.pattern2phrase_plus(pattern) - * for phrase in phrases: # <<<<<<<<<<<<<< - * self.precomputed_index[phrase] = arr - * if self.use_collocations: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":289 + * bint tight_phrases=False, + * # True to require use of double-binary alg, false otherwise + * bint use_baeza_yates=True, # <<<<<<<<<<<<<< + * # True to enable used of precomputed collocations + * bint use_collocations=True, */ - if (PyList_CheckExact(__pyx_v_phrases) || PyTuple_CheckExact(__pyx_v_phrases)) { - __pyx_t_3 = __pyx_v_phrases; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0; - __pyx_t_11 = NULL; - } else { - __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_phrases); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; - } - for (;;) { - if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_3)) { - if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; - #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_3)) { - if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; - #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_2 = __pyx_t_11(__pyx_t_3); - if (unlikely(!__pyx_t_2)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 437; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_XDECREF(__pyx_v_phrase); - __pyx_v_phrase = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_use_baeza_yates = ((int)1); + } + if (values[19]) { + __pyx_v_use_collocations = __Pyx_PyObject_IsTrue(values[19]); if (unlikely((__pyx_v_use_collocations == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":438 - * phrases = self.pattern2phrase_plus(pattern) - * for phrase in phrases: - * self.precomputed_index[phrase] = arr # <<<<<<<<<<<<<< - * if self.use_collocations: - * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":291 + * bint use_baeza_yates=True, + * # True to enable used of precomputed collocations + * bint use_collocations=True, # <<<<<<<<<<<<<< + * # True to enable use of precomputed inverted indices + * bint use_index=True): */ - if (PyObject_SetItem(__pyx_v_self->precomputed_index, __pyx_v_phrase, __pyx_v_arr) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L8; + __pyx_v_use_collocations = ((int)1); } - __pyx_L8:; + if (values[20]) { + __pyx_v_use_index = __Pyx_PyObject_IsTrue(values[20]); if (unlikely((__pyx_v_use_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } else { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":439 - * for phrase in phrases: - * self.precomputed_index[phrase] = arr - * if self.use_collocations: # <<<<<<<<<<<<<< - * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) - * for pattern, arr in pre.precomputed_collocations.iteritems(): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":293 + * bint use_collocations=True, + * # True to enable use of precomputed inverted indices + * bint use_index=True): # <<<<<<<<<<<<<< + * '''Note: we make a distinction between the min_gap_size + * and max_initial_size used in test and train. The latter */ - if (__pyx_v_self->use_collocations) { + __pyx_v_use_index = ((int)1); + } + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 21, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return -1; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_alignment), __pyx_ptype_3_sa_Alignment, 1, "alignment", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory___cinit__(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_alignment, __pyx_v_by_slack_factor, __pyx_v_category, __pyx_v_max_chunks, __pyx_v_max_initial_size, __pyx_v_max_length, __pyx_v_max_nonterminals, __pyx_v_max_target_chunks, __pyx_v_max_target_length, __pyx_v_min_gap_size, __pyx_v_precompute_file, __pyx_v_precompute_secondary_rank, __pyx_v_precompute_rank, __pyx_v_require_aligned_terminal, __pyx_v_require_aligned_chunks, __pyx_v_train_max_initial_size, __pyx_v_train_min_gap_size, __pyx_v_tight_phrases, __pyx_v_use_baeza_yates, __pyx_v_use_collocations, __pyx_v_use_index); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":440 - * self.precomputed_index[phrase] = arr - * if self.use_collocations: - * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) # <<<<<<<<<<<<<< - * for pattern, arr in pre.precomputed_collocations.iteritems(): - * phrase = self.pattern2phrase(pattern) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":251 + * cdef IntList findexes1 + * + * def __cinit__(self, # <<<<<<<<<<<<<< + * # compiled alignment object (REQUIRED) + * Alignment alignment, */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __pyx_v_pre->precomputed_collocations; - __Pyx_INCREF(__pyx_t_5); - __pyx_t_7 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_114)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_114)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_114)); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":441 - * if self.use_collocations: - * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) - * for pattern, arr in pre.precomputed_collocations.iteritems(): # <<<<<<<<<<<<<< - * phrase = self.pattern2phrase(pattern) - * self.precomputed_collocations[phrase] = arr +static int __pyx_pf_3_sa_23HieroCachingRuleFactory___cinit__(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Alignment *__pyx_v_alignment, float __pyx_v_by_slack_factor, char *__pyx_v_category, PyObject *__pyx_v_max_chunks, unsigned int __pyx_v_max_initial_size, unsigned int __pyx_v_max_length, unsigned int __pyx_v_max_nonterminals, PyObject *__pyx_v_max_target_chunks, PyObject *__pyx_v_max_target_length, unsigned int __pyx_v_min_gap_size, PyObject *__pyx_v_precompute_file, unsigned int __pyx_v_precompute_secondary_rank, unsigned int __pyx_v_precompute_rank, int __pyx_v_require_aligned_terminal, int __pyx_v_require_aligned_chunks, unsigned int __pyx_v_train_max_initial_size, unsigned int __pyx_v_train_min_gap_size, int __pyx_v_tight_phrases, int __pyx_v_use_baeza_yates, int __pyx_v_use_collocations, int __pyx_v_use_index) { + int __pyx_r; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__cinit__", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":299 + * respectively. This is because Chiang's model does not require + * them to be the same, therefore we don't either.''' + * self.rules = TrieTable(True) # cache # <<<<<<<<<<<<<< + * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) + * if alignment is None: */ - __pyx_t_7 = 0; - if (unlikely(__pyx_v_pre->precomputed_collocations == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_pre->precomputed_collocations, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_6), (&__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_5); - __pyx_t_5 = __pyx_t_2; - __pyx_t_2 = 0; - while (1) { - __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_6, &__pyx_t_7, &__pyx_t_2, &__pyx_t_3, NULL, __pyx_t_8); - if (unlikely(__pyx_t_9 == 0)) break; - if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_v_pattern); - __pyx_v_pattern = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_v_arr); - __pyx_v_arr = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_TrieTable)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->rules); + __Pyx_DECREF(((PyObject *)__pyx_v_self->rules)); + __pyx_v_self->rules = ((struct __pyx_obj_3_sa_TrieTable *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":442 - * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) - * for pattern, arr in pre.precomputed_collocations.iteritems(): - * phrase = self.pattern2phrase(pattern) # <<<<<<<<<<<<<< - * self.precomputed_collocations[phrase] = arr - * stop_time = monitor_cpu() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":300 + * them to be the same, therefore we don't either.''' + * self.rules = TrieTable(True) # cache + * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) # <<<<<<<<<<<<<< + * if alignment is None: + * raise Exception("Must specify an alignment object") */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pattern2phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_pattern); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pattern); - __Pyx_GIVEREF(__pyx_v_pattern); - __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_v_phrase); - __pyx_v_phrase = __pyx_t_4; - __pyx_t_4 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":443 - * for pattern, arr in pre.precomputed_collocations.iteritems(): - * phrase = self.pattern2phrase(pattern) - * self.precomputed_collocations[phrase] = arr # <<<<<<<<<<<<<< - * stop_time = monitor_cpu() - * logger.info("Processing precomputations took %f seconds", stop_time - start_time) - */ - if (PyObject_SetItem(__pyx_v_self->precomputed_collocations, __pyx_v_phrase, __pyx_v_arr) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 443; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L13; - } - __pyx_L13:; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->rules->root); + __Pyx_DECREF(__pyx_v_self->rules->root); + __pyx_v_self->rules->root = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":444 - * phrase = self.pattern2phrase(pattern) - * self.precomputed_collocations[phrase] = arr - * stop_time = monitor_cpu() # <<<<<<<<<<<<<< - * logger.info("Processing precomputations took %f seconds", stop_time - start_time) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":301 + * self.rules = TrieTable(True) # cache + * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) + * if alignment is None: # <<<<<<<<<<<<<< + * raise Exception("Must specify an alignment object") + * self.alignment = alignment */ - __pyx_t_5 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_v_stop_time = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_t_3 = (((PyObject *)__pyx_v_alignment) == Py_None); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":445 - * self.precomputed_collocations[phrase] = arr - * stop_time = monitor_cpu() - * logger.info("Processing precomputations took %f seconds", stop_time - start_time) # <<<<<<<<<<<<<< - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":302 + * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) + * if alignment is None: + * raise Exception("Must specify an alignment object") # <<<<<<<<<<<<<< + * self.alignment = alignment * */ - __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__info); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Subtract(__pyx_v_stop_time, __pyx_v_start_time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_k_tuple_109), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_115)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_115)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_115)); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.precompute", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_pre); - __Pyx_XDECREF(__pyx_v_start_time); - __Pyx_XDECREF(__pyx_v_pattern); - __Pyx_XDECREF(__pyx_v_arr); - __Pyx_XDECREF(__pyx_v_phrases); - __Pyx_XDECREF(__pyx_v_phrase); - __Pyx_XDECREF(__pyx_v_stop_time); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_11get_precomputed_collocation(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_11get_precomputed_collocation(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_precomputed_collocation (wrapper)", 0); - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_10get_precomputed_collocation(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_phrase)); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":448 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":303 + * if alignment is None: + * raise Exception("Must specify an alignment object") + * self.alignment = alignment # <<<<<<<<<<<<<< * - * def get_precomputed_collocation(self, phrase): # <<<<<<<<<<<<<< - * if phrase in self.precomputed_collocations: - * arr = self.precomputed_collocations[phrase] + * # grammar parameters and settings */ + __Pyx_INCREF(((PyObject *)__pyx_v_alignment)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_alignment)); + __Pyx_GOTREF(__pyx_v_self->alignment); + __Pyx_DECREF(((PyObject *)__pyx_v_self->alignment)); + __pyx_v_self->alignment = __pyx_v_alignment; -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_10get_precomputed_collocation(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_phrase) { - PyObject *__pyx_v_arr = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_precomputed_collocation", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":449 - * - * def get_precomputed_collocation(self, phrase): - * if phrase in self.precomputed_collocations: # <<<<<<<<<<<<<< - * arr = self.precomputed_collocations[phrase] - * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":307 + * # grammar parameters and settings + * # NOTE: setting max_nonterminals > 2 is not currently supported in Hiero + * self.max_length = max_length # <<<<<<<<<<<<<< + * self.max_nonterminals = max_nonterminals + * self.max_initial_size = max_initial_size */ - __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->precomputed_collocations, __pyx_v_phrase))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { + __pyx_v_self->max_length = __pyx_v_max_length; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":450 - * def get_precomputed_collocation(self, phrase): - * if phrase in self.precomputed_collocations: - * arr = self.precomputed_collocations[phrase] # <<<<<<<<<<<<<< - * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) - * return None + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":308 + * # NOTE: setting max_nonterminals > 2 is not currently supported in Hiero + * self.max_length = max_length + * self.max_nonterminals = max_nonterminals # <<<<<<<<<<<<<< + * self.max_initial_size = max_initial_size + * self.train_max_initial_size = train_max_initial_size */ - __pyx_t_2 = PyObject_GetItem(__pyx_v_self->precomputed_collocations, __pyx_v_phrase); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_arr = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_self->max_nonterminals = __pyx_v_max_nonterminals; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":451 - * if phrase in self.precomputed_collocations: - * arr = self.precomputed_collocations[phrase] - * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) # <<<<<<<<<<<<<< - * return None - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":309 + * self.max_length = max_length + * self.max_nonterminals = max_nonterminals + * self.max_initial_size = max_initial_size # <<<<<<<<<<<<<< + * self.train_max_initial_size = train_max_initial_size + * self.min_gap_size = min_gap_size */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__arr), __pyx_v_arr) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__arr_low), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__arr_high), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_GetAttr(__pyx_v_phrase, __pyx_n_s__arity); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__num_subpatterns), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - goto __pyx_L3; - } - __pyx_L3:; + __pyx_v_self->max_initial_size = __pyx_v_max_initial_size; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":452 - * arr = self.precomputed_collocations[phrase] - * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) - * return None # <<<<<<<<<<<<<< - * - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":310 + * self.max_nonterminals = max_nonterminals + * self.max_initial_size = max_initial_size + * self.train_max_initial_size = train_max_initial_size # <<<<<<<<<<<<<< + * self.min_gap_size = min_gap_size + * self.train_min_gap_size = train_min_gap_size */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; + __pyx_v_self->train_max_initial_size = __pyx_v_train_max_initial_size; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_precomputed_collocation", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_arr); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":311 + * self.max_initial_size = max_initial_size + * self.train_max_initial_size = train_max_initial_size + * self.min_gap_size = min_gap_size # <<<<<<<<<<<<<< + * self.train_min_gap_size = train_min_gap_size + * self.category = sym_fromstring(category, False) + */ + __pyx_v_self->min_gap_size = __pyx_v_min_gap_size; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":455 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":312 + * self.train_max_initial_size = train_max_initial_size + * self.min_gap_size = min_gap_size + * self.train_min_gap_size = train_min_gap_size # <<<<<<<<<<<<<< + * self.category = sym_fromstring(category, False) * - * cdef int* baeza_yates_helper(self, int low1, int high1, int* arr1, int step1, # <<<<<<<<<<<<<< - * int low2, int high2, int* arr2, int step2, - * int offset_by_one, int len_last, int num_subpatterns, int* result_len): */ + __pyx_v_self->train_min_gap_size = __pyx_v_train_min_gap_size; -static int *__pyx_f_3_sa_23HieroCachingRuleFactory_baeza_yates_helper(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_low1, int __pyx_v_high1, int *__pyx_v_arr1, int __pyx_v_step1, int __pyx_v_low2, int __pyx_v_high2, int *__pyx_v_arr2, int __pyx_v_step2, int __pyx_v_offset_by_one, int __pyx_v_len_last, int __pyx_v_num_subpatterns, int *__pyx_v_result_len) { - int __pyx_v_i1; - int __pyx_v_i2; - int __pyx_v_med1; - int __pyx_v_med2; - int __pyx_v_med1_plus; - int __pyx_v_med1_minus; - int __pyx_v_med2_minus; - int __pyx_v_med2_plus; - int __pyx_v_d_first; - int __pyx_v_qsetsize; - int __pyx_v_dsetsize; - int __pyx_v_tmp; - int __pyx_v_search_low; - int __pyx_v_search_high; - int __pyx_v_med_result_len; - int __pyx_v_low_result_len; - int __pyx_v_high_result_len; - long __pyx_v_comparison; - int *__pyx_v_result; - int *__pyx_v_low_result; - int *__pyx_v_med_result; - int *__pyx_v_high_result; - struct __pyx_t_3_sa_Matching __pyx_v_loc1; - struct __pyx_t_3_sa_Matching __pyx_v_loc2; - int *__pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - double __pyx_t_5; - double __pyx_t_6; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("baeza_yates_helper", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":468 - * cdef Matching loc1, loc2 - * - * result = malloc(0*sizeof(int*)) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":313 + * self.min_gap_size = min_gap_size + * self.train_min_gap_size = train_min_gap_size + * self.category = sym_fromstring(category, False) # <<<<<<<<<<<<<< * - * d_first = 0 + * if max_chunks is None: */ - __pyx_v_result = ((int *)malloc((0 * (sizeof(int *))))); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyBytes_FromString(__pyx_v_category); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_1 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_v_self->category = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":470 - * result = malloc(0*sizeof(int*)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":315 + * self.category = sym_fromstring(category, False) * - * d_first = 0 # <<<<<<<<<<<<<< - * if high1 - low1 > high2 - low2: - * d_first = 1 + * if max_chunks is None: # <<<<<<<<<<<<<< + * self.max_chunks = self.max_nonterminals + 1 + * else: */ - __pyx_v_d_first = 0; + __pyx_t_3 = (__pyx_v_max_chunks == Py_None); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":471 - * - * d_first = 0 - * if high1 - low1 > high2 - low2: # <<<<<<<<<<<<<< - * d_first = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":316 * + * if max_chunks is None: + * self.max_chunks = self.max_nonterminals + 1 # <<<<<<<<<<<<<< + * else: + * self.max_chunks = max_chunks */ - __pyx_t_1 = ((__pyx_v_high1 - __pyx_v_low1) > (__pyx_v_high2 - __pyx_v_low2)); - if (__pyx_t_1) { + __pyx_v_self->max_chunks = (__pyx_v_self->max_nonterminals + 1); + goto __pyx_L4; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":472 - * d_first = 0 - * if high1 - low1 > high2 - low2: - * d_first = 1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":318 + * self.max_chunks = self.max_nonterminals + 1 + * else: + * self.max_chunks = max_chunks # <<<<<<<<<<<<<< * - * # First, check to see if we are at any of the recursive base cases + * if max_target_chunks is None: */ - __pyx_v_d_first = 1; - goto __pyx_L3; + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_max_chunks); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->max_chunks = __pyx_t_6; } - __pyx_L3:; + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":476 - * # First, check to see if we are at any of the recursive base cases - * # Case 1: one of the sets is empty - * if low1 >= high1 or low2 >= high2: # <<<<<<<<<<<<<< - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":320 + * self.max_chunks = max_chunks * + * if max_target_chunks is None: # <<<<<<<<<<<<<< + * self.max_target_chunks = self.max_nonterminals + 1 + * else: */ - __pyx_t_1 = (__pyx_v_low1 >= __pyx_v_high1); - if (!__pyx_t_1) { - __pyx_t_2 = (__pyx_v_low2 >= __pyx_v_high2); - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_1; - } + __pyx_t_3 = (__pyx_v_max_target_chunks == Py_None); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":477 - * # Case 1: one of the sets is empty - * if low1 >= high1 or low2 >= high2: - * return result # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":321 * - * # Case 2: sets are non-overlapping + * if max_target_chunks is None: + * self.max_target_chunks = self.max_nonterminals + 1 # <<<<<<<<<<<<<< + * else: + * self.max_target_chunks = max_target_chunks */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; - goto __pyx_L4; + __pyx_v_self->max_target_chunks = (__pyx_v_self->max_nonterminals + 1); + goto __pyx_L5; } - __pyx_L4:; + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":480 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":323 + * self.max_target_chunks = self.max_nonterminals + 1 + * else: + * self.max_target_chunks = max_target_chunks # <<<<<<<<<<<<<< * - * # Case 2: sets are non-overlapping - * assign_matching(&loc1, arr1, high1-step1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: - */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, (__pyx_v_high1 - __pyx_v_step1), __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":481 - * # Case 2: sets are non-overlapping - * assign_matching(&loc1, arr1, high1-step1, step1, self.fda.sent_id.arr) - * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: - * return result + * if max_target_length is None: */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_low2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_max_target_chunks); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->max_target_chunks = __pyx_t_6; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":482 - * assign_matching(&loc1, arr1, high1-step1, step1, self.fda.sent_id.arr) - * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: # <<<<<<<<<<<<<< - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":325 + * self.max_target_chunks = max_target_chunks * + * if max_target_length is None: # <<<<<<<<<<<<<< + * self.max_target_length = max_initial_size + * else: */ - __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) == -1); + __pyx_t_3 = (__pyx_v_max_target_length == Py_None); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":483 - * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: - * return result # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":326 * - * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) + * if max_target_length is None: + * self.max_target_length = max_initial_size # <<<<<<<<<<<<<< + * else: + * self.max_target_length = max_target_length */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; - goto __pyx_L5; + __pyx_v_self->max_target_length = __pyx_v_max_initial_size; + goto __pyx_L6; } - __pyx_L5:; + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":485 - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":328 + * self.max_target_length = max_initial_size + * else: + * self.max_target_length = max_target_length # <<<<<<<<<<<<<< * - * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + * # algorithmic parameters and settings */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_low1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_max_target_length); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->max_target_length = __pyx_t_6; + } + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":486 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":331 * - * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) - * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: - * return result + * # algorithmic parameters and settings + * self.precomputed_collocations = {} # <<<<<<<<<<<<<< + * self.precomputed_index = {} + * self.use_index = use_index */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, (__pyx_v_high2 - __pyx_v_step2), __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 331; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __Pyx_GOTREF(__pyx_v_self->precomputed_collocations); + __Pyx_DECREF(__pyx_v_self->precomputed_collocations); + __pyx_v_self->precomputed_collocations = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":487 - * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) - * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: # <<<<<<<<<<<<<< - * return result - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":332 + * # algorithmic parameters and settings + * self.precomputed_collocations = {} + * self.precomputed_index = {} # <<<<<<<<<<<<<< + * self.use_index = use_index + * self.use_collocations = use_collocations */ - __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) == 1); - if (__pyx_t_3) { + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __Pyx_GOTREF(__pyx_v_self->precomputed_index); + __Pyx_DECREF(__pyx_v_self->precomputed_index); + __pyx_v_self->precomputed_index = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":488 - * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: - * return result # <<<<<<<<<<<<<< - * - * # Case 3: query set and data set do not meet size mismatch constraints; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":333 + * self.precomputed_collocations = {} + * self.precomputed_index = {} + * self.use_index = use_index # <<<<<<<<<<<<<< + * self.use_collocations = use_collocations + * self.max_rank = {} */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; - goto __pyx_L6; - } - __pyx_L6:; + __pyx_v_self->use_index = __pyx_v_use_index; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":492 - * # Case 3: query set and data set do not meet size mismatch constraints; - * # We use mergesort instead in this case - * qsetsize = (high1-low1) / step1 # <<<<<<<<<<<<<< - * dsetsize = (high2-low2) / step2 - * if d_first: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":334 + * self.precomputed_index = {} + * self.use_index = use_index + * self.use_collocations = use_collocations # <<<<<<<<<<<<<< + * self.max_rank = {} + * self.precompute_file = precompute_file */ - __pyx_t_4 = (__pyx_v_high1 - __pyx_v_low1); - if (unlikely(__pyx_v_step1 == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_step1 == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_4))) { - PyErr_Format(PyExc_OverflowError, "value too large to perform division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 492; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_qsetsize = __Pyx_div_int(__pyx_t_4, __pyx_v_step1); + __pyx_v_self->use_collocations = __pyx_v_use_collocations; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":493 - * # We use mergesort instead in this case - * qsetsize = (high1-low1) / step1 - * dsetsize = (high2-low2) / step2 # <<<<<<<<<<<<<< - * if d_first: - * tmp = qsetsize + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":335 + * self.use_index = use_index + * self.use_collocations = use_collocations + * self.max_rank = {} # <<<<<<<<<<<<<< + * self.precompute_file = precompute_file + * self.precompute_rank = precompute_rank */ - __pyx_t_4 = (__pyx_v_high2 - __pyx_v_low2); - if (unlikely(__pyx_v_step2 == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_step2 == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_4))) { - PyErr_Format(PyExc_OverflowError, "value too large to perform division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_dsetsize = __Pyx_div_int(__pyx_t_4, __pyx_v_step2); + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); + __Pyx_GOTREF(__pyx_v_self->max_rank); + __Pyx_DECREF(__pyx_v_self->max_rank); + __pyx_v_self->max_rank = ((PyObject *)__pyx_t_4); + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":494 - * qsetsize = (high1-low1) / step1 - * dsetsize = (high2-low2) / step2 - * if d_first: # <<<<<<<<<<<<<< - * tmp = qsetsize - * qsetsize = dsetsize + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":336 + * self.use_collocations = use_collocations + * self.max_rank = {} + * self.precompute_file = precompute_file # <<<<<<<<<<<<<< + * self.precompute_rank = precompute_rank + * self.precompute_secondary_rank = precompute_secondary_rank */ - if (__pyx_v_d_first) { + __Pyx_INCREF(__pyx_v_precompute_file); + __Pyx_GIVEREF(__pyx_v_precompute_file); + __Pyx_GOTREF(__pyx_v_self->precompute_file); + __Pyx_DECREF(__pyx_v_self->precompute_file); + __pyx_v_self->precompute_file = __pyx_v_precompute_file; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":495 - * dsetsize = (high2-low2) / step2 - * if d_first: - * tmp = qsetsize # <<<<<<<<<<<<<< - * qsetsize = dsetsize - * dsetsize = tmp + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":337 + * self.max_rank = {} + * self.precompute_file = precompute_file + * self.precompute_rank = precompute_rank # <<<<<<<<<<<<<< + * self.precompute_secondary_rank = precompute_secondary_rank + * self.use_baeza_yates = use_baeza_yates */ - __pyx_v_tmp = __pyx_v_qsetsize; + __pyx_v_self->precompute_rank = __pyx_v_precompute_rank; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":496 - * if d_first: - * tmp = qsetsize - * qsetsize = dsetsize # <<<<<<<<<<<<<< - * dsetsize = tmp - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":338 + * self.precompute_file = precompute_file + * self.precompute_rank = precompute_rank + * self.precompute_secondary_rank = precompute_secondary_rank # <<<<<<<<<<<<<< + * self.use_baeza_yates = use_baeza_yates + * self.by_slack_factor = by_slack_factor */ - __pyx_v_qsetsize = __pyx_v_dsetsize; + __pyx_v_self->precompute_secondary_rank = __pyx_v_precompute_secondary_rank; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":497 - * tmp = qsetsize - * qsetsize = dsetsize - * dsetsize = tmp # <<<<<<<<<<<<<< - * - * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":339 + * self.precompute_rank = precompute_rank + * self.precompute_secondary_rank = precompute_secondary_rank + * self.use_baeza_yates = use_baeza_yates # <<<<<<<<<<<<<< + * self.by_slack_factor = by_slack_factor + * if tight_phrases: */ - __pyx_v_dsetsize = __pyx_v_tmp; + __pyx_v_self->use_baeza_yates = __pyx_v_use_baeza_yates; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":340 + * self.precompute_secondary_rank = precompute_secondary_rank + * self.use_baeza_yates = use_baeza_yates + * self.by_slack_factor = by_slack_factor # <<<<<<<<<<<<<< + * if tight_phrases: + * self.tight_phrases = 1 + */ + __pyx_v_self->by_slack_factor = __pyx_v_by_slack_factor; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":341 + * self.use_baeza_yates = use_baeza_yates + * self.by_slack_factor = by_slack_factor + * if tight_phrases: # <<<<<<<<<<<<<< + * self.tight_phrases = 1 + * else: + */ + if (__pyx_v_tight_phrases) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":342 + * self.by_slack_factor = by_slack_factor + * if tight_phrases: + * self.tight_phrases = 1 # <<<<<<<<<<<<<< + * else: + * self.tight_phrases = 0 + */ + __pyx_v_self->tight_phrases = 1; goto __pyx_L7; } - __pyx_L7:; + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":499 - * dsetsize = tmp + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":344 + * self.tight_phrases = 1 + * else: + * self.tight_phrases = 0 # <<<<<<<<<<<<<< * - * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: # <<<<<<<<<<<<<< - * free(result) - * return self.merge_helper(low1, high1, arr1, step1, low2, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, result_len) + * if require_aligned_chunks: */ - __pyx_t_5 = ((__pyx_v_self->by_slack_factor * __pyx_v_qsetsize) * log(__pyx_v_dsetsize)); - __pyx_t_6 = log(2.0); - if (unlikely(__pyx_t_6 == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 499; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->tight_phrases = 0; } - __pyx_t_3 = ((__pyx_t_5 / __pyx_t_6) > __pyx_v_dsetsize); - if (__pyx_t_3) { + __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":500 - * - * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: - * free(result) # <<<<<<<<<<<<<< - * return self.merge_helper(low1, high1, arr1, step1, low2, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":346 + * self.tight_phrases = 0 * + * if require_aligned_chunks: # <<<<<<<<<<<<<< + * # one condition is a stronger version of the other. + * self.require_aligned_chunks = 1 */ - free(__pyx_v_result); + if (__pyx_v_require_aligned_chunks) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":501 - * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: - * free(result) - * return self.merge_helper(low1, high1, arr1, step1, low2, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, result_len) # <<<<<<<<<<<<<< - * - * # binary search. There are two flavors, depending on + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":348 + * if require_aligned_chunks: + * # one condition is a stronger version of the other. + * self.require_aligned_chunks = 1 # <<<<<<<<<<<<<< + * self.require_aligned_terminal = 1 + * elif require_aligned_terminal: */ - __pyx_r = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->merge_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_low2, __pyx_v_high2, __pyx_v_arr2, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, __pyx_v_result_len); - goto __pyx_L0; + __pyx_v_self->require_aligned_chunks = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":349 + * # one condition is a stronger version of the other. + * self.require_aligned_chunks = 1 + * self.require_aligned_terminal = 1 # <<<<<<<<<<<<<< + * elif require_aligned_terminal: + * self.require_aligned_chunks = 0 + */ + __pyx_v_self->require_aligned_terminal = 1; goto __pyx_L8; } - __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":505 - * # binary search. There are two flavors, depending on - * # whether the queryset or dataset is first - * if d_first: # <<<<<<<<<<<<<< - * med2 = median(low2, high2, step2) - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":350 + * self.require_aligned_chunks = 1 + * self.require_aligned_terminal = 1 + * elif require_aligned_terminal: # <<<<<<<<<<<<<< + * self.require_aligned_chunks = 0 + * self.require_aligned_terminal = 1 */ - if (__pyx_v_d_first) { + if (__pyx_v_require_aligned_terminal) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":506 - * # whether the queryset or dataset is first - * if d_first: - * med2 = median(low2, high2, step2) # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":351 + * self.require_aligned_terminal = 1 + * elif require_aligned_terminal: + * self.require_aligned_chunks = 0 # <<<<<<<<<<<<<< + * self.require_aligned_terminal = 1 + * else: */ - __pyx_v_med2 = __pyx_f_3_sa_median(__pyx_v_low2, __pyx_v_high2, __pyx_v_step2); + __pyx_v_self->require_aligned_chunks = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":507 - * if d_first: - * med2 = median(low2, high2, step2) - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * - * search_low = low1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":352 + * elif require_aligned_terminal: + * self.require_aligned_chunks = 0 + * self.require_aligned_terminal = 1 # <<<<<<<<<<<<<< + * else: + * self.require_aligned_chunks = 0 */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_med2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_v_self->require_aligned_terminal = 1; + goto __pyx_L8; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":509 - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":354 + * self.require_aligned_terminal = 1 + * else: + * self.require_aligned_chunks = 0 # <<<<<<<<<<<<<< + * self.require_aligned_terminal = 0 * - * search_low = low1 # <<<<<<<<<<<<<< - * search_high = high1 - * while search_low < search_high: */ - __pyx_v_search_low = __pyx_v_low1; + __pyx_v_self->require_aligned_chunks = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":510 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":355 + * else: + * self.require_aligned_chunks = 0 + * self.require_aligned_terminal = 0 # <<<<<<<<<<<<<< + * * - * search_low = low1 - * search_high = high1 # <<<<<<<<<<<<<< - * while search_low < search_high: - * med1 = median(search_low, search_high, step1) */ - __pyx_v_search_high = __pyx_v_high1; + __pyx_v_self->require_aligned_terminal = 0; + } + __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":511 - * search_low = low1 - * search_high = high1 - * while search_low < search_high: # <<<<<<<<<<<<<< - * med1 = median(search_low, search_high, step1) - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":359 + * + * # diagnostics + * self.prev_norm_prefix = () # <<<<<<<<<<<<<< + * + * self.findexes = IntList(initial_len=10) */ - while (1) { - __pyx_t_3 = (__pyx_v_search_low < __pyx_v_search_high); - if (!__pyx_t_3) break; + __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); + __Pyx_GIVEREF(((PyObject *)__pyx_empty_tuple)); + __Pyx_GOTREF(__pyx_v_self->prev_norm_prefix); + __Pyx_DECREF(__pyx_v_self->prev_norm_prefix); + __pyx_v_self->prev_norm_prefix = ((PyObject *)__pyx_empty_tuple); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":512 - * search_high = high1 - * while search_low < search_high: - * med1 = median(search_low, search_high, step1) # <<<<<<<<<<<<<< - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":361 + * self.prev_norm_prefix = () + * + * self.findexes = IntList(initial_len=10) # <<<<<<<<<<<<<< + * self.findexes1 = IntList(initial_len=10) + * */ - __pyx_v_med1 = __pyx_f_3_sa_median(__pyx_v_search_low, __pyx_v_search_high, __pyx_v_step1); + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__initial_len), __pyx_int_10) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_GIVEREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_v_self->findexes); + __Pyx_DECREF(((PyObject *)__pyx_v_self->findexes)); + __pyx_v_self->findexes = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5); + __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":513 - * while search_low < search_high: - * med1 = median(search_low, search_high, step1) - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) # <<<<<<<<<<<<<< - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) - * if comparison == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":362 + * + * self.findexes = IntList(initial_len=10) + * self.findexes1 = IntList(initial_len=10) # <<<<<<<<<<<<<< + * + * def configure(self, SuffixArray fsarray, DataArray edarray, */ - __pyx_f_3_sa_find_comparable_matchings(__pyx_v_low1, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_med1, (&__pyx_v_med1_minus), (&__pyx_v_med1_plus)); + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__initial_len), __pyx_int_10) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_GIVEREF(__pyx_t_4); + __Pyx_GOTREF(__pyx_v_self->findexes1); + __Pyx_DECREF(((PyObject *)__pyx_v_self->findexes1)); + __pyx_v_self->findexes1 = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_4); + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":514 - * med1 = median(search_low, search_high, step1) - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< - * if comparison == -1: - * search_low = med1_plus + __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_3configure(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_3_sa_23HieroCachingRuleFactory_2configure[] = "This gives the RuleFactory access to the Context object.\n Here we also use it to precompute the most expensive intersections\n in the corpus quickly."; +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_3configure(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray = 0; + struct __pyx_obj_3_sa_DataArray *__pyx_v_edarray = 0; + struct __pyx_obj_3_sa_Sampler *__pyx_v_sampler = 0; + struct __pyx_obj_3_sa_Scorer *__pyx_v_scorer = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("configure (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fsarray,&__pyx_n_s__edarray,&__pyx_n_s__sampler,&__pyx_n_s__scorer,0}; + PyObject* values[4] = {0,0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fsarray)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__edarray)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("configure", 1, 4, 4, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__sampler)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("configure", 1, 4, 4, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scorer)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("configure", 1, 4, 4, 3); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "configure") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 4) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + } + __pyx_v_fsarray = ((struct __pyx_obj_3_sa_SuffixArray *)values[0]); + __pyx_v_edarray = ((struct __pyx_obj_3_sa_DataArray *)values[1]); + __pyx_v_sampler = ((struct __pyx_obj_3_sa_Sampler *)values[2]); + __pyx_v_scorer = ((struct __pyx_obj_3_sa_Scorer *)values[3]); + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("configure", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.configure", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fsarray), __pyx_ptype_3_sa_SuffixArray, 1, "fsarray", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_edarray), __pyx_ptype_3_sa_DataArray, 1, "edarray", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sampler), __pyx_ptype_3_sa_Sampler, 1, "sampler", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_scorer), __pyx_ptype_3_sa_Scorer, 1, "scorer", 0))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_2configure(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fsarray, __pyx_v_edarray, __pyx_v_sampler, __pyx_v_scorer); + goto __pyx_L0; + __pyx_L1_error:; + __pyx_r = NULL; + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":364 + * self.findexes1 = IntList(initial_len=10) + * + * def configure(self, SuffixArray fsarray, DataArray edarray, # <<<<<<<<<<<<<< + * Sampler sampler, Scorer scorer): + * '''This gives the RuleFactory access to the Context object. */ - __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings_set(__pyx_v_self, __pyx_v_med1_minus, __pyx_v_med1_plus, __pyx_v_arr1, __pyx_v_step1, (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":517 - * if comparison == -1: - * search_low = med1_plus - * elif comparison == 1: # <<<<<<<<<<<<<< - * search_high = med1_minus - * else: +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_2configure(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_SuffixArray *__pyx_v_fsarray, struct __pyx_obj_3_sa_DataArray *__pyx_v_edarray, struct __pyx_obj_3_sa_Sampler *__pyx_v_sampler, struct __pyx_obj_3_sa_Scorer *__pyx_v_scorer) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("configure", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":369 + * Here we also use it to precompute the most expensive intersections + * in the corpus quickly.''' + * self.fsa = fsarray # <<<<<<<<<<<<<< + * self.fda = fsarray.darray + * self.eda = edarray */ - switch (__pyx_v_comparison) { + __Pyx_INCREF(((PyObject *)__pyx_v_fsarray)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fsarray)); + __Pyx_GOTREF(__pyx_v_self->fsa); + __Pyx_DECREF(((PyObject *)__pyx_v_self->fsa)); + __pyx_v_self->fsa = __pyx_v_fsarray; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":515 - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) - * if comparison == -1: # <<<<<<<<<<<<<< - * search_low = med1_plus - * elif comparison == 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":370 + * in the corpus quickly.''' + * self.fsa = fsarray + * self.fda = fsarray.darray # <<<<<<<<<<<<<< + * self.eda = edarray + * self.fid2symid = self.set_idmap(self.fda) */ - case -1: + __Pyx_INCREF(((PyObject *)__pyx_v_fsarray->darray)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fsarray->darray)); + __Pyx_GOTREF(__pyx_v_self->fda); + __Pyx_DECREF(((PyObject *)__pyx_v_self->fda)); + __pyx_v_self->fda = __pyx_v_fsarray->darray; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":516 - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) - * if comparison == -1: - * search_low = med1_plus # <<<<<<<<<<<<<< - * elif comparison == 1: - * search_high = med1_minus + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":371 + * self.fsa = fsarray + * self.fda = fsarray.darray + * self.eda = edarray # <<<<<<<<<<<<<< + * self.fid2symid = self.set_idmap(self.fda) + * self.eid2symid = self.set_idmap(self.eda) */ - __pyx_v_search_low = __pyx_v_med1_plus; - break; + __Pyx_INCREF(((PyObject *)__pyx_v_edarray)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_edarray)); + __Pyx_GOTREF(__pyx_v_self->eda); + __Pyx_DECREF(((PyObject *)__pyx_v_self->eda)); + __pyx_v_self->eda = __pyx_v_edarray; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":517 - * if comparison == -1: - * search_low = med1_plus - * elif comparison == 1: # <<<<<<<<<<<<<< - * search_high = med1_minus - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":372 + * self.fda = fsarray.darray + * self.eda = edarray + * self.fid2symid = self.set_idmap(self.fda) # <<<<<<<<<<<<<< + * self.eid2symid = self.set_idmap(self.eda) + * self.precompute() */ - case 1: + __pyx_t_1 = ((PyObject *)__pyx_v_self->fda); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->set_idmap(__pyx_v_self, ((struct __pyx_obj_3_sa_DataArray *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_self->fid2symid); + __Pyx_DECREF(((PyObject *)__pyx_v_self->fid2symid)); + __pyx_v_self->fid2symid = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":518 - * search_low = med1_plus - * elif comparison == 1: - * search_high = med1_minus # <<<<<<<<<<<<<< - * else: - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":373 + * self.eda = edarray + * self.fid2symid = self.set_idmap(self.fda) + * self.eid2symid = self.set_idmap(self.eda) # <<<<<<<<<<<<<< + * self.precompute() + * self.sampler = sampler */ - __pyx_v_search_high = __pyx_v_med1_minus; - break; - default: + __pyx_t_2 = ((PyObject *)__pyx_v_self->eda); + __Pyx_INCREF(__pyx_t_2); + __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->set_idmap(__pyx_v_self, ((struct __pyx_obj_3_sa_DataArray *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_1); + __Pyx_GOTREF(__pyx_v_self->eid2symid); + __Pyx_DECREF(((PyObject *)__pyx_v_self->eid2symid)); + __pyx_v_self->eid2symid = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":520 - * search_high = med1_minus - * else: - * break # <<<<<<<<<<<<<< - * else: - * med1 = median(low1, high1, step1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":374 + * self.fid2symid = self.set_idmap(self.fda) + * self.eid2symid = self.set_idmap(self.eda) + * self.precompute() # <<<<<<<<<<<<<< + * self.sampler = sampler + * self.scorer = scorer */ - goto __pyx_L11_break; - break; - } - } - __pyx_L11_break:; - goto __pyx_L9; - } - /*else*/ { + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__precompute); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 374; __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[8]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":522 - * break - * else: - * med1 = median(low1, high1, step1) # <<<<<<<<<<<<<< - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":375 + * self.eid2symid = self.set_idmap(self.eda) + * self.precompute() + * self.sampler = sampler # <<<<<<<<<<<<<< + * self.scorer = scorer * */ - __pyx_v_med1 = __pyx_f_3_sa_median(__pyx_v_low1, __pyx_v_high1, __pyx_v_step1); + __Pyx_INCREF(((PyObject *)__pyx_v_sampler)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_sampler)); + __Pyx_GOTREF(__pyx_v_self->sampler); + __Pyx_DECREF(((PyObject *)__pyx_v_self->sampler)); + __pyx_v_self->sampler = __pyx_v_sampler; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":523 - * else: - * med1 = median(low1, high1, step1) - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":376 + * self.precompute() + * self.sampler = sampler + * self.scorer = scorer # <<<<<<<<<<<<<< * - * search_low = low2 + * cdef set_idmap(self, DataArray darray): */ - __pyx_f_3_sa_find_comparable_matchings(__pyx_v_low1, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_med1, (&__pyx_v_med1_minus), (&__pyx_v_med1_plus)); + __Pyx_INCREF(((PyObject *)__pyx_v_scorer)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_scorer)); + __Pyx_GOTREF(__pyx_v_self->scorer); + __Pyx_DECREF(((PyObject *)__pyx_v_self->scorer)); + __pyx_v_self->scorer = __pyx_v_scorer; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":525 - * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) - * - * search_low = low2 # <<<<<<<<<<<<<< - * search_high = high2 - * while search_low < search_high: - */ - __pyx_v_search_low = __pyx_v_low2; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.configure", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":526 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":378 + * self.scorer = scorer * - * search_low = low2 - * search_high = high2 # <<<<<<<<<<<<<< - * while search_low < search_high: - * med2 = median(search_low, search_high, step2) + * cdef set_idmap(self, DataArray darray): # <<<<<<<<<<<<<< + * cdef int word_id, new_word_id, N + * cdef IntList idmap */ - __pyx_v_search_high = __pyx_v_high2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":527 - * search_low = low2 - * search_high = high2 - * while search_low < search_high: # <<<<<<<<<<<<<< - * med2 = median(search_low, search_high, step2) - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) +static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_set_idmap(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_DataArray *__pyx_v_darray) { + int __pyx_v_word_id; + int __pyx_v_new_word_id; + int __pyx_v_N; + struct __pyx_obj_3_sa_IntList *__pyx_v_idmap = 0; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_t_7; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("set_idmap", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":382 + * cdef IntList idmap + * + * N = len(darray.id2word) # <<<<<<<<<<<<<< + * idmap = IntList(initial_len=N) + * for word_id from 0 <= word_id < N: */ - while (1) { - __pyx_t_3 = (__pyx_v_search_low < __pyx_v_search_high); - if (!__pyx_t_3) break; + __pyx_t_1 = __pyx_v_darray->id2word; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_N = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":528 - * search_high = high2 - * while search_low < search_high: - * med2 = median(search_low, search_high, step2) # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":383 + * + * N = len(darray.id2word) + * idmap = IntList(initial_len=N) # <<<<<<<<<<<<<< + * for word_id from 0 <= word_id < N: + * new_word_id = sym_fromstring(darray.id2word[word_id], True) */ - __pyx_v_med2 = __pyx_f_3_sa_median(__pyx_v_search_low, __pyx_v_search_high, __pyx_v_step2); + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_3 = PyInt_FromLong(__pyx_v_N); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_v_idmap = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":529 - * while search_low < search_high: - * med2 = median(search_low, search_high, step2) - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) - * if comparison == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":384 + * N = len(darray.id2word) + * idmap = IntList(initial_len=N) + * for word_id from 0 <= word_id < N: # <<<<<<<<<<<<<< + * new_word_id = sym_fromstring(darray.id2word[word_id], True) + * idmap.arr[word_id] = new_word_id */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_med2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_t_4 = __pyx_v_N; + for (__pyx_v_word_id = 0; __pyx_v_word_id < __pyx_t_4; __pyx_v_word_id++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":530 - * med2 = median(search_low, search_high, step2) - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< - * if comparison == -1: - * search_high = med2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":385 + * idmap = IntList(initial_len=N) + * for word_id from 0 <= word_id < N: + * new_word_id = sym_fromstring(darray.id2word[word_id], True) # <<<<<<<<<<<<<< + * idmap.arr[word_id] = new_word_id + * return idmap */ - __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings_set(__pyx_v_self, __pyx_v_med1_minus, __pyx_v_med1_plus, __pyx_v_arr1, __pyx_v_step1, (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_darray->id2word, __pyx_v_word_id, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_1 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_new_word_id = __pyx_t_7; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":533 - * if comparison == -1: - * search_high = med2 - * elif comparison == 1: # <<<<<<<<<<<<<< - * search_low = med2 + step2 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":386 + * for word_id from 0 <= word_id < N: + * new_word_id = sym_fromstring(darray.id2word[word_id], True) + * idmap.arr[word_id] = new_word_id # <<<<<<<<<<<<<< + * return idmap + * */ - switch (__pyx_v_comparison) { + (__pyx_v_idmap->arr[__pyx_v_word_id]) = __pyx_v_new_word_id; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":531 - * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) - * if comparison == -1: # <<<<<<<<<<<<<< - * search_high = med2 - * elif comparison == 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":387 + * new_word_id = sym_fromstring(darray.id2word[word_id], True) + * idmap.arr[word_id] = new_word_id + * return idmap # <<<<<<<<<<<<<< + * + * */ - case -1: + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_idmap)); + __pyx_r = ((PyObject *)__pyx_v_idmap); + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":532 - * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) - * if comparison == -1: - * search_high = med2 # <<<<<<<<<<<<<< - * elif comparison == 1: - * search_low = med2 + step2 + __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_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.set_idmap", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_idmap); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_5pattern2phrase(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_5pattern2phrase(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("pattern2phrase (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_4pattern2phrase(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_pattern)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":390 + * + * + * def pattern2phrase(self, pattern): # <<<<<<<<<<<<<< + * # pattern is a tuple, which we must convert to a hiero Phrase + * result = () */ - __pyx_v_search_high = __pyx_v_med2; - break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":533 - * if comparison == -1: - * search_high = med2 - * elif comparison == 1: # <<<<<<<<<<<<<< - * search_low = med2 + step2 - * else: +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_4pattern2phrase(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_pattern) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_arity = NULL; + PyObject *__pyx_v_word_id = NULL; + PyObject *__pyx_v_new_id = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("pattern2phrase", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":392 + * def pattern2phrase(self, pattern): + * # pattern is a tuple, which we must convert to a hiero Phrase + * result = () # <<<<<<<<<<<<<< + * arity = 0 + * for word_id in pattern: */ - case 1: + __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); + __pyx_v_result = __pyx_empty_tuple; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":534 - * search_high = med2 - * elif comparison == 1: - * search_low = med2 + step2 # <<<<<<<<<<<<<< - * else: - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":393 + * # pattern is a tuple, which we must convert to a hiero Phrase + * result = () + * arity = 0 # <<<<<<<<<<<<<< + * for word_id in pattern: + * if word_id == -1: */ - __pyx_v_search_low = (__pyx_v_med2 + __pyx_v_step2); - break; - default: + __Pyx_INCREF(__pyx_int_0); + __pyx_v_arity = __pyx_int_0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":536 - * search_low = med2 + step2 - * else: - * break # <<<<<<<<<<<<<< - * - * med_result_len = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":394 + * result = () + * arity = 0 + * for word_id in pattern: # <<<<<<<<<<<<<< + * if word_id == -1: + * arity = arity + 1 */ - goto __pyx_L13_break; + if (PyList_CheckExact(__pyx_v_pattern) || PyTuple_CheckExact(__pyx_v_pattern)) { + __pyx_t_1 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } break; } + __Pyx_GOTREF(__pyx_t_4); } - __pyx_L13_break:; - } - __pyx_L9:; + __Pyx_XDECREF(__pyx_v_word_id); + __pyx_v_word_id = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":538 - * break - * - * med_result_len = 0 # <<<<<<<<<<<<<< - * med_result = malloc(0*sizeof(int*)) - * if search_high > search_low: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":395 + * arity = 0 + * for word_id in pattern: + * if word_id == -1: # <<<<<<<<<<<<<< + * arity = arity + 1 + * new_id = sym_setindex(self.category, arity) */ - __pyx_v_med_result_len = 0; + __pyx_t_4 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 395; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":539 - * - * med_result_len = 0 - * med_result = malloc(0*sizeof(int*)) # <<<<<<<<<<<<<< - * if search_high > search_low: - * # Then there is a match for the median element of Q + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":396 + * for word_id in pattern: + * if word_id == -1: + * arity = arity + 1 # <<<<<<<<<<<<<< + * new_id = sym_setindex(self.category, arity) + * else: */ - __pyx_v_med_result = ((int *)malloc((0 * (sizeof(int *))))); + __pyx_t_4 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 396; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_v_arity); + __pyx_v_arity = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":540 - * med_result_len = 0 - * med_result = malloc(0*sizeof(int*)) - * if search_high > search_low: # <<<<<<<<<<<<<< - * # Then there is a match for the median element of Q - * # What we want to find is the group of all bindings in the first set + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":397 + * if word_id == -1: + * arity = arity + 1 + * new_id = sym_setindex(self.category, arity) # <<<<<<<<<<<<<< + * else: + * new_id = sym_fromstring(self.fda.id2word[word_id], True) */ - __pyx_t_3 = (__pyx_v_search_high > __pyx_v_search_low); - if (__pyx_t_3) { + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_arity); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_v_new_id); + __pyx_v_new_id = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L5; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":546 - * # want to store the bindings for all of those elements. We can - * # subsequently throw all of them away. - * med2_minus = med2 # <<<<<<<<<<<<<< - * med2_plus = med2 + step2 - * i1 = med1_minus + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":399 + * new_id = sym_setindex(self.category, arity) + * else: + * new_id = sym_fromstring(self.fda.id2word[word_id], True) # <<<<<<<<<<<<<< + * result = result + (new_id,) + * return Phrase(result) */ - __pyx_v_med2_minus = __pyx_v_med2; + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = PyObject_GetItem(__pyx_v_self->fda->id2word, __pyx_v_word_id); if (!__pyx_t_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_7 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_v_new_id); + __pyx_v_new_id = __pyx_t_8; + __pyx_t_8 = 0; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":547 - * # subsequently throw all of them away. - * med2_minus = med2 - * med2_plus = med2 + step2 # <<<<<<<<<<<<<< - * i1 = med1_minus - * while i1 < med1_plus: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":400 + * else: + * new_id = sym_fromstring(self.fda.id2word[word_id], True) + * result = result + (new_id,) # <<<<<<<<<<<<<< + * return Phrase(result) + * */ - __pyx_v_med2_plus = (__pyx_v_med2 + __pyx_v_step2); + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_new_id); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_new_id); + __Pyx_GIVEREF(__pyx_v_new_id); + __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_9)); + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_result)); + __pyx_v_result = __pyx_t_9; + __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":548 - * med2_minus = med2 - * med2_plus = med2 + step2 - * i1 = med1_minus # <<<<<<<<<<<<<< - * while i1 < med1_plus: - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":401 + * new_id = sym_fromstring(self.fda.id2word[word_id], True) + * result = result + (new_id,) + * return Phrase(result) # <<<<<<<<<<<<<< + * + * def pattern2phrase_plus(self, pattern): */ - __pyx_v_i1 = __pyx_v_med1_minus; + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_result)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_result)); + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_r = __pyx_t_9; + __pyx_t_9 = 0; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":549 - * med2_plus = med2 + step2 - * i1 = med1_minus - * while i1 < med1_plus: # <<<<<<<<<<<<<< - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * while med2_minus-step2 >= low2: - */ - while (1) { - __pyx_t_3 = (__pyx_v_i1 < __pyx_v_med1_plus); - if (!__pyx_t_3) break; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.pattern2phrase", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_arity); + __Pyx_XDECREF(__pyx_v_word_id); + __Pyx_XDECREF(__pyx_v_new_id); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":550 - * i1 = med1_minus - * while i1 < med1_plus: - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * while med2_minus-step2 >= low2: - * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) - */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_7pattern2phrase_plus(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_7pattern2phrase_plus(PyObject *__pyx_v_self, PyObject *__pyx_v_pattern) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("pattern2phrase_plus (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_6pattern2phrase_plus(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_pattern)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":551 - * while i1 < med1_plus: - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * while med2_minus-step2 >= low2: # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":403 + * return Phrase(result) + * + * def pattern2phrase_plus(self, pattern): # <<<<<<<<<<<<<< + * # returns a list containing both the pattern, and pattern + * # suffixed/prefixed with the NT category. */ - while (1) { - __pyx_t_3 = ((__pyx_v_med2_minus - __pyx_v_step2) >= __pyx_v_low2); - if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":552 - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * while med2_minus-step2 >= low2: - * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: - * med2_minus = med2_minus - step2 +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_6pattern2phrase_plus(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_pattern) { + PyObject *__pyx_v_patterns = NULL; + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_arity = NULL; + PyObject *__pyx_v_word_id = NULL; + PyObject *__pyx_v_new_id = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + PyObject *__pyx_t_9 = NULL; + int __pyx_t_10; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("pattern2phrase_plus", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":406 + * # returns a list containing both the pattern, and pattern + * # suffixed/prefixed with the NT category. + * patterns = [] # <<<<<<<<<<<<<< + * result = () + * arity = 0 */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, (__pyx_v_med2_minus - __pyx_v_step2), __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_patterns = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":553 - * while med2_minus-step2 >= low2: - * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: # <<<<<<<<<<<<<< - * med2_minus = med2_minus - step2 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":407 + * # suffixed/prefixed with the NT category. + * patterns = [] + * result = () # <<<<<<<<<<<<<< + * arity = 0 + * for word_id in pattern: */ - __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) < 1); - if (__pyx_t_3) { + __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); + __pyx_v_result = __pyx_empty_tuple; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":554 - * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: - * med2_minus = med2_minus - step2 # <<<<<<<<<<<<<< - * else: - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":408 + * patterns = [] + * result = () + * arity = 0 # <<<<<<<<<<<<<< + * for word_id in pattern: + * if word_id == -1: */ - __pyx_v_med2_minus = (__pyx_v_med2_minus - __pyx_v_step2); - goto __pyx_L19; - } - /*else*/ { + __Pyx_INCREF(__pyx_int_0); + __pyx_v_arity = __pyx_int_0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":556 - * med2_minus = med2_minus - step2 - * else: - * break # <<<<<<<<<<<<<< - * i2 = med2_minus - * while i2 < high2: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":409 + * result = () + * arity = 0 + * for word_id in pattern: # <<<<<<<<<<<<<< + * if word_id == -1: + * arity = arity + 1 */ - goto __pyx_L18_break; + if (PyList_CheckExact(__pyx_v_pattern) || PyTuple_CheckExact(__pyx_v_pattern)) { + __pyx_t_1 = __pyx_v_pattern; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_pattern); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L19:; + break; } - __pyx_L18_break:; + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_word_id); + __pyx_v_word_id = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":557 - * else: - * break - * i2 = med2_minus # <<<<<<<<<<<<<< - * while i2 < high2: - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":410 + * arity = 0 + * for word_id in pattern: + * if word_id == -1: # <<<<<<<<<<<<<< + * arity = arity + 1 + * new_id = sym_setindex(self.category, arity) */ - __pyx_v_i2 = __pyx_v_med2_minus; + __pyx_t_4 = PyObject_RichCompare(__pyx_v_word_id, __pyx_int_neg_1, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":558 - * break - * i2 = med2_minus - * while i2 < high2: # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":411 + * for word_id in pattern: + * if word_id == -1: + * arity = arity + 1 # <<<<<<<<<<<<<< + * new_id = sym_setindex(self.category, arity) + * else: */ - while (1) { - __pyx_t_3 = (__pyx_v_i2 < __pyx_v_high2); - if (!__pyx_t_3) break; + __pyx_t_4 = PyNumber_Add(__pyx_v_arity, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 411; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_v_arity); + __pyx_v_arity = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":559 - * i2 = med2_minus - * while i2 < high2: - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) - * if comparison == 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":412 + * if word_id == -1: + * arity = arity + 1 + * new_id = sym_setindex(self.category, arity) # <<<<<<<<<<<<<< + * else: + * new_id = sym_fromstring(self.fda.id2word[word_id], True) */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_i2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_v_arity); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_t_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_v_new_id); + __pyx_v_new_id = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L5; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":560 - * while i2 < high2: - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< - * if comparison == 0: - * pass + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":414 + * new_id = sym_setindex(self.category, arity) + * else: + * new_id = sym_fromstring(self.fda.id2word[word_id], True) # <<<<<<<<<<<<<< + * result = result + (new_id,) + * patterns.append(Phrase(result)) */ - __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_7 = PyObject_GetItem(__pyx_v_self->fda->id2word, __pyx_v_word_id); if (!__pyx_t_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_7 = 0; + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_v_new_id); + __pyx_v_new_id = __pyx_t_8; + __pyx_t_8 = 0; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":561 - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) - * if comparison == 0: # <<<<<<<<<<<<<< - * pass - * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":415 + * else: + * new_id = sym_fromstring(self.fda.id2word[word_id], True) + * result = result + (new_id,) # <<<<<<<<<<<<<< + * patterns.append(Phrase(result)) + * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) */ - __pyx_t_3 = (__pyx_v_comparison == 0); - if (__pyx_t_3) { + __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_new_id); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_new_id); + __Pyx_GIVEREF(__pyx_v_new_id); + __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_9)); + __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_result)); + __pyx_v_result = __pyx_t_9; + __pyx_t_9 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":563 - * if comparison == 0: - * pass - * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) # <<<<<<<<<<<<<< - * if comparison == -1: - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":416 + * new_id = sym_fromstring(self.fda.id2word[word_id], True) + * result = result + (new_id,) + * patterns.append(Phrase(result)) # <<<<<<<<<<<<<< + * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) + * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) */ - __pyx_v_med_result = __pyx_f_3_sa_append_combined_matching(__pyx_v_med_result, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_num_subpatterns, (&__pyx_v_med_result_len)); - goto __pyx_L22; - } - __pyx_L22:; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_result)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_result)); + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_10 = PyList_Append(__pyx_v_patterns, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":564 - * pass - * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) - * if comparison == -1: # <<<<<<<<<<<<<< - * break - * i2 = i2 + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":417 + * result = result + (new_id,) + * patterns.append(Phrase(result)) + * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) # <<<<<<<<<<<<<< + * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) + * return patterns */ - __pyx_t_3 = (__pyx_v_comparison == -1); - if (__pyx_t_3) { + __pyx_t_9 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, 1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_9)); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_10 = PyList_Append(__pyx_v_patterns, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":565 - * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) - * if comparison == -1: - * break # <<<<<<<<<<<<<< - * i2 = i2 + step2 - * if i2 > med2_plus: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":418 + * patterns.append(Phrase(result)) + * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) + * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) # <<<<<<<<<<<<<< + * return patterns + * */ - goto __pyx_L21_break; - goto __pyx_L23; - } - __pyx_L23:; + __pyx_t_9 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, 1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Add(((PyObject *)__pyx_t_1), ((PyObject *)__pyx_v_result)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_9)); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_10 = PyList_Append(__pyx_v_patterns, __pyx_t_9); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 418; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":566 - * if comparison == -1: - * break - * i2 = i2 + step2 # <<<<<<<<<<<<<< - * if i2 > med2_plus: - * med2_plus = i2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":419 + * patterns.append(Phrase(result + (sym_setindex(self.category, 1),))) + * patterns.append(Phrase((sym_setindex(self.category, 1),) + result)) + * return patterns # <<<<<<<<<<<<<< + * + * def precompute(self): */ - __pyx_v_i2 = (__pyx_v_i2 + __pyx_v_step2); - } - __pyx_L21_break:; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_patterns)); + __pyx_r = ((PyObject *)__pyx_v_patterns); + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":567 - * break - * i2 = i2 + step2 - * if i2 > med2_plus: # <<<<<<<<<<<<<< - * med2_plus = i2 - * i1 = i1 + step1 - */ - __pyx_t_3 = (__pyx_v_i2 > __pyx_v_med2_plus); - if (__pyx_t_3) { + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.pattern2phrase_plus", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_patterns); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_arity); + __Pyx_XDECREF(__pyx_v_word_id); + __Pyx_XDECREF(__pyx_v_new_id); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":568 - * i2 = i2 + step2 - * if i2 > med2_plus: - * med2_plus = i2 # <<<<<<<<<<<<<< - * i1 = i1 + step1 - * - */ - __pyx_v_med2_plus = __pyx_v_i2; - goto __pyx_L24; - } - __pyx_L24:; +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_9precompute(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_9precompute(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("precompute (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_8precompute(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":569 - * if i2 > med2_plus: - * med2_plus = i2 - * i1 = i1 + step1 # <<<<<<<<<<<<<< +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":421 + * return patterns + * + * def precompute(self): # <<<<<<<<<<<<<< + * cdef Precomputation pre * - * tmp = med1_minus */ - __pyx_v_i1 = (__pyx_v_i1 + __pyx_v_step1); - } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":571 - * i1 = i1 + step1 +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_8precompute(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self) { + struct __pyx_obj_3_sa_Precomputation *__pyx_v_pre = 0; + PyObject *__pyx_v_start_time = NULL; + PyObject *__pyx_v_pattern = NULL; + PyObject *__pyx_v_arr = NULL; + PyObject *__pyx_v_phrases = NULL; + PyObject *__pyx_v_phrase = NULL; + PyObject *__pyx_v_stop_time = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + Py_ssize_t __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + Py_ssize_t __pyx_t_10; + PyObject *(*__pyx_t_11)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("precompute", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":424 + * cdef Precomputation pre * - * tmp = med1_minus # <<<<<<<<<<<<<< - * med1_minus = med1_plus - * med1_plus = tmp + * if self.precompute_file is not None: # <<<<<<<<<<<<<< + * start_time = monitor_cpu() + * logger.info("Reading precomputed data from file %s... ", self.precompute_file) */ - __pyx_v_tmp = __pyx_v_med1_minus; + __pyx_t_1 = (__pyx_v_self->precompute_file != Py_None); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":572 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":425 * - * tmp = med1_minus - * med1_minus = med1_plus # <<<<<<<<<<<<<< - * med1_plus = tmp - * else: + * if self.precompute_file is not None: + * start_time = monitor_cpu() # <<<<<<<<<<<<<< + * logger.info("Reading precomputed data from file %s... ", self.precompute_file) + * pre = Precomputation(from_binary=self.precompute_file) */ - __pyx_v_med1_minus = __pyx_v_med1_plus; + __pyx_t_2 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_start_time = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":573 - * tmp = med1_minus - * med1_minus = med1_plus - * med1_plus = tmp # <<<<<<<<<<<<<< - * else: - * # No match; need to figure out the point of division in D and Q + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":426 + * if self.precompute_file is not None: + * start_time = monitor_cpu() + * logger.info("Reading precomputed data from file %s... ", self.precompute_file) # <<<<<<<<<<<<<< + * pre = Precomputation(from_binary=self.precompute_file) + * # check parameters of precomputation -- some are critical and some are not */ - __pyx_v_med1_plus = __pyx_v_tmp; - goto __pyx_L14; - } - /*else*/ { + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_110)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_110)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_110)); + __Pyx_INCREF(__pyx_v_self->precompute_file); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->precompute_file); + __Pyx_GIVEREF(__pyx_v_self->precompute_file); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 426; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":576 - * else: - * # No match; need to figure out the point of division in D and Q - * med2_minus = med2 # <<<<<<<<<<<<<< - * med2_plus = med2 - * if d_first: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":427 + * start_time = monitor_cpu() + * logger.info("Reading precomputed data from file %s... ", self.precompute_file) + * pre = Precomputation(from_binary=self.precompute_file) # <<<<<<<<<<<<<< + * # check parameters of precomputation -- some are critical and some are not + * if pre.max_nonterminals != self.max_nonterminals: */ - __pyx_v_med2_minus = __pyx_v_med2; + __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__from_binary), __pyx_v_self->precompute_file) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Precomputation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_v_pre = ((struct __pyx_obj_3_sa_Precomputation *)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":577 - * # No match; need to figure out the point of division in D and Q - * med2_minus = med2 - * med2_plus = med2 # <<<<<<<<<<<<<< - * if d_first: - * med2_minus = med2_minus + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":429 + * pre = Precomputation(from_binary=self.precompute_file) + * # check parameters of precomputation -- some are critical and some are not + * if pre.max_nonterminals != self.max_nonterminals: # <<<<<<<<<<<<<< + * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) + * if pre.max_length != self.max_length: */ - __pyx_v_med2_plus = __pyx_v_med2; + __pyx_t_1 = (__pyx_v_pre->max_nonterminals != __pyx_v_self->max_nonterminals); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":578 - * med2_minus = med2 - * med2_plus = med2 - * if d_first: # <<<<<<<<<<<<<< - * med2_minus = med2_minus + step2 - * if comparison == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":430 + * # check parameters of precomputation -- some are critical and some are not + * if pre.max_nonterminals != self.max_nonterminals: + * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) # <<<<<<<<<<<<<< + * if pre.max_length != self.max_length: + * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) */ - if (__pyx_v_d_first) { + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__warn); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong(__pyx_v_pre->max_nonterminals); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyInt_FromLong(__pyx_v_self->max_nonterminals); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_111)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_111)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_111)); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 430; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + goto __pyx_L4; + } + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":579 - * med2_plus = med2 - * if d_first: - * med2_minus = med2_minus + step2 # <<<<<<<<<<<<<< - * if comparison == -1: - * med1_minus = med1_plus + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":431 + * if pre.max_nonterminals != self.max_nonterminals: + * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) + * if pre.max_length != self.max_length: # <<<<<<<<<<<<<< + * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) + * if pre.train_max_initial_size != self.train_max_initial_size: */ - __pyx_v_med2_minus = (__pyx_v_med2_minus + __pyx_v_step2); + __pyx_t_1 = (__pyx_v_pre->max_length != __pyx_v_self->max_length); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":580 - * if d_first: - * med2_minus = med2_minus + step2 - * if comparison == -1: # <<<<<<<<<<<<<< - * med1_minus = med1_plus - * if comparison == 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":432 + * logger.warn("Precomputation done with max nonterminals %d, decoder uses %d", pre.max_nonterminals, self.max_nonterminals) + * if pre.max_length != self.max_length: + * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) # <<<<<<<<<<<<<< + * if pre.train_max_initial_size != self.train_max_initial_size: + * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) */ - __pyx_t_3 = (__pyx_v_comparison == -1); - if (__pyx_t_3) { + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__warn); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyInt_FromLong(__pyx_v_pre->max_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = PyInt_FromLong(__pyx_v_self->max_length); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_112)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_112)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_112)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_3 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + goto __pyx_L5; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":581 - * med2_minus = med2_minus + step2 - * if comparison == -1: - * med1_minus = med1_plus # <<<<<<<<<<<<<< - * if comparison == 1: - * med1_plus = med1_minus + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":433 + * if pre.max_length != self.max_length: + * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) + * if pre.train_max_initial_size != self.train_max_initial_size: # <<<<<<<<<<<<<< + * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) + * if pre.train_min_gap_size != self.train_min_gap_size: */ - __pyx_v_med1_minus = __pyx_v_med1_plus; - goto __pyx_L26; - } - __pyx_L26:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":582 - * if comparison == -1: - * med1_minus = med1_plus - * if comparison == 1: # <<<<<<<<<<<<<< - * med1_plus = med1_minus - * else: - */ - __pyx_t_3 = (__pyx_v_comparison == 1); - if (__pyx_t_3) { + __pyx_t_1 = (__pyx_v_pre->train_max_initial_size != __pyx_v_self->train_max_initial_size); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":583 - * med1_minus = med1_plus - * if comparison == 1: - * med1_plus = med1_minus # <<<<<<<<<<<<<< - * else: - * tmp = med1_minus + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":434 + * logger.warn("Precomputation done with max terminals %d, decoder uses %d", pre.max_length, self.max_length) + * if pre.train_max_initial_size != self.train_max_initial_size: + * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) # <<<<<<<<<<<<<< + * if pre.train_min_gap_size != self.train_min_gap_size: + * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) */ - __pyx_v_med1_plus = __pyx_v_med1_minus; - goto __pyx_L27; - } - __pyx_L27:; - goto __pyx_L25; + __pyx_t_4 = PyInt_FromLong(__pyx_v_pre->train_max_initial_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->train_max_initial_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_4 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_113), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_Raise(__pyx_t_2, 0, 0, 0); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L6; } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":585 - * med1_plus = med1_minus - * else: - * tmp = med1_minus # <<<<<<<<<<<<<< - * med1_minus = med1_plus - * med1_plus = tmp - */ - __pyx_v_tmp = __pyx_v_med1_minus; + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":586 - * else: - * tmp = med1_minus - * med1_minus = med1_plus # <<<<<<<<<<<<<< - * med1_plus = tmp - * if comparison == 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":435 + * if pre.train_max_initial_size != self.train_max_initial_size: + * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) + * if pre.train_min_gap_size != self.train_min_gap_size: # <<<<<<<<<<<<<< + * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) + * if self.use_index: */ - __pyx_v_med1_minus = __pyx_v_med1_plus; + __pyx_t_1 = (__pyx_v_pre->train_min_gap_size != __pyx_v_self->train_min_gap_size); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":587 - * tmp = med1_minus - * med1_minus = med1_plus - * med1_plus = tmp # <<<<<<<<<<<<<< - * if comparison == 1: - * med2_minus = med2_minus + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":436 + * raise Exception("Precomputation done with max initial size %d, decoder uses %d" % (pre.train_max_initial_size, self.train_max_initial_size)) + * if pre.train_min_gap_size != self.train_min_gap_size: + * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) # <<<<<<<<<<<<<< + * if self.use_index: + * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) */ - __pyx_v_med1_plus = __pyx_v_tmp; + __pyx_t_2 = PyInt_FromLong(__pyx_v_pre->train_min_gap_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_5 = PyInt_FromLong(__pyx_v_self->train_min_gap_size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_2 = 0; + __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_5, 0, 0, 0); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L7; + } + __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":588 - * med1_minus = med1_plus - * med1_plus = tmp - * if comparison == 1: # <<<<<<<<<<<<<< - * med2_minus = med2_minus + step2 - * med2_plus = med2_plus + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":437 + * if pre.train_min_gap_size != self.train_min_gap_size: + * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) + * if self.use_index: # <<<<<<<<<<<<<< + * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) + * for pattern, arr in pre.precomputed_index.iteritems(): */ - __pyx_t_3 = (__pyx_v_comparison == 1); - if (__pyx_t_3) { + if (__pyx_v_self->use_index) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":589 - * med1_plus = tmp - * if comparison == 1: - * med2_minus = med2_minus + step2 # <<<<<<<<<<<<<< - * med2_plus = med2_plus + step2 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":438 + * raise Exception("Precomputation done with min gap size %d, decoder uses %d" % (pre.train_min_gap_size, self.train_min_gap_size)) + * if self.use_index: + * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) # <<<<<<<<<<<<<< + * for pattern, arr in pre.precomputed_index.iteritems(): + * phrases = self.pattern2phrase_plus(pattern) */ - __pyx_v_med2_minus = (__pyx_v_med2_minus + __pyx_v_step2); + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__info); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __pyx_v_pre->precomputed_index; + __Pyx_INCREF(__pyx_t_5); + __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_115)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_115)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_115)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":590 - * if comparison == 1: - * med2_minus = med2_minus + step2 - * med2_plus = med2_plus + step2 # <<<<<<<<<<<<<< - * - * low_result_len = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":439 + * if self.use_index: + * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) + * for pattern, arr in pre.precomputed_index.iteritems(): # <<<<<<<<<<<<<< + * phrases = self.pattern2phrase_plus(pattern) + * for phrase in phrases: */ - __pyx_v_med2_plus = (__pyx_v_med2_plus + __pyx_v_step2); - goto __pyx_L28; + __pyx_t_6 = 0; + if (unlikely(__pyx_v_pre->precomputed_index == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L28:; - } - __pyx_L25:; - } - __pyx_L14:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":592 - * med2_plus = med2_plus + step2 - * - * low_result_len = 0 # <<<<<<<<<<<<<< - * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) - * high_result_len = 0 - */ - __pyx_v_low_result_len = 0; + __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_pre->precomputed_index, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_7), (&__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __pyx_t_5 = __pyx_t_2; + __pyx_t_2 = 0; + while (1) { + __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_7, &__pyx_t_6, &__pyx_t_2, &__pyx_t_4, NULL, __pyx_t_8); + if (unlikely(__pyx_t_9 == 0)) break; + if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_v_pattern); + __pyx_v_pattern = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_v_arr); + __pyx_v_arr = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":593 - * - * low_result_len = 0 - * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) # <<<<<<<<<<<<<< - * high_result_len = 0 - * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":440 + * logger.info("Converting %d hash keys on precomputed inverted index... ", len(pre.precomputed_index)) + * for pattern, arr in pre.precomputed_index.iteritems(): + * phrases = self.pattern2phrase_plus(pattern) # <<<<<<<<<<<<<< + * for phrase in phrases: + * self.precomputed_index[phrase] = arr */ - __pyx_v_low_result = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->baeza_yates_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_med1_plus, __pyx_v_arr1, __pyx_v_step1, __pyx_v_low2, __pyx_v_med2_plus, __pyx_v_arr2, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_low_result_len)); + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pattern2phrase_plus); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_pattern); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pattern); + __Pyx_GIVEREF(__pyx_v_pattern); + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_v_phrases); + __pyx_v_phrases = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":594 - * low_result_len = 0 - * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) - * high_result_len = 0 # <<<<<<<<<<<<<< - * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":441 + * for pattern, arr in pre.precomputed_index.iteritems(): + * phrases = self.pattern2phrase_plus(pattern) + * for phrase in phrases: # <<<<<<<<<<<<<< + * self.precomputed_index[phrase] = arr + * if self.use_collocations: */ - __pyx_v_high_result_len = 0; + if (PyList_CheckExact(__pyx_v_phrases) || PyTuple_CheckExact(__pyx_v_phrases)) { + __pyx_t_3 = __pyx_v_phrases; __Pyx_INCREF(__pyx_t_3); __pyx_t_10 = 0; + __pyx_t_11 = NULL; + } else { + __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_phrases); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_11 = Py_TYPE(__pyx_t_3)->tp_iternext; + } + for (;;) { + if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_3)) { + if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_3)) { + if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_2 = __pyx_t_11(__pyx_t_3); + if (unlikely(!__pyx_t_2)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_2); + } + __Pyx_XDECREF(__pyx_v_phrase); + __pyx_v_phrase = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":595 - * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) - * high_result_len = 0 - * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) # <<<<<<<<<<<<<< - * - * result = extend_arr(result, result_len, low_result, low_result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":442 + * phrases = self.pattern2phrase_plus(pattern) + * for phrase in phrases: + * self.precomputed_index[phrase] = arr # <<<<<<<<<<<<<< + * if self.use_collocations: + * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) */ - __pyx_v_high_result = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->baeza_yates_helper(__pyx_v_self, __pyx_v_med1_minus, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_med2_minus, __pyx_v_high2, __pyx_v_arr2, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_high_result_len)); + if (PyObject_SetItem(__pyx_v_self->precomputed_index, __pyx_v_phrase, __pyx_v_arr) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L8; + } + __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":597 - * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) - * - * result = extend_arr(result, result_len, low_result, low_result_len) # <<<<<<<<<<<<<< - * result = extend_arr(result, result_len, med_result, med_result_len) - * result = extend_arr(result, result_len, high_result, high_result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":443 + * for phrase in phrases: + * self.precomputed_index[phrase] = arr + * if self.use_collocations: # <<<<<<<<<<<<<< + * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) + * for pattern, arr in pre.precomputed_collocations.iteritems(): */ - __pyx_v_result = __pyx_f_3_sa_extend_arr(__pyx_v_result, __pyx_v_result_len, __pyx_v_low_result, __pyx_v_low_result_len); + if (__pyx_v_self->use_collocations) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":598 - * - * result = extend_arr(result, result_len, low_result, low_result_len) - * result = extend_arr(result, result_len, med_result, med_result_len) # <<<<<<<<<<<<<< - * result = extend_arr(result, result_len, high_result, high_result_len) - * free(low_result) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":444 + * self.precomputed_index[phrase] = arr + * if self.use_collocations: + * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) # <<<<<<<<<<<<<< + * for pattern, arr in pre.precomputed_collocations.iteritems(): + * phrase = self.pattern2phrase(pattern) */ - __pyx_v_result = __pyx_f_3_sa_extend_arr(__pyx_v_result, __pyx_v_result_len, __pyx_v_med_result, __pyx_v_med_result_len); + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__info); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __pyx_v_pre->precomputed_collocations; + __Pyx_INCREF(__pyx_t_5); + __pyx_t_7 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyInt_FromSsize_t(__pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_116)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_116)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_116)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 444; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":599 - * result = extend_arr(result, result_len, low_result, low_result_len) - * result = extend_arr(result, result_len, med_result, med_result_len) - * result = extend_arr(result, result_len, high_result, high_result_len) # <<<<<<<<<<<<<< - * free(low_result) - * free(med_result) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":445 + * if self.use_collocations: + * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) + * for pattern, arr in pre.precomputed_collocations.iteritems(): # <<<<<<<<<<<<<< + * phrase = self.pattern2phrase(pattern) + * self.precomputed_collocations[phrase] = arr */ - __pyx_v_result = __pyx_f_3_sa_extend_arr(__pyx_v_result, __pyx_v_result_len, __pyx_v_high_result, __pyx_v_high_result_len); + __pyx_t_7 = 0; + if (unlikely(__pyx_v_pre->precomputed_collocations == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_2 = __Pyx_dict_iterator(__pyx_v_pre->precomputed_collocations, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_6), (&__pyx_t_8)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __pyx_t_5 = __pyx_t_2; + __pyx_t_2 = 0; + while (1) { + __pyx_t_9 = __Pyx_dict_iter_next(__pyx_t_5, __pyx_t_6, &__pyx_t_7, &__pyx_t_2, &__pyx_t_3, NULL, __pyx_t_8); + if (unlikely(__pyx_t_9 == 0)) break; + if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_v_pattern); + __pyx_v_pattern = __pyx_t_2; + __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_v_arr); + __pyx_v_arr = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":600 - * result = extend_arr(result, result_len, med_result, med_result_len) - * result = extend_arr(result, result_len, high_result, high_result_len) - * free(low_result) # <<<<<<<<<<<<<< - * free(med_result) - * free(high_result) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":446 + * logger.info("Converting %d hash keys on precomputed collocations... ", len(pre.precomputed_collocations)) + * for pattern, arr in pre.precomputed_collocations.iteritems(): + * phrase = self.pattern2phrase(pattern) # <<<<<<<<<<<<<< + * self.precomputed_collocations[phrase] = arr + * stop_time = monitor_cpu() */ - free(__pyx_v_low_result); + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pattern2phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_v_pattern); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_pattern); + __Pyx_GIVEREF(__pyx_v_pattern); + __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_v_phrase); + __pyx_v_phrase = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":601 - * result = extend_arr(result, result_len, high_result, high_result_len) - * free(low_result) - * free(med_result) # <<<<<<<<<<<<<< - * free(high_result) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":447 + * for pattern, arr in pre.precomputed_collocations.iteritems(): + * phrase = self.pattern2phrase(pattern) + * self.precomputed_collocations[phrase] = arr # <<<<<<<<<<<<<< + * stop_time = monitor_cpu() + * logger.info("Processing precomputations took %f seconds", stop_time - start_time) */ - free(__pyx_v_med_result); + if (PyObject_SetItem(__pyx_v_self->precomputed_collocations, __pyx_v_phrase, __pyx_v_arr) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L13; + } + __pyx_L13:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":602 - * free(low_result) - * free(med_result) - * free(high_result) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":448 + * phrase = self.pattern2phrase(pattern) + * self.precomputed_collocations[phrase] = arr + * stop_time = monitor_cpu() # <<<<<<<<<<<<<< + * logger.info("Processing precomputations took %f seconds", stop_time - start_time) * - * return result */ - free(__pyx_v_high_result); + __pyx_t_5 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_v_stop_time = __pyx_t_5; + __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":604 - * free(high_result) - * - * return result # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":449 + * self.precomputed_collocations[phrase] = arr + * stop_time = monitor_cpu() + * logger.info("Processing precomputations took %f seconds", stop_time - start_time) # <<<<<<<<<<<<<< * * */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; + __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__info); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Subtract(__pyx_v_stop_time, __pyx_v_start_time); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_117)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_117)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_117)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L3; + } + __pyx_L3:; - __pyx_r = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_WriteUnraisable("_sa.HieroCachingRuleFactory.baeza_yates_helper", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.precompute", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_pre); + __Pyx_XDECREF(__pyx_v_start_time); + __Pyx_XDECREF(__pyx_v_pattern); + __Pyx_XDECREF(__pyx_v_arr); + __Pyx_XDECREF(__pyx_v_phrases); + __Pyx_XDECREF(__pyx_v_phrase); + __Pyx_XDECREF(__pyx_v_stop_time); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_11get_precomputed_collocation(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_11get_precomputed_collocation(PyObject *__pyx_v_self, PyObject *__pyx_v_phrase) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_precomputed_collocation (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_10get_precomputed_collocation(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_phrase)); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":608 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":452 * * - * cdef long compare_matchings_set(self, int i1_minus, int i1_plus, int* arr1, int step1, # <<<<<<<<<<<<<< - * Matching* loc2, int offset_by_one, int len_last): - * """ + * def get_precomputed_collocation(self, phrase): # <<<<<<<<<<<<<< + * if phrase in self.precomputed_collocations: + * arr = self.precomputed_collocations[phrase] */ -static long __pyx_f_3_sa_23HieroCachingRuleFactory_compare_matchings_set(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_i1_minus, int __pyx_v_i1_plus, int *__pyx_v_arr1, int __pyx_v_step1, struct __pyx_t_3_sa_Matching *__pyx_v_loc2, int __pyx_v_offset_by_one, int __pyx_v_len_last) { - int __pyx_v_i1; - int __pyx_v_comparison; - int __pyx_v_prev_comparison; - struct __pyx_t_3_sa_Matching __pyx_v_l1_stack; - struct __pyx_t_3_sa_Matching *__pyx_v_loc1; - long __pyx_r; +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_10get_precomputed_collocation(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_phrase) { + PyObject *__pyx_v_arr = NULL; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations int __pyx_t_1; - __Pyx_RefNannySetupContext("compare_matchings_set", 0); + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_precomputed_collocation", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":619 - * cdef Matching* loc1 - * - * loc1 = &l1_stack # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":453 * - * i1 = i1_minus + * def get_precomputed_collocation(self, phrase): + * if phrase in self.precomputed_collocations: # <<<<<<<<<<<<<< + * arr = self.precomputed_collocations[phrase] + * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) */ - __pyx_v_loc1 = (&__pyx_v_l1_stack); + __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->precomputed_collocations, __pyx_v_phrase))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":621 - * loc1 = &l1_stack - * - * i1 = i1_minus # <<<<<<<<<<<<<< - * while i1 < i1_plus: - * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":454 + * def get_precomputed_collocation(self, phrase): + * if phrase in self.precomputed_collocations: + * arr = self.precomputed_collocations[phrase] # <<<<<<<<<<<<<< + * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) + * return None */ - __pyx_v_i1 = __pyx_v_i1_minus; + __pyx_t_2 = PyObject_GetItem(__pyx_v_self->precomputed_collocations, __pyx_v_phrase); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_arr = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":622 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":455 + * if phrase in self.precomputed_collocations: + * arr = self.precomputed_collocations[phrase] + * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) # <<<<<<<<<<<<<< + * return None * - * i1 = i1_minus - * while i1 < i1_plus: # <<<<<<<<<<<<<< - * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) - * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) - */ - while (1) { - __pyx_t_1 = (__pyx_v_i1 < __pyx_v_i1_plus); - if (!__pyx_t_1) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":623 - * i1 = i1_minus - * while i1 < i1_plus: - * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) - * if comparison == 0: */ - __pyx_f_3_sa_assign_matching(__pyx_v_loc1, __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":624 - * while i1 < i1_plus: - * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) - * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< - * if comparison == 0: - * prev_comparison = 0 - */ - __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, __pyx_v_loc1, __pyx_v_loc2, __pyx_v_offset_by_one, __pyx_v_len_last); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":625 - * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) - * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) - * if comparison == 0: # <<<<<<<<<<<<<< - * prev_comparison = 0 - * break - */ - __pyx_t_1 = (__pyx_v_comparison == 0); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":626 - * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) - * if comparison == 0: - * prev_comparison = 0 # <<<<<<<<<<<<<< - * break - * elif i1 == i1_minus: - */ - __pyx_v_prev_comparison = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":627 - * if comparison == 0: - * prev_comparison = 0 - * break # <<<<<<<<<<<<<< - * elif i1 == i1_minus: - * prev_comparison = comparison - */ - goto __pyx_L4_break; - goto __pyx_L5; - } - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":628 - * prev_comparison = 0 - * break - * elif i1 == i1_minus: # <<<<<<<<<<<<<< - * prev_comparison = comparison - * else: - */ - __pyx_t_1 = (__pyx_v_i1 == __pyx_v_i1_minus); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":629 - * break - * elif i1 == i1_minus: - * prev_comparison = comparison # <<<<<<<<<<<<<< - * else: - * if comparison != prev_comparison: - */ - __pyx_v_prev_comparison = __pyx_v_comparison; - goto __pyx_L5; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":631 - * prev_comparison = comparison - * else: - * if comparison != prev_comparison: # <<<<<<<<<<<<<< - * prev_comparison = 0 - * break - */ - __pyx_t_1 = (__pyx_v_comparison != __pyx_v_prev_comparison); - if (__pyx_t_1) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":632 - * else: - * if comparison != prev_comparison: - * prev_comparison = 0 # <<<<<<<<<<<<<< - * break - * i1 = i1 + step1 - */ - __pyx_v_prev_comparison = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":633 - * if comparison != prev_comparison: - * prev_comparison = 0 - * break # <<<<<<<<<<<<<< - * i1 = i1 + step1 - * return prev_comparison - */ - goto __pyx_L4_break; - goto __pyx_L6; - } - __pyx_L6:; - } - __pyx_L5:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":634 - * prev_comparison = 0 - * break - * i1 = i1 + step1 # <<<<<<<<<<<<<< - * return prev_comparison - * - */ - __pyx_v_i1 = (__pyx_v_i1 + __pyx_v_step1); + __Pyx_XDECREF(__pyx_r); + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__arr), __pyx_v_arr) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__arr_low), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Length(__pyx_v_arr); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__arr_high), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_GetAttr(__pyx_v_phrase, __pyx_n_s__arity); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyNumber_Add(__pyx_t_5, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__num_subpatterns), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + goto __pyx_L3; } - __pyx_L4_break:; + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":635 - * break - * i1 = i1 + step1 - * return prev_comparison # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":456 + * arr = self.precomputed_collocations[phrase] + * return PhraseLocation(arr=arr, arr_low=0, arr_high=len(arr), num_subpatterns=phrase.arity()+1) + * return None # <<<<<<<<<<<<<< * * */ - __pyx_r = __pyx_v_prev_comparison; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; goto __pyx_L0; - __pyx_r = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_precomputed_collocation", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_arr); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":638 - * +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":459 * - * cdef long compare_matchings(self, Matching* loc1, Matching* loc2, int offset_by_one, int len_last): # <<<<<<<<<<<<<< - * cdef int i * + * cdef int* baeza_yates_helper(self, int low1, int high1, int* arr1, int step1, # <<<<<<<<<<<<<< + * int low2, int high2, int* arr2, int step2, + * int offset_by_one, int len_last, int num_subpatterns, int* result_len): */ -static long __pyx_f_3_sa_23HieroCachingRuleFactory_compare_matchings(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_t_3_sa_Matching *__pyx_v_loc1, struct __pyx_t_3_sa_Matching *__pyx_v_loc2, int __pyx_v_offset_by_one, int __pyx_v_len_last) { - int __pyx_v_i; - long __pyx_r; +static int *__pyx_f_3_sa_23HieroCachingRuleFactory_baeza_yates_helper(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_low1, int __pyx_v_high1, int *__pyx_v_arr1, int __pyx_v_step1, int __pyx_v_low2, int __pyx_v_high2, int *__pyx_v_arr2, int __pyx_v_step2, int __pyx_v_offset_by_one, int __pyx_v_len_last, int __pyx_v_num_subpatterns, int *__pyx_v_result_len) { + int __pyx_v_i1; + int __pyx_v_i2; + int __pyx_v_med1; + int __pyx_v_med2; + int __pyx_v_med1_plus; + int __pyx_v_med1_minus; + int __pyx_v_med2_minus; + int __pyx_v_med2_plus; + int __pyx_v_d_first; + int __pyx_v_qsetsize; + int __pyx_v_dsetsize; + int __pyx_v_tmp; + int __pyx_v_search_low; + int __pyx_v_search_high; + int __pyx_v_med_result_len; + int __pyx_v_low_result_len; + int __pyx_v_high_result_len; + long __pyx_v_comparison; + int *__pyx_v_result; + int *__pyx_v_low_result; + int *__pyx_v_med_result; + int *__pyx_v_high_result; + struct __pyx_t_3_sa_Matching __pyx_v_loc1; + struct __pyx_t_3_sa_Matching __pyx_v_loc2; + int *__pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; int __pyx_t_2; int __pyx_t_3; int __pyx_t_4; - __Pyx_RefNannySetupContext("compare_matchings", 0); + double __pyx_t_5; + double __pyx_t_6; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("baeza_yates_helper", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":641 - * cdef int i + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":472 + * cdef Matching loc1, loc2 * - * if loc1.sent_id > loc2.sent_id: # <<<<<<<<<<<<<< - * return 1 - * if loc2.sent_id > loc1.sent_id: + * result = malloc(0*sizeof(int*)) # <<<<<<<<<<<<<< + * + * d_first = 0 */ - __pyx_t_1 = (__pyx_v_loc1->sent_id > __pyx_v_loc2->sent_id); - if (__pyx_t_1) { + __pyx_v_result = ((int *)malloc((0 * (sizeof(int *))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":642 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":474 + * result = malloc(0*sizeof(int*)) * - * if loc1.sent_id > loc2.sent_id: - * return 1 # <<<<<<<<<<<<<< - * if loc2.sent_id > loc1.sent_id: - * return -1 + * d_first = 0 # <<<<<<<<<<<<<< + * if high1 - low1 > high2 - low2: + * d_first = 1 */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L3; - } - __pyx_L3:; + __pyx_v_d_first = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":643 - * if loc1.sent_id > loc2.sent_id: - * return 1 - * if loc2.sent_id > loc1.sent_id: # <<<<<<<<<<<<<< - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":475 + * + * d_first = 0 + * if high1 - low1 > high2 - low2: # <<<<<<<<<<<<<< + * d_first = 1 * */ - __pyx_t_1 = (__pyx_v_loc2->sent_id > __pyx_v_loc1->sent_id); + __pyx_t_1 = ((__pyx_v_high1 - __pyx_v_low1) > (__pyx_v_high2 - __pyx_v_low2)); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":644 - * return 1 - * if loc2.sent_id > loc1.sent_id: - * return -1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":476 + * d_first = 0 + * if high1 - low1 > high2 - low2: + * d_first = 1 # <<<<<<<<<<<<<< * - * if loc1.size == 1 and loc2.size == 1: + * # First, check to see if we are at any of the recursive base cases */ - __pyx_r = -1; - goto __pyx_L0; - goto __pyx_L4; + __pyx_v_d_first = 1; + goto __pyx_L3; } - __pyx_L4:; + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":646 - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":480 + * # First, check to see if we are at any of the recursive base cases + * # Case 1: one of the sets is empty + * if low1 >= high1 or low2 >= high2: # <<<<<<<<<<<<<< + * return result * - * if loc1.size == 1 and loc2.size == 1: # <<<<<<<<<<<<<< - * if loc2.arr[loc2.start] - loc1.arr[loc1.start] <= self.train_min_gap_size: - * return 1 */ - __pyx_t_1 = (__pyx_v_loc1->size == 1); - if (__pyx_t_1) { - __pyx_t_2 = (__pyx_v_loc2->size == 1); + __pyx_t_1 = (__pyx_v_low1 >= __pyx_v_high1); + if (!__pyx_t_1) { + __pyx_t_2 = (__pyx_v_low2 >= __pyx_v_high2); __pyx_t_3 = __pyx_t_2; } else { __pyx_t_3 = __pyx_t_1; } if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":647 - * - * if loc1.size == 1 and loc2.size == 1: - * if loc2.arr[loc2.start] - loc1.arr[loc1.start] <= self.train_min_gap_size: # <<<<<<<<<<<<<< - * return 1 - * - */ - __pyx_t_3 = (((__pyx_v_loc2->arr[__pyx_v_loc2->start]) - (__pyx_v_loc1->arr[__pyx_v_loc1->start])) <= __pyx_v_self->train_min_gap_size); - if (__pyx_t_3) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":648 - * if loc1.size == 1 and loc2.size == 1: - * if loc2.arr[loc2.start] - loc1.arr[loc1.start] <= self.train_min_gap_size: - * return 1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":481 + * # Case 1: one of the sets is empty + * if low1 >= high1 or low2 >= high2: + * return result # <<<<<<<<<<<<<< * - * elif offset_by_one: + * # Case 2: sets are non-overlapping */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L6; - } - __pyx_L6:; - goto __pyx_L5; + __pyx_r = __pyx_v_result; + goto __pyx_L0; + goto __pyx_L4; } + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":650 - * return 1 - * - * elif offset_by_one: # <<<<<<<<<<<<<< - * for i from 1 <= i < loc1.size: - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: - */ - if (__pyx_v_offset_by_one) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":651 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":484 * - * elif offset_by_one: - * for i from 1 <= i < loc1.size: # <<<<<<<<<<<<<< - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: - * return 1 - */ - __pyx_t_4 = __pyx_v_loc1->size; - for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_4; __pyx_v_i++) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":652 - * elif offset_by_one: - * for i from 1 <= i < loc1.size: - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: # <<<<<<<<<<<<<< - * return 1 - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: + * # Case 2: sets are non-overlapping + * assign_matching(&loc1, arr1, high1-step1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: */ - __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) > (__pyx_v_loc2->arr[((__pyx_v_loc2->start + __pyx_v_i) - 1)])); - if (__pyx_t_3) { + __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, (__pyx_v_high1 - __pyx_v_step1), __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":653 - * for i from 1 <= i < loc1.size: - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: - * return 1 # <<<<<<<<<<<<<< - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":485 + * # Case 2: sets are non-overlapping + * assign_matching(&loc1, arr1, high1-step1, step1, self.fda.sent_id.arr) + * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: + * return result */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L9; - } - __pyx_L9:; + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_low2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":654 - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: - * return 1 - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: # <<<<<<<<<<<<<< - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":486 + * assign_matching(&loc1, arr1, high1-step1, step1, self.fda.sent_id.arr) + * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: # <<<<<<<<<<<<<< + * return result * */ - __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) < (__pyx_v_loc2->arr[((__pyx_v_loc2->start + __pyx_v_i) - 1)])); - if (__pyx_t_3) { + __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) == -1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":655 - * return 1 - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: - * return -1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":487 + * assign_matching(&loc2, arr2, low2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == -1: + * return result # <<<<<<<<<<<<<< * - * else: + * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) */ - __pyx_r = -1; - goto __pyx_L0; - goto __pyx_L10; - } - __pyx_L10:; - } + __pyx_r = __pyx_v_result; + goto __pyx_L0; goto __pyx_L5; } - /*else*/ { + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":658 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":489 + * return result * - * else: - * if loc1.arr[loc1.start]+1 > loc2.arr[loc2.start]: # <<<<<<<<<<<<<< - * return 1 - * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: + * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: */ - __pyx_t_3 = (((__pyx_v_loc1->arr[__pyx_v_loc1->start]) + 1) > (__pyx_v_loc2->arr[__pyx_v_loc2->start])); - if (__pyx_t_3) { + __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_low1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":659 - * else: - * if loc1.arr[loc1.start]+1 > loc2.arr[loc2.start]: - * return 1 # <<<<<<<<<<<<<< - * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":490 + * + * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) + * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + * return result */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L11; - } - __pyx_L11:; + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, (__pyx_v_high2 - __pyx_v_step2), __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":660 - * if loc1.arr[loc1.start]+1 > loc2.arr[loc2.start]: - * return 1 - * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: # <<<<<<<<<<<<<< - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":491 + * assign_matching(&loc1, arr1, low1, step1, self.fda.sent_id.arr) + * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: # <<<<<<<<<<<<<< + * return result * */ - __pyx_t_3 = (((__pyx_v_loc1->arr[__pyx_v_loc1->start]) + 1) < (__pyx_v_loc2->arr[__pyx_v_loc2->start])); - if (__pyx_t_3) { + __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) == 1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":661 - * return 1 - * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: - * return -1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":492 + * assign_matching(&loc2, arr2, high2-step2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + * return result # <<<<<<<<<<<<<< * - * for i from 1 <= i < loc1.size: + * # Case 3: query set and data set do not meet size mismatch constraints; */ - __pyx_r = -1; - goto __pyx_L0; - goto __pyx_L12; - } - __pyx_L12:; + __pyx_r = __pyx_v_result; + goto __pyx_L0; + goto __pyx_L6; + } + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":663 - * return -1 - * - * for i from 1 <= i < loc1.size: # <<<<<<<<<<<<<< - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: - * return 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":496 + * # Case 3: query set and data set do not meet size mismatch constraints; + * # We use mergesort instead in this case + * qsetsize = (high1-low1) / step1 # <<<<<<<<<<<<<< + * dsetsize = (high2-low2) / step2 + * if d_first: */ - __pyx_t_4 = __pyx_v_loc1->size; - for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_4; __pyx_v_i++) { + __pyx_t_4 = (__pyx_v_high1 - __pyx_v_low1); + if (unlikely(__pyx_v_step1 == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_step1 == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_4))) { + PyErr_Format(PyExc_OverflowError, "value too large to perform division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_qsetsize = __Pyx_div_int(__pyx_t_4, __pyx_v_step1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":664 - * - * for i from 1 <= i < loc1.size: - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: # <<<<<<<<<<<<<< - * return 1 - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":497 + * # We use mergesort instead in this case + * qsetsize = (high1-low1) / step1 + * dsetsize = (high2-low2) / step2 # <<<<<<<<<<<<<< + * if d_first: + * tmp = qsetsize */ - __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) > (__pyx_v_loc2->arr[(__pyx_v_loc2->start + __pyx_v_i)])); - if (__pyx_t_3) { + __pyx_t_4 = (__pyx_v_high2 - __pyx_v_low2); + if (unlikely(__pyx_v_step2 == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + else if (sizeof(int) == sizeof(long) && unlikely(__pyx_v_step2 == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_t_4))) { + PyErr_Format(PyExc_OverflowError, "value too large to perform division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_dsetsize = __Pyx_div_int(__pyx_t_4, __pyx_v_step2); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":665 - * for i from 1 <= i < loc1.size: - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: - * return 1 # <<<<<<<<<<<<<< - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":498 + * qsetsize = (high1-low1) / step1 + * dsetsize = (high2-low2) / step2 + * if d_first: # <<<<<<<<<<<<<< + * tmp = qsetsize + * qsetsize = dsetsize */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L15; - } - __pyx_L15:; + if (__pyx_v_d_first) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":666 - * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: - * return 1 - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: # <<<<<<<<<<<<<< - * return -1 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":499 + * dsetsize = (high2-low2) / step2 + * if d_first: + * tmp = qsetsize # <<<<<<<<<<<<<< + * qsetsize = dsetsize + * dsetsize = tmp */ - __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) < (__pyx_v_loc2->arr[(__pyx_v_loc2->start + __pyx_v_i)])); - if (__pyx_t_3) { + __pyx_v_tmp = __pyx_v_qsetsize; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":667 - * return 1 - * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: - * return -1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":500 + * if d_first: + * tmp = qsetsize + * qsetsize = dsetsize # <<<<<<<<<<<<<< + * dsetsize = tmp * - * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: */ - __pyx_r = -1; - goto __pyx_L0; - goto __pyx_L16; - } - __pyx_L16:; - } - } - __pyx_L5:; + __pyx_v_qsetsize = __pyx_v_dsetsize; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":669 - * return -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":501 + * tmp = qsetsize + * qsetsize = dsetsize + * dsetsize = tmp # <<<<<<<<<<<<<< * - * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: # <<<<<<<<<<<<<< - * return -1 - * return 0 + * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: */ - __pyx_t_3 = ((((__pyx_v_loc2->arr[(__pyx_v_loc2->end - 1)]) + __pyx_v_len_last) - (__pyx_v_loc1->arr[__pyx_v_loc1->start])) > __pyx_v_self->train_max_initial_size); - if (__pyx_t_3) { + __pyx_v_dsetsize = __pyx_v_tmp; + goto __pyx_L7; + } + __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":670 - * - * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: - * return -1 # <<<<<<<<<<<<<< - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":503 + * dsetsize = tmp * + * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: # <<<<<<<<<<<<<< + * free(result) + * return self.merge_helper(low1, high1, arr1, step1, low2, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, result_len) */ - __pyx_r = -1; - goto __pyx_L0; - goto __pyx_L17; + __pyx_t_5 = ((__pyx_v_self->by_slack_factor * __pyx_v_qsetsize) * log(__pyx_v_dsetsize)); + __pyx_t_6 = log(2.0); + if (unlikely(__pyx_t_6 == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L17:; + __pyx_t_3 = ((__pyx_t_5 / __pyx_t_6) > __pyx_v_dsetsize); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":671 - * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: - * return -1 - * return 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":504 * + * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: + * free(result) # <<<<<<<<<<<<<< + * return self.merge_helper(low1, high1, arr1, step1, low2, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, result_len) * */ - __pyx_r = 0; - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + free(__pyx_v_result); -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":674 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":505 + * if self.by_slack_factor * qsetsize * log(dsetsize) / log(2) > dsetsize: + * free(result) + * return self.merge_helper(low1, high1, arr1, step1, low2, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, result_len) # <<<<<<<<<<<<<< * - * cdef int* merge_helper(self, int low1, int high1, int* arr1, int step1, # <<<<<<<<<<<<<< - * int low2, int high2, int* arr2, int step2, - * int offset_by_one, int len_last, int num_subpatterns, int* result_len): + * # binary search. There are two flavors, depending on */ + __pyx_r = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->merge_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_low2, __pyx_v_high2, __pyx_v_arr2, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, __pyx_v_result_len); + goto __pyx_L0; + goto __pyx_L8; + } + __pyx_L8:; -static int *__pyx_f_3_sa_23HieroCachingRuleFactory_merge_helper(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_low1, int __pyx_v_high1, int *__pyx_v_arr1, int __pyx_v_step1, int __pyx_v_low2, int __pyx_v_high2, int *__pyx_v_arr2, int __pyx_v_step2, int __pyx_v_offset_by_one, int __pyx_v_len_last, int __pyx_v_num_subpatterns, int *__pyx_v_result_len) { - int __pyx_v_i1; - int __pyx_v_i2; - int __pyx_v_j1; - int __pyx_v_j2; - long __pyx_v_comparison; - int *__pyx_v_result; - struct __pyx_t_3_sa_Matching __pyx_v_loc1; - struct __pyx_t_3_sa_Matching __pyx_v_loc2; - int *__pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - __Pyx_RefNannySetupContext("merge_helper", 0); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":509 + * # binary search. There are two flavors, depending on + * # whether the queryset or dataset is first + * if d_first: # <<<<<<<<<<<<<< + * med2 = median(low2, high2, step2) + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) + */ + if (__pyx_v_d_first) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":682 - * cdef Matching loc1, loc2 - * - * result_len[0] = 0 # <<<<<<<<<<<<<< - * result = malloc(0*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":510 + * # whether the queryset or dataset is first + * if d_first: + * med2 = median(low2, high2, step2) # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) * */ - (__pyx_v_result_len[0]) = 0; + __pyx_v_med2 = __pyx_f_3_sa_median(__pyx_v_low2, __pyx_v_high2, __pyx_v_step2); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":683 - * - * result_len[0] = 0 - * result = malloc(0*sizeof(int)) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":511 + * if d_first: + * med2 = median(low2, high2, step2) + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< * - * i1 = low1 + * search_low = low1 */ - __pyx_v_result = ((int *)malloc((0 * (sizeof(int))))); + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_med2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":685 - * result = malloc(0*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":513 + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) * - * i1 = low1 # <<<<<<<<<<<<<< - * i2 = low2 - * while i1 < high1 and i2 < high2: + * search_low = low1 # <<<<<<<<<<<<<< + * search_high = high1 + * while search_low < search_high: */ - __pyx_v_i1 = __pyx_v_low1; + __pyx_v_search_low = __pyx_v_low1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":686 - * - * i1 = low1 - * i2 = low2 # <<<<<<<<<<<<<< - * while i1 < high1 and i2 < high2: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":514 * + * search_low = low1 + * search_high = high1 # <<<<<<<<<<<<<< + * while search_low < search_high: + * med1 = median(search_low, search_high, step1) */ - __pyx_v_i2 = __pyx_v_low2; + __pyx_v_search_high = __pyx_v_high1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":687 - * i1 = low1 - * i2 = low2 - * while i1 < high1 and i2 < high2: # <<<<<<<<<<<<<< - * - * # First, pop all unneeded loc2's off the stack + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":515 + * search_low = low1 + * search_high = high1 + * while search_low < search_high: # <<<<<<<<<<<<<< + * med1 = median(search_low, search_high, step1) + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) */ - while (1) { - __pyx_t_1 = (__pyx_v_i1 < __pyx_v_high1); - if (__pyx_t_1) { - __pyx_t_2 = (__pyx_v_i2 < __pyx_v_high2); - __pyx_t_3 = __pyx_t_2; - } else { - __pyx_t_3 = __pyx_t_1; - } - if (!__pyx_t_3) break; + while (1) { + __pyx_t_3 = (__pyx_v_search_low < __pyx_v_search_high); + if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":690 - * - * # First, pop all unneeded loc2's off the stack - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * while i2 < high2: - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":516 + * search_high = high1 + * while search_low < search_high: + * med1 = median(search_low, search_high, step1) # <<<<<<<<<<<<<< + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); + __pyx_v_med1 = __pyx_f_3_sa_median(__pyx_v_search_low, __pyx_v_search_high, __pyx_v_step1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":691 - * # First, pop all unneeded loc2's off the stack - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * while i2 < high2: # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":517 + * while search_low < search_high: + * med1 = median(search_low, search_high, step1) + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) # <<<<<<<<<<<<<< + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + * if comparison == -1: */ - while (1) { - __pyx_t_3 = (__pyx_v_i2 < __pyx_v_high2); - if (!__pyx_t_3) break; + __pyx_f_3_sa_find_comparable_matchings(__pyx_v_low1, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_med1, (&__pyx_v_med1_minus), (&__pyx_v_med1_plus)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":692 - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * while i2 < high2: - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: - * i2 = i2 + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":518 + * med1 = median(search_low, search_high, step1) + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< + * if comparison == -1: + * search_low = med1_plus */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_i2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings_set(__pyx_v_self, __pyx_v_med1_minus, __pyx_v_med1_plus, __pyx_v_arr1, __pyx_v_step1, (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":693 - * while i2 < high2: - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: # <<<<<<<<<<<<<< - * i2 = i2 + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":521 + * if comparison == -1: + * search_low = med1_plus + * elif comparison == 1: # <<<<<<<<<<<<<< + * search_high = med1_minus * else: */ - __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) == 1); - if (__pyx_t_3) { + switch (__pyx_v_comparison) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":694 - * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) - * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: - * i2 = i2 + step2 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":519 + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + * if comparison == -1: # <<<<<<<<<<<<<< + * search_low = med1_plus + * elif comparison == 1: + */ + case -1: + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":520 + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + * if comparison == -1: + * search_low = med1_plus # <<<<<<<<<<<<<< + * elif comparison == 1: + * search_high = med1_minus + */ + __pyx_v_search_low = __pyx_v_med1_plus; + break; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":521 + * if comparison == -1: + * search_low = med1_plus + * elif comparison == 1: # <<<<<<<<<<<<<< + * search_high = med1_minus + * else: + */ + case 1: + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":522 + * search_low = med1_plus + * elif comparison == 1: + * search_high = med1_minus # <<<<<<<<<<<<<< * else: * break */ - __pyx_v_i2 = (__pyx_v_i2 + __pyx_v_step2); - goto __pyx_L7; - } - /*else*/ { + __pyx_v_search_high = __pyx_v_med1_minus; + break; + default: - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":696 - * i2 = i2 + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":524 + * search_high = med1_minus * else: * break # <<<<<<<<<<<<<< - * - * # Next: process all loc1's with the same starting val + * else: + * med1 = median(low1, high1, step1) */ - goto __pyx_L6_break; + goto __pyx_L11_break; + break; } - __pyx_L7:; } - __pyx_L6_break:; + __pyx_L11_break:; + goto __pyx_L9; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":699 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":526 + * break + * else: + * med1 = median(low1, high1, step1) # <<<<<<<<<<<<<< + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) * - * # Next: process all loc1's with the same starting val - * j1 = i1 # <<<<<<<<<<<<<< - * while i1 < high1 and arr1[j1] == arr1[i1]: - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) */ - __pyx_v_j1 = __pyx_v_i1; + __pyx_v_med1 = __pyx_f_3_sa_median(__pyx_v_low1, __pyx_v_high1, __pyx_v_step1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":700 - * # Next: process all loc1's with the same starting val - * j1 = i1 - * while i1 < high1 and arr1[j1] == arr1[i1]: # <<<<<<<<<<<<<< - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * j2 = i2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":527 + * else: + * med1 = median(low1, high1, step1) + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) # <<<<<<<<<<<<<< + * + * search_low = low2 */ - while (1) { - __pyx_t_3 = (__pyx_v_i1 < __pyx_v_high1); - if (__pyx_t_3) { - __pyx_t_1 = ((__pyx_v_arr1[__pyx_v_j1]) == (__pyx_v_arr1[__pyx_v_i1])); - __pyx_t_2 = __pyx_t_1; - } else { - __pyx_t_2 = __pyx_t_3; - } - if (!__pyx_t_2) break; + __pyx_f_3_sa_find_comparable_matchings(__pyx_v_low1, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_med1, (&__pyx_v_med1_minus), (&__pyx_v_med1_plus)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":701 - * j1 = i1 - * while i1 < high1 and arr1[j1] == arr1[i1]: - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * j2 = i2 - * while j2 < high2: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":529 + * find_comparable_matchings(low1, high1, arr1, step1, med1, &med1_minus, &med1_plus) + * + * search_low = low2 # <<<<<<<<<<<<<< + * search_high = high2 + * while search_low < search_high: */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); + __pyx_v_search_low = __pyx_v_low2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":702 - * while i1 < high1 and arr1[j1] == arr1[i1]: - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * j2 = i2 # <<<<<<<<<<<<<< - * while j2 < high2: - * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":530 + * + * search_low = low2 + * search_high = high2 # <<<<<<<<<<<<<< + * while search_low < search_high: + * med2 = median(search_low, search_high, step2) */ - __pyx_v_j2 = __pyx_v_i2; + __pyx_v_search_high = __pyx_v_high2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":703 - * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) - * j2 = i2 - * while j2 < high2: # <<<<<<<<<<<<<< - * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":531 + * search_low = low2 + * search_high = high2 + * while search_low < search_high: # <<<<<<<<<<<<<< + * med2 = median(search_low, search_high, step2) + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) */ - while (1) { - __pyx_t_2 = (__pyx_v_j2 < __pyx_v_high2); - if (!__pyx_t_2) break; + while (1) { + __pyx_t_3 = (__pyx_v_search_low < __pyx_v_search_high); + if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":704 - * j2 = i2 - * while j2 < high2: - * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) - * if comparison == 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":532 + * search_high = high2 + * while search_low < search_high: + * med2 = median(search_low, search_high, step2) # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) */ - __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_j2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + __pyx_v_med2 = __pyx_f_3_sa_median(__pyx_v_search_low, __pyx_v_search_high, __pyx_v_step2); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":705 - * while j2 < high2: - * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< - * if comparison == 0: - * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":533 + * while search_low < search_high: + * med2 = median(search_low, search_high, step2) + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + * if comparison == -1: */ - __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_med2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":706 - * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) - * if comparison == 0: # <<<<<<<<<<<<<< - * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) - * if comparison == 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":534 + * med2 = median(search_low, search_high, step2) + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< + * if comparison == -1: + * search_high = med2 */ - __pyx_t_2 = (__pyx_v_comparison == 0); - if (__pyx_t_2) { + __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings_set(__pyx_v_self, __pyx_v_med1_minus, __pyx_v_med1_plus, __pyx_v_arr1, __pyx_v_step1, (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":707 - * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) - * if comparison == 0: - * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) # <<<<<<<<<<<<<< - * if comparison == 1: - * pass + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":537 + * if comparison == -1: + * search_high = med2 + * elif comparison == 1: # <<<<<<<<<<<<<< + * search_low = med2 + step2 + * else: */ - __pyx_v_result = __pyx_f_3_sa_append_combined_matching(__pyx_v_result, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_num_subpatterns, __pyx_v_result_len); - goto __pyx_L12; - } - __pyx_L12:; + switch (__pyx_v_comparison) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":708 - * if comparison == 0: - * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) - * if comparison == 1: # <<<<<<<<<<<<<< - * pass - * if comparison == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":535 + * assign_matching(&loc2, arr2, med2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + * if comparison == -1: # <<<<<<<<<<<<<< + * search_high = med2 + * elif comparison == 1: */ - __pyx_t_2 = (__pyx_v_comparison == 1); - if (__pyx_t_2) { - goto __pyx_L13; - } - __pyx_L13:; + case -1: - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":710 - * if comparison == 1: - * pass - * if comparison == -1: # <<<<<<<<<<<<<< - * break - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":536 + * comparison = self.compare_matchings_set(med1_minus, med1_plus, arr1, step1, &loc2, offset_by_one, len_last) + * if comparison == -1: + * search_high = med2 # <<<<<<<<<<<<<< + * elif comparison == 1: + * search_low = med2 + step2 */ - __pyx_t_2 = (__pyx_v_comparison == -1); - if (__pyx_t_2) { + __pyx_v_search_high = __pyx_v_med2; + break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":711 - * pass - * if comparison == -1: - * break # <<<<<<<<<<<<<< - * else: - * j2 = j2 + step2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":537 + * if comparison == -1: + * search_high = med2 + * elif comparison == 1: # <<<<<<<<<<<<<< + * search_low = med2 + step2 + * else: */ - goto __pyx_L11_break; - goto __pyx_L14; - } - /*else*/ { + case 1: - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":713 - * break - * else: - * j2 = j2 + step2 # <<<<<<<<<<<<<< - * i1 = i1 + step1 - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":538 + * search_high = med2 + * elif comparison == 1: + * search_low = med2 + step2 # <<<<<<<<<<<<<< + * else: + * break */ - __pyx_v_j2 = (__pyx_v_j2 + __pyx_v_step2); - } - __pyx_L14:; - } - __pyx_L11_break:; + __pyx_v_search_low = (__pyx_v_med2 + __pyx_v_step2); + break; + default: - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":714 - * else: - * j2 = j2 + step2 - * i1 = i1 + step1 # <<<<<<<<<<<<<< - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":540 + * search_low = med2 + step2 + * else: + * break # <<<<<<<<<<<<<< * + * med_result_len = 0 */ - __pyx_v_i1 = (__pyx_v_i1 + __pyx_v_step1); + goto __pyx_L13_break; + break; + } } + __pyx_L13_break:; } + __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":715 - * j2 = j2 + step2 - * i1 = i1 + step1 - * return result # <<<<<<<<<<<<<< - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":542 + * break * + * med_result_len = 0 # <<<<<<<<<<<<<< + * med_result = malloc(0*sizeof(int*)) + * if search_high > search_low: */ - __pyx_r = __pyx_v_result; - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + __pyx_v_med_result_len = 0; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":718 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":543 * - * - * cdef void sort_phrase_loc(self, IntList arr, PhraseLocation loc, Phrase phrase): # <<<<<<<<<<<<<< - * cdef int i, j - * cdef VEB veb + * med_result_len = 0 + * med_result = malloc(0*sizeof(int*)) # <<<<<<<<<<<<<< + * if search_high > search_low: + * # Then there is a match for the median element of Q */ + __pyx_v_med_result = ((int *)malloc((0 * (sizeof(int *))))); -static void __pyx_f_3_sa_23HieroCachingRuleFactory_sort_phrase_loc(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_IntList *__pyx_v_arr, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_loc, struct __pyx_obj_3_sa_Phrase *__pyx_v_phrase) { - int __pyx_v_i; - int __pyx_v_j; - struct __pyx_obj_3_sa_VEB *__pyx_v_veb = 0; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("sort_phrase_loc", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":723 - * cdef IntList result - * - * if phrase in self.precomputed_index: # <<<<<<<<<<<<<< - * loc.arr = self.precomputed_index[phrase] - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":544 + * med_result_len = 0 + * med_result = malloc(0*sizeof(int*)) + * if search_high > search_low: # <<<<<<<<<<<<<< + * # Then there is a match for the median element of Q + * # What we want to find is the group of all bindings in the first set */ - __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->precomputed_index, ((PyObject *)__pyx_v_phrase)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_1) { + __pyx_t_3 = (__pyx_v_search_high > __pyx_v_search_low); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":724 - * - * if phrase in self.precomputed_index: - * loc.arr = self.precomputed_index[phrase] # <<<<<<<<<<<<<< - * else: - * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":550 + * # want to store the bindings for all of those elements. We can + * # subsequently throw all of them away. + * med2_minus = med2 # <<<<<<<<<<<<<< + * med2_plus = med2 + step2 + * i1 = med1_minus */ - __pyx_t_2 = PyObject_GetItem(__pyx_v_self->precomputed_index, ((PyObject *)__pyx_v_phrase)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 724; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_loc->arr); - __Pyx_DECREF(((PyObject *)__pyx_v_loc->arr)); - __pyx_v_loc->arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L3; - } - /*else*/ { + __pyx_v_med2_minus = __pyx_v_med2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":726 - * loc.arr = self.precomputed_index[phrase] - * else: - * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) # <<<<<<<<<<<<<< - * veb = VEB(arr.len) - * for i from loc.sa_low <= i < loc.sa_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":551 + * # subsequently throw all of them away. + * med2_minus = med2 + * med2_plus = med2 + step2 # <<<<<<<<<<<<<< + * i1 = med1_minus + * while i1 < med1_plus: */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyInt_FromLong((__pyx_v_loc->sa_high - __pyx_v_loc->sa_low)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 726; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(__pyx_v_loc->arr); - __Pyx_DECREF(((PyObject *)__pyx_v_loc->arr)); - __pyx_v_loc->arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_v_med2_plus = (__pyx_v_med2 + __pyx_v_step2); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":727 - * else: - * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) - * veb = VEB(arr.len) # <<<<<<<<<<<<<< - * for i from loc.sa_low <= i < loc.sa_high: - * veb._insert(arr.arr[i]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":552 + * med2_minus = med2 + * med2_plus = med2 + step2 + * i1 = med1_minus # <<<<<<<<<<<<<< + * while i1 < med1_plus: + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) */ - __pyx_t_3 = PyInt_FromLong(__pyx_v_arr->len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_VEB)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_v_veb = ((struct __pyx_obj_3_sa_VEB *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_v_i1 = __pyx_v_med1_minus; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":728 - * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) - * veb = VEB(arr.len) - * for i from loc.sa_low <= i < loc.sa_high: # <<<<<<<<<<<<<< - * veb._insert(arr.arr[i]) - * i = veb.veb.min_val + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":553 + * med2_plus = med2 + step2 + * i1 = med1_minus + * while i1 < med1_plus: # <<<<<<<<<<<<<< + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * while med2_minus-step2 >= low2: */ - __pyx_t_4 = __pyx_v_loc->sa_high; - for (__pyx_v_i = __pyx_v_loc->sa_low; __pyx_v_i < __pyx_t_4; __pyx_v_i++) { + while (1) { + __pyx_t_3 = (__pyx_v_i1 < __pyx_v_med1_plus); + if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":729 - * veb = VEB(arr.len) - * for i from loc.sa_low <= i < loc.sa_high: - * veb._insert(arr.arr[i]) # <<<<<<<<<<<<<< - * i = veb.veb.min_val - * for j from 0 <= j < loc.sa_high-loc.sa_low: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":554 + * i1 = med1_minus + * while i1 < med1_plus: + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * while med2_minus-step2 >= low2: + * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) */ - ((struct __pyx_vtabstruct_3_sa_VEB *)__pyx_v_veb->__pyx_vtab)->_insert(__pyx_v_veb, (__pyx_v_arr->arr[__pyx_v_i])); - } + __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":730 - * for i from loc.sa_low <= i < loc.sa_high: - * veb._insert(arr.arr[i]) - * i = veb.veb.min_val # <<<<<<<<<<<<<< - * for j from 0 <= j < loc.sa_high-loc.sa_low: - * loc.arr.arr[j] = i + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":555 + * while i1 < med1_plus: + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * while med2_minus-step2 >= low2: # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: */ - __pyx_v_i = __pyx_v_veb->veb->min_val; + while (1) { + __pyx_t_3 = ((__pyx_v_med2_minus - __pyx_v_step2) >= __pyx_v_low2); + if (!__pyx_t_3) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":731 - * veb._insert(arr.arr[i]) - * i = veb.veb.min_val - * for j from 0 <= j < loc.sa_high-loc.sa_low: # <<<<<<<<<<<<<< - * loc.arr.arr[j] = i - * i = veb._findsucc(i) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":556 + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * while med2_minus-step2 >= low2: + * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: + * med2_minus = med2_minus - step2 */ - __pyx_t_4 = (__pyx_v_loc->sa_high - __pyx_v_loc->sa_low); - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_4; __pyx_v_j++) { + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, (__pyx_v_med2_minus - __pyx_v_step2), __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":732 - * i = veb.veb.min_val - * for j from 0 <= j < loc.sa_high-loc.sa_low: - * loc.arr.arr[j] = i # <<<<<<<<<<<<<< - * i = veb._findsucc(i) - * loc.arr_low = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":557 + * while med2_minus-step2 >= low2: + * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: # <<<<<<<<<<<<<< + * med2_minus = med2_minus - step2 + * else: */ - (__pyx_v_loc->arr->arr[__pyx_v_j]) = __pyx_v_i; + __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) < 1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":733 - * for j from 0 <= j < loc.sa_high-loc.sa_low: - * loc.arr.arr[j] = i - * i = veb._findsucc(i) # <<<<<<<<<<<<<< - * loc.arr_low = 0 - * loc.arr_high = loc.arr.len + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":558 + * assign_matching(&loc2, arr2, med2_minus-step2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) < 1: + * med2_minus = med2_minus - step2 # <<<<<<<<<<<<<< + * else: + * break */ - __pyx_v_i = ((struct __pyx_vtabstruct_3_sa_VEB *)__pyx_v_veb->__pyx_vtab)->_findsucc(__pyx_v_veb, __pyx_v_i); - } - } - __pyx_L3:; + __pyx_v_med2_minus = (__pyx_v_med2_minus - __pyx_v_step2); + goto __pyx_L19; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":734 - * loc.arr.arr[j] = i - * i = veb._findsucc(i) - * loc.arr_low = 0 # <<<<<<<<<<<<<< - * loc.arr_high = loc.arr.len - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":560 + * med2_minus = med2_minus - step2 + * else: + * break # <<<<<<<<<<<<<< + * i2 = med2_minus + * while i2 < high2: */ - __pyx_v_loc->arr_low = 0; + goto __pyx_L18_break; + } + __pyx_L19:; + } + __pyx_L18_break:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":735 - * i = veb._findsucc(i) - * loc.arr_low = 0 - * loc.arr_high = loc.arr.len # <<<<<<<<<<<<<< - * - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":561 + * else: + * break + * i2 = med2_minus # <<<<<<<<<<<<<< + * while i2 < high2: + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) */ - __pyx_v_loc->arr_high = __pyx_v_loc->arr->len; - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("_sa.HieroCachingRuleFactory.sort_phrase_loc", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_veb); - __Pyx_RefNannyFinishContext(); -} + __pyx_v_i2 = __pyx_v_med2_minus; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":738 - * - * - * cdef intersect_helper(self, Phrase prefix, Phrase suffix, # <<<<<<<<<<<<<< - * PhraseLocation prefix_loc, PhraseLocation suffix_loc, int algorithm): - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":562 + * break + * i2 = med2_minus + * while i2 < high2: # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) */ + while (1) { + __pyx_t_3 = (__pyx_v_i2 < __pyx_v_high2); + if (!__pyx_t_3) break; -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_intersect_helper(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_prefix, struct __pyx_obj_3_sa_Phrase *__pyx_v_suffix, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_prefix_loc, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_suffix_loc, int __pyx_v_algorithm) { - struct __pyx_obj_3_sa_IntList *__pyx_v_arr1 = 0; - struct __pyx_obj_3_sa_IntList *__pyx_v_arr2 = 0; - struct __pyx_obj_3_sa_IntList *__pyx_v_result = 0; - int __pyx_v_low1; - int __pyx_v_high1; - int __pyx_v_step1; - int __pyx_v_low2; - int __pyx_v_high2; - int __pyx_v_step2; - int __pyx_v_offset_by_one; - int __pyx_v_len_last; - int __pyx_v_num_subpatterns; - int __pyx_v_result_len; - int *__pyx_v_result_ptr; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - int __pyx_t_7; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("intersect_helper", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":745 - * cdef int* result_ptr - * - * result_len = 0 # <<<<<<<<<<<<<< - * - * if sym_isvar(suffix[0]): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":563 + * i2 = med2_minus + * while i2 < high2: + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + * if comparison == 0: */ - __pyx_v_result_len = 0; + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_i2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":747 - * result_len = 0 - * - * if sym_isvar(suffix[0]): # <<<<<<<<<<<<<< - * offset_by_one = 1 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":564 + * while i2 < high2: + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< + * if comparison == 0: + * pass */ - __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_suffix), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = __pyx_f_3_sa_sym_isvar(__pyx_t_2); - if (__pyx_t_3) { + __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":748 - * - * if sym_isvar(suffix[0]): - * offset_by_one = 1 # <<<<<<<<<<<<<< - * else: - * offset_by_one = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":565 + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + * if comparison == 0: # <<<<<<<<<<<<<< + * pass + * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) */ - __pyx_v_offset_by_one = 1; - goto __pyx_L3; - } - /*else*/ { + __pyx_t_3 = (__pyx_v_comparison == 0); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":750 - * offset_by_one = 1 - * else: - * offset_by_one = 0 # <<<<<<<<<<<<<< - * - * len_last = len(suffix.getchunk(suffix.arity())) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":567 + * if comparison == 0: + * pass + * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) # <<<<<<<<<<<<<< + * if comparison == -1: + * break */ - __pyx_v_offset_by_one = 0; - } - __pyx_L3:; + __pyx_v_med_result = __pyx_f_3_sa_append_combined_matching(__pyx_v_med_result, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_num_subpatterns, (&__pyx_v_med_result_len)); + goto __pyx_L22; + } + __pyx_L22:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":752 - * offset_by_one = 0 - * - * len_last = len(suffix.getchunk(suffix.arity())) # <<<<<<<<<<<<<< - * - * if prefix_loc.arr is None: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":568 + * pass + * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) + * if comparison == -1: # <<<<<<<<<<<<<< + * break + * i2 = i2 + step2 */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_suffix), __pyx_n_s__getchunk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_suffix), __pyx_n_s__arity); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_len_last = __pyx_t_6; + __pyx_t_3 = (__pyx_v_comparison == -1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":754 - * len_last = len(suffix.getchunk(suffix.arity())) - * - * if prefix_loc.arr is None: # <<<<<<<<<<<<<< - * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) - * arr1 = prefix_loc.arr + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":569 + * med_result = append_combined_matching(med_result, &loc1, &loc2, offset_by_one, num_subpatterns, &med_result_len) + * if comparison == -1: + * break # <<<<<<<<<<<<<< + * i2 = i2 + step2 + * if i2 > med2_plus: */ - __pyx_t_7 = (((PyObject *)__pyx_v_prefix_loc->arr) == Py_None); - if (__pyx_t_7) { + goto __pyx_L21_break; + goto __pyx_L23; + } + __pyx_L23:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":755 - * - * if prefix_loc.arr is None: - * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) # <<<<<<<<<<<<<< - * arr1 = prefix_loc.arr - * low1 = prefix_loc.arr_low + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":570 + * if comparison == -1: + * break + * i2 = i2 + step2 # <<<<<<<<<<<<<< + * if i2 > med2_plus: + * med2_plus = i2 */ - __pyx_t_5 = ((PyObject *)__pyx_v_self->fsa->sa); - __Pyx_INCREF(__pyx_t_5); - ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->sort_phrase_loc(__pyx_v_self, ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5), __pyx_v_prefix_loc, __pyx_v_prefix); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L4; - } - __pyx_L4:; + __pyx_v_i2 = (__pyx_v_i2 + __pyx_v_step2); + } + __pyx_L21_break:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":756 - * if prefix_loc.arr is None: - * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) - * arr1 = prefix_loc.arr # <<<<<<<<<<<<<< - * low1 = prefix_loc.arr_low - * high1 = prefix_loc.arr_high + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":571 + * break + * i2 = i2 + step2 + * if i2 > med2_plus: # <<<<<<<<<<<<<< + * med2_plus = i2 + * i1 = i1 + step1 */ - __Pyx_INCREF(((PyObject *)__pyx_v_prefix_loc->arr)); - __pyx_v_arr1 = __pyx_v_prefix_loc->arr; + __pyx_t_3 = (__pyx_v_i2 > __pyx_v_med2_plus); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":757 - * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) - * arr1 = prefix_loc.arr - * low1 = prefix_loc.arr_low # <<<<<<<<<<<<<< - * high1 = prefix_loc.arr_high - * step1 = prefix_loc.num_subpatterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":572 + * i2 = i2 + step2 + * if i2 > med2_plus: + * med2_plus = i2 # <<<<<<<<<<<<<< + * i1 = i1 + step1 + * */ - __pyx_v_low1 = __pyx_v_prefix_loc->arr_low; + __pyx_v_med2_plus = __pyx_v_i2; + goto __pyx_L24; + } + __pyx_L24:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":758 - * arr1 = prefix_loc.arr - * low1 = prefix_loc.arr_low - * high1 = prefix_loc.arr_high # <<<<<<<<<<<<<< - * step1 = prefix_loc.num_subpatterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":573 + * if i2 > med2_plus: + * med2_plus = i2 + * i1 = i1 + step1 # <<<<<<<<<<<<<< * + * tmp = med1_minus */ - __pyx_v_high1 = __pyx_v_prefix_loc->arr_high; + __pyx_v_i1 = (__pyx_v_i1 + __pyx_v_step1); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":759 - * low1 = prefix_loc.arr_low - * high1 = prefix_loc.arr_high - * step1 = prefix_loc.num_subpatterns # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":575 + * i1 = i1 + step1 * - * if suffix_loc.arr is None: + * tmp = med1_minus # <<<<<<<<<<<<<< + * med1_minus = med1_plus + * med1_plus = tmp */ - __pyx_v_step1 = __pyx_v_prefix_loc->num_subpatterns; + __pyx_v_tmp = __pyx_v_med1_minus; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":761 - * step1 = prefix_loc.num_subpatterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":576 * - * if suffix_loc.arr is None: # <<<<<<<<<<<<<< - * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) - * arr2 = suffix_loc.arr + * tmp = med1_minus + * med1_minus = med1_plus # <<<<<<<<<<<<<< + * med1_plus = tmp + * else: */ - __pyx_t_7 = (((PyObject *)__pyx_v_suffix_loc->arr) == Py_None); - if (__pyx_t_7) { + __pyx_v_med1_minus = __pyx_v_med1_plus; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":762 - * - * if suffix_loc.arr is None: - * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) # <<<<<<<<<<<<<< - * arr2 = suffix_loc.arr - * low2 = suffix_loc.arr_low + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":577 + * tmp = med1_minus + * med1_minus = med1_plus + * med1_plus = tmp # <<<<<<<<<<<<<< + * else: + * # No match; need to figure out the point of division in D and Q */ - __pyx_t_5 = ((PyObject *)__pyx_v_self->fsa->sa); - __Pyx_INCREF(__pyx_t_5); - ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->sort_phrase_loc(__pyx_v_self, ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5), __pyx_v_suffix_loc, __pyx_v_suffix); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L5; + __pyx_v_med1_plus = __pyx_v_tmp; + goto __pyx_L14; } - __pyx_L5:; + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":763 - * if suffix_loc.arr is None: - * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) - * arr2 = suffix_loc.arr # <<<<<<<<<<<<<< - * low2 = suffix_loc.arr_low - * high2 = suffix_loc.arr_high + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":580 + * else: + * # No match; need to figure out the point of division in D and Q + * med2_minus = med2 # <<<<<<<<<<<<<< + * med2_plus = med2 + * if d_first: */ - __Pyx_INCREF(((PyObject *)__pyx_v_suffix_loc->arr)); - __pyx_v_arr2 = __pyx_v_suffix_loc->arr; + __pyx_v_med2_minus = __pyx_v_med2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":764 - * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) - * arr2 = suffix_loc.arr - * low2 = suffix_loc.arr_low # <<<<<<<<<<<<<< - * high2 = suffix_loc.arr_high - * step2 = suffix_loc.num_subpatterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":581 + * # No match; need to figure out the point of division in D and Q + * med2_minus = med2 + * med2_plus = med2 # <<<<<<<<<<<<<< + * if d_first: + * med2_minus = med2_minus + step2 */ - __pyx_v_low2 = __pyx_v_suffix_loc->arr_low; + __pyx_v_med2_plus = __pyx_v_med2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":765 - * arr2 = suffix_loc.arr - * low2 = suffix_loc.arr_low - * high2 = suffix_loc.arr_high # <<<<<<<<<<<<<< - * step2 = suffix_loc.num_subpatterns - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":582 + * med2_minus = med2 + * med2_plus = med2 + * if d_first: # <<<<<<<<<<<<<< + * med2_minus = med2_minus + step2 + * if comparison == -1: */ - __pyx_v_high2 = __pyx_v_suffix_loc->arr_high; + if (__pyx_v_d_first) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":766 - * low2 = suffix_loc.arr_low - * high2 = suffix_loc.arr_high - * step2 = suffix_loc.num_subpatterns # <<<<<<<<<<<<<< - * - * num_subpatterns = prefix.arity()+1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":583 + * med2_plus = med2 + * if d_first: + * med2_minus = med2_minus + step2 # <<<<<<<<<<<<<< + * if comparison == -1: + * med1_minus = med1_plus */ - __pyx_v_step2 = __pyx_v_suffix_loc->num_subpatterns; + __pyx_v_med2_minus = (__pyx_v_med2_minus + __pyx_v_step2); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":768 - * step2 = suffix_loc.num_subpatterns - * - * num_subpatterns = prefix.arity()+1 # <<<<<<<<<<<<<< - * - * if algorithm == MERGE: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":584 + * if d_first: + * med2_minus = med2_minus + step2 + * if comparison == -1: # <<<<<<<<<<<<<< + * med1_minus = med1_plus + * if comparison == 1: */ - __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_prefix), __pyx_n_s__arity); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_num_subpatterns = __pyx_t_3; + __pyx_t_3 = (__pyx_v_comparison == -1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":770 - * num_subpatterns = prefix.arity()+1 - * - * if algorithm == MERGE: # <<<<<<<<<<<<<< - * result_ptr = self.merge_helper(low1, high1, arr1.arr, step1, - * low2, high2, arr2.arr, step2, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":585 + * med2_minus = med2_minus + step2 + * if comparison == -1: + * med1_minus = med1_plus # <<<<<<<<<<<<<< + * if comparison == 1: + * med1_plus = med1_minus */ - __pyx_t_7 = (__pyx_v_algorithm == __pyx_v_3_sa_MERGE); - if (__pyx_t_7) { + __pyx_v_med1_minus = __pyx_v_med1_plus; + goto __pyx_L26; + } + __pyx_L26:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":773 - * result_ptr = self.merge_helper(low1, high1, arr1.arr, step1, - * low2, high2, arr2.arr, step2, - * offset_by_one, len_last, num_subpatterns, &result_len) # <<<<<<<<<<<<<< - * else: - * result_ptr = self.baeza_yates_helper(low1, high1, arr1.arr, step1, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":586 + * if comparison == -1: + * med1_minus = med1_plus + * if comparison == 1: # <<<<<<<<<<<<<< + * med1_plus = med1_minus + * else: */ - __pyx_v_result_ptr = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->merge_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_high1, __pyx_v_arr1->arr, __pyx_v_step1, __pyx_v_low2, __pyx_v_high2, __pyx_v_arr2->arr, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_result_len)); - goto __pyx_L6; - } - /*else*/ { + __pyx_t_3 = (__pyx_v_comparison == 1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":777 - * result_ptr = self.baeza_yates_helper(low1, high1, arr1.arr, step1, - * low2, high2, arr2.arr, step2, - * offset_by_one, len_last, num_subpatterns, &result_len) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":587 + * med1_minus = med1_plus + * if comparison == 1: + * med1_plus = med1_minus # <<<<<<<<<<<<<< + * else: + * tmp = med1_minus + */ + __pyx_v_med1_plus = __pyx_v_med1_minus; + goto __pyx_L27; + } + __pyx_L27:; + goto __pyx_L25; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":589 + * med1_plus = med1_minus + * else: + * tmp = med1_minus # <<<<<<<<<<<<<< + * med1_minus = med1_plus + * med1_plus = tmp + */ + __pyx_v_tmp = __pyx_v_med1_minus; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":590 + * else: + * tmp = med1_minus + * med1_minus = med1_plus # <<<<<<<<<<<<<< + * med1_plus = tmp + * if comparison == 1: + */ + __pyx_v_med1_minus = __pyx_v_med1_plus; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":591 + * tmp = med1_minus + * med1_minus = med1_plus + * med1_plus = tmp # <<<<<<<<<<<<<< + * if comparison == 1: + * med2_minus = med2_minus + step2 + */ + __pyx_v_med1_plus = __pyx_v_tmp; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":592 + * med1_minus = med1_plus + * med1_plus = tmp + * if comparison == 1: # <<<<<<<<<<<<<< + * med2_minus = med2_minus + step2 + * med2_plus = med2_plus + step2 + */ + __pyx_t_3 = (__pyx_v_comparison == 1); + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":593 + * med1_plus = tmp + * if comparison == 1: + * med2_minus = med2_minus + step2 # <<<<<<<<<<<<<< + * med2_plus = med2_plus + step2 * - * if result_len == 0: */ - __pyx_v_result_ptr = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->baeza_yates_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_high1, __pyx_v_arr1->arr, __pyx_v_step1, __pyx_v_low2, __pyx_v_high2, __pyx_v_arr2->arr, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_result_len)); + __pyx_v_med2_minus = (__pyx_v_med2_minus + __pyx_v_step2); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":594 + * if comparison == 1: + * med2_minus = med2_minus + step2 + * med2_plus = med2_plus + step2 # <<<<<<<<<<<<<< + * + * low_result_len = 0 + */ + __pyx_v_med2_plus = (__pyx_v_med2_plus + __pyx_v_step2); + goto __pyx_L28; + } + __pyx_L28:; + } + __pyx_L25:; } - __pyx_L6:; + __pyx_L14:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":779 - * offset_by_one, len_last, num_subpatterns, &result_len) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":596 + * med2_plus = med2_plus + step2 * - * if result_len == 0: # <<<<<<<<<<<<<< - * free(result_ptr) - * return None + * low_result_len = 0 # <<<<<<<<<<<<<< + * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) + * high_result_len = 0 */ - __pyx_t_7 = (__pyx_v_result_len == 0); - if (__pyx_t_7) { + __pyx_v_low_result_len = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":780 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":597 * - * if result_len == 0: - * free(result_ptr) # <<<<<<<<<<<<<< - * return None - * else: + * low_result_len = 0 + * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) # <<<<<<<<<<<<<< + * high_result_len = 0 + * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) */ - free(__pyx_v_result_ptr); + __pyx_v_low_result = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->baeza_yates_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_med1_plus, __pyx_v_arr1, __pyx_v_step1, __pyx_v_low2, __pyx_v_med2_plus, __pyx_v_arr2, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_low_result_len)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":781 - * if result_len == 0: - * free(result_ptr) - * return None # <<<<<<<<<<<<<< - * else: - * result = IntList() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":598 + * low_result_len = 0 + * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) + * high_result_len = 0 # <<<<<<<<<<<<<< + * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) + * */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; - goto __pyx_L7; - } - /*else*/ { + __pyx_v_high_result_len = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":783 - * return None - * else: - * result = IntList() # <<<<<<<<<<<<<< - * free(result.arr) - * result.arr = result_ptr + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":599 + * low_result = self.baeza_yates_helper(low1, med1_plus, arr1, step1, low2, med2_plus, arr2, step2, offset_by_one, len_last, num_subpatterns, &low_result_len) + * high_result_len = 0 + * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) # <<<<<<<<<<<<<< + * + * result = extend_arr(result, result_len, low_result, low_result_len) */ - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_v_result = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5); - __pyx_t_5 = 0; + __pyx_v_high_result = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->baeza_yates_helper(__pyx_v_self, __pyx_v_med1_minus, __pyx_v_high1, __pyx_v_arr1, __pyx_v_step1, __pyx_v_med2_minus, __pyx_v_high2, __pyx_v_arr2, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_high_result_len)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":784 - * else: - * result = IntList() - * free(result.arr) # <<<<<<<<<<<<<< - * result.arr = result_ptr - * result.len = result_len + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":601 + * high_result = self.baeza_yates_helper(med1_minus, high1, arr1, step1, med2_minus, high2, arr2, step2, offset_by_one, len_last, num_subpatterns, &high_result_len) + * + * result = extend_arr(result, result_len, low_result, low_result_len) # <<<<<<<<<<<<<< + * result = extend_arr(result, result_len, med_result, med_result_len) + * result = extend_arr(result, result_len, high_result, high_result_len) */ - free(__pyx_v_result->arr); + __pyx_v_result = __pyx_f_3_sa_extend_arr(__pyx_v_result, __pyx_v_result_len, __pyx_v_low_result, __pyx_v_low_result_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":785 - * result = IntList() - * free(result.arr) - * result.arr = result_ptr # <<<<<<<<<<<<<< - * result.len = result_len - * result.size = result_len + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":602 + * + * result = extend_arr(result, result_len, low_result, low_result_len) + * result = extend_arr(result, result_len, med_result, med_result_len) # <<<<<<<<<<<<<< + * result = extend_arr(result, result_len, high_result, high_result_len) + * free(low_result) */ - __pyx_v_result->arr = __pyx_v_result_ptr; + __pyx_v_result = __pyx_f_3_sa_extend_arr(__pyx_v_result, __pyx_v_result_len, __pyx_v_med_result, __pyx_v_med_result_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":786 - * free(result.arr) - * result.arr = result_ptr - * result.len = result_len # <<<<<<<<<<<<<< - * result.size = result_len - * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":603 + * result = extend_arr(result, result_len, low_result, low_result_len) + * result = extend_arr(result, result_len, med_result, med_result_len) + * result = extend_arr(result, result_len, high_result, high_result_len) # <<<<<<<<<<<<<< + * free(low_result) + * free(med_result) */ - __pyx_v_result->len = __pyx_v_result_len; + __pyx_v_result = __pyx_f_3_sa_extend_arr(__pyx_v_result, __pyx_v_result_len, __pyx_v_high_result, __pyx_v_high_result_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":787 - * result.arr = result_ptr - * result.len = result_len - * result.size = result_len # <<<<<<<<<<<<<< - * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":604 + * result = extend_arr(result, result_len, med_result, med_result_len) + * result = extend_arr(result, result_len, high_result, high_result_len) + * free(low_result) # <<<<<<<<<<<<<< + * free(med_result) + * free(high_result) + */ + free(__pyx_v_low_result); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":605 + * result = extend_arr(result, result_len, high_result, high_result_len) + * free(low_result) + * free(med_result) # <<<<<<<<<<<<<< + * free(high_result) * */ - __pyx_v_result->size = __pyx_v_result_len; + free(__pyx_v_med_result); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":788 - * result.len = result_len - * result.size = result_len - * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":606 + * free(low_result) + * free(med_result) + * free(high_result) # <<<<<<<<<<<<<< * - * cdef loc2str(self, PhraseLocation loc): + * return result */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__arr_low), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromLong(__pyx_v_result_len); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__arr_high), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__arr), ((PyObject *)__pyx_v_result)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = PyInt_FromLong(__pyx_v_num_subpatterns); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__num_subpatterns), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - } - __pyx_L7:; + free(__pyx_v_high_result); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":608 + * free(high_result) + * + * return result # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_result; + goto __pyx_L0; + + __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.intersect_helper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_WriteUnraisable("_sa.HieroCachingRuleFactory.baeza_yates_helper", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_arr1); - __Pyx_XDECREF((PyObject *)__pyx_v_arr2); - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":790 - * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":612 * - * cdef loc2str(self, PhraseLocation loc): # <<<<<<<<<<<<<< - * cdef int i, j - * result = "{" + * + * cdef long compare_matchings_set(self, int i1_minus, int i1_plus, int* arr1, int step1, # <<<<<<<<<<<<<< + * Matching* loc2, int offset_by_one, int len_last): + * """ */ -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_loc2str(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_loc) { - int __pyx_v_i; - int __pyx_v_j; - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_r = NULL; +static long __pyx_f_3_sa_23HieroCachingRuleFactory_compare_matchings_set(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_i1_minus, int __pyx_v_i1_plus, int *__pyx_v_arr1, int __pyx_v_step1, struct __pyx_t_3_sa_Matching *__pyx_v_loc2, int __pyx_v_offset_by_one, int __pyx_v_len_last) { + int __pyx_v_i1; + int __pyx_v_comparison; + int __pyx_v_prev_comparison; + struct __pyx_t_3_sa_Matching __pyx_v_l1_stack; + struct __pyx_t_3_sa_Matching *__pyx_v_loc1; + long __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("loc2str", 0); + __Pyx_RefNannySetupContext("compare_matchings_set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":792 - * cdef loc2str(self, PhraseLocation loc): - * cdef int i, j - * result = "{" # <<<<<<<<<<<<<< - * i = 0 - * while i < loc.arr_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":623 + * cdef Matching* loc1 + * + * loc1 = &l1_stack # <<<<<<<<<<<<<< + * + * i1 = i1_minus */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_116)); - __pyx_v_result = ((PyObject *)__pyx_kp_s_116); + __pyx_v_loc1 = (&__pyx_v_l1_stack); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":793 - * cdef int i, j - * result = "{" - * i = 0 # <<<<<<<<<<<<<< - * while i < loc.arr_high: - * result = result + "(" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":625 + * loc1 = &l1_stack + * + * i1 = i1_minus # <<<<<<<<<<<<<< + * while i1 < i1_plus: + * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) */ - __pyx_v_i = 0; + __pyx_v_i1 = __pyx_v_i1_minus; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":794 - * result = "{" - * i = 0 - * while i < loc.arr_high: # <<<<<<<<<<<<<< - * result = result + "(" - * for j from i <= j < i + loc.num_subpatterns: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":626 + * + * i1 = i1_minus + * while i1 < i1_plus: # <<<<<<<<<<<<<< + * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) + * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) */ while (1) { - __pyx_t_1 = (__pyx_v_i < __pyx_v_loc->arr_high); + __pyx_t_1 = (__pyx_v_i1 < __pyx_v_i1_plus); if (!__pyx_t_1) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":795 - * i = 0 - * while i < loc.arr_high: - * result = result + "(" # <<<<<<<<<<<<<< - * for j from i <= j < i + loc.num_subpatterns: - * result = result + ("%d " %loc.arr[j]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":627 + * i1 = i1_minus + * while i1 < i1_plus: + * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) + * if comparison == 0: */ - __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_kp_s_117)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_f_3_sa_assign_matching(__pyx_v_loc1, __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":796 - * while i < loc.arr_high: - * result = result + "(" - * for j from i <= j < i + loc.num_subpatterns: # <<<<<<<<<<<<<< - * result = result + ("%d " %loc.arr[j]) - * result = result + ")" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":628 + * while i1 < i1_plus: + * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) + * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< + * if comparison == 0: + * prev_comparison = 0 */ - __pyx_t_3 = (__pyx_v_i + __pyx_v_loc->num_subpatterns); - for (__pyx_v_j = __pyx_v_i; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { + __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, __pyx_v_loc1, __pyx_v_loc2, __pyx_v_offset_by_one, __pyx_v_len_last); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":797 - * result = result + "(" - * for j from i <= j < i + loc.num_subpatterns: - * result = result + ("%d " %loc.arr[j]) # <<<<<<<<<<<<<< - * result = result + ")" - * i = i + loc.num_subpatterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":629 + * assign_matching(loc1, arr1, i1, step1, self.fda.sent_id.arr) + * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) + * if comparison == 0: # <<<<<<<<<<<<<< + * prev_comparison = 0 + * break */ - __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_loc->arr), __pyx_v_j, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = (__pyx_v_comparison == 0); + if (__pyx_t_1) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":630 + * comparison = self.compare_matchings(loc1, loc2, offset_by_one, len_last) + * if comparison == 0: + * prev_comparison = 0 # <<<<<<<<<<<<<< + * break + * elif i1 == i1_minus: + */ + __pyx_v_prev_comparison = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":631 + * if comparison == 0: + * prev_comparison = 0 + * break # <<<<<<<<<<<<<< + * elif i1 == i1_minus: + * prev_comparison = comparison + */ + goto __pyx_L4_break; + goto __pyx_L5; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":798 - * for j from i <= j < i + loc.num_subpatterns: - * result = result + ("%d " %loc.arr[j]) - * result = result + ")" # <<<<<<<<<<<<<< - * i = i + loc.num_subpatterns - * result = result + "}" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":632 + * prev_comparison = 0 + * break + * elif i1 == i1_minus: # <<<<<<<<<<<<<< + * prev_comparison = comparison + * else: */ - __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_kp_s_59)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = (__pyx_v_i1 == __pyx_v_i1_minus); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":799 - * result = result + ("%d " %loc.arr[j]) - * result = result + ")" - * i = i + loc.num_subpatterns # <<<<<<<<<<<<<< - * result = result + "}" - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":633 + * break + * elif i1 == i1_minus: + * prev_comparison = comparison # <<<<<<<<<<<<<< + * else: + * if comparison != prev_comparison: */ - __pyx_v_i = (__pyx_v_i + __pyx_v_loc->num_subpatterns); - } + __pyx_v_prev_comparison = __pyx_v_comparison; + goto __pyx_L5; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":800 - * result = result + ")" - * i = i + loc.num_subpatterns - * result = result + "}" # <<<<<<<<<<<<<< - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":635 + * prev_comparison = comparison + * else: + * if comparison != prev_comparison: # <<<<<<<<<<<<<< + * prev_comparison = 0 + * break + */ + __pyx_t_1 = (__pyx_v_comparison != __pyx_v_prev_comparison); + if (__pyx_t_1) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":636 + * else: + * if comparison != prev_comparison: + * prev_comparison = 0 # <<<<<<<<<<<<<< + * break + * i1 = i1 + step1 + */ + __pyx_v_prev_comparison = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":637 + * if comparison != prev_comparison: + * prev_comparison = 0 + * break # <<<<<<<<<<<<<< + * i1 = i1 + step1 + * return prev_comparison + */ + goto __pyx_L4_break; + goto __pyx_L6; + } + __pyx_L6:; + } + __pyx_L5:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":638 + * prev_comparison = 0 + * break + * i1 = i1 + step1 # <<<<<<<<<<<<<< + * return prev_comparison * */ - __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_kp_s_118)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_v_result); - __pyx_v_result = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_i1 = (__pyx_v_i1 + __pyx_v_step1); + } + __pyx_L4_break:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":801 - * i = i + loc.num_subpatterns - * result = result + "}" - * return result # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":639 + * break + * i1 = i1 + step1 + * return prev_comparison # <<<<<<<<<<<<<< + * * - * cdef PhraseLocation intersect(self, prefix_node, suffix_node, Phrase phrase): */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_result); - __pyx_r = __pyx_v_result; + __pyx_r = __pyx_v_prev_comparison; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.loc2str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":803 - * return result +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":642 + * + * + * cdef long compare_matchings(self, Matching* loc1, Matching* loc2, int offset_by_one, int len_last): # <<<<<<<<<<<<<< + * cdef int i * - * cdef PhraseLocation intersect(self, prefix_node, suffix_node, Phrase phrase): # <<<<<<<<<<<<<< - * cdef Phrase prefix, suffix - * cdef PhraseLocation prefix_loc, suffix_loc, result */ -static struct __pyx_obj_3_sa_PhraseLocation *__pyx_f_3_sa_23HieroCachingRuleFactory_intersect(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_prefix_node, PyObject *__pyx_v_suffix_node, struct __pyx_obj_3_sa_Phrase *__pyx_v_phrase) { - struct __pyx_obj_3_sa_Phrase *__pyx_v_prefix = 0; - struct __pyx_obj_3_sa_Phrase *__pyx_v_suffix = 0; - struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_prefix_loc = 0; - struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_suffix_loc = 0; - struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_result = 0; - CYTHON_UNUSED PyObject *__pyx_v_intersect_method = NULL; - struct __pyx_obj_3_sa_PhraseLocation *__pyx_r = NULL; +static long __pyx_f_3_sa_23HieroCachingRuleFactory_compare_matchings(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_t_3_sa_Matching *__pyx_v_loc1, struct __pyx_t_3_sa_Matching *__pyx_v_loc2, int __pyx_v_offset_by_one, int __pyx_v_len_last) { + int __pyx_v_i; + long __pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; + int __pyx_t_1; + 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("intersect", 0); + __Pyx_RefNannySetupContext("compare_matchings", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":807 - * cdef PhraseLocation prefix_loc, suffix_loc, result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":645 + * cdef int i * - * prefix = prefix_node.phrase # <<<<<<<<<<<<<< - * suffix = suffix_node.phrase - * prefix_loc = prefix_node.phrase_location + * if loc1.sent_id > loc2.sent_id: # <<<<<<<<<<<<<< + * return 1 + * if loc2.sent_id > loc1.sent_id: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_prefix_node, __pyx_n_s__phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_Phrase))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_prefix = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_1 = (__pyx_v_loc1->sent_id > __pyx_v_loc2->sent_id); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":808 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":646 * - * prefix = prefix_node.phrase - * suffix = suffix_node.phrase # <<<<<<<<<<<<<< - * prefix_loc = prefix_node.phrase_location - * suffix_loc = suffix_node.phrase_location + * if loc1.sent_id > loc2.sent_id: + * return 1 # <<<<<<<<<<<<<< + * if loc2.sent_id > loc1.sent_id: + * return -1 */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_suffix_node, __pyx_n_s__phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_Phrase))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_suffix = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":809 - * prefix = prefix_node.phrase - * suffix = suffix_node.phrase - * prefix_loc = prefix_node.phrase_location # <<<<<<<<<<<<<< - * suffix_loc = suffix_node.phrase_location + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":647 + * if loc1.sent_id > loc2.sent_id: + * return 1 + * if loc2.sent_id > loc1.sent_id: # <<<<<<<<<<<<<< + * return -1 * */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_prefix_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_prefix_loc = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_1 = (__pyx_v_loc2->sent_id > __pyx_v_loc1->sent_id); + if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":810 - * suffix = suffix_node.phrase - * prefix_loc = prefix_node.phrase_location - * suffix_loc = suffix_node.phrase_location # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":648 + * return 1 + * if loc2.sent_id > loc1.sent_id: + * return -1 # <<<<<<<<<<<<<< * - * result = self.get_precomputed_collocation(phrase) + * if loc1.size == 1 and loc2.size == 1: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_suffix_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 810; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_suffix_loc = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L4; + } + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":812 - * suffix_loc = suffix_node.phrase_location + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":650 + * return -1 * - * result = self.get_precomputed_collocation(phrase) # <<<<<<<<<<<<<< - * if result is not None: - * intersect_method = "precomputed" + * if loc1.size == 1 and loc2.size == 1: # <<<<<<<<<<<<<< + * if loc2.arr[loc2.start] - loc1.arr[loc1.start] <= self.train_min_gap_size: + * return 1 */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_119); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_phrase)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_phrase)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_phrase)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_result = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_1 = (__pyx_v_loc1->size == 1); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_loc2->size == 1); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; + } + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":813 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":651 * - * result = self.get_precomputed_collocation(phrase) - * if result is not None: # <<<<<<<<<<<<<< - * intersect_method = "precomputed" + * if loc1.size == 1 and loc2.size == 1: + * if loc2.arr[loc2.start] - loc1.arr[loc1.start] <= self.train_min_gap_size: # <<<<<<<<<<<<<< + * return 1 * */ - __pyx_t_4 = (((PyObject *)__pyx_v_result) != Py_None); - if (__pyx_t_4) { + __pyx_t_3 = (((__pyx_v_loc2->arr[__pyx_v_loc2->start]) - (__pyx_v_loc1->arr[__pyx_v_loc1->start])) <= __pyx_v_self->train_min_gap_size); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":814 - * result = self.get_precomputed_collocation(phrase) - * if result is not None: - * intersect_method = "precomputed" # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":652 + * if loc1.size == 1 and loc2.size == 1: + * if loc2.arr[loc2.start] - loc1.arr[loc1.start] <= self.train_min_gap_size: + * return 1 # <<<<<<<<<<<<<< * - * if result is None: + * elif offset_by_one: */ - __Pyx_INCREF(((PyObject *)__pyx_n_s__precomputed)); - __pyx_v_intersect_method = ((PyObject *)__pyx_n_s__precomputed); - goto __pyx_L3; + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L6; + } + __pyx_L6:; + goto __pyx_L5; } - __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":816 - * intersect_method = "precomputed" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":654 + * return 1 * - * if result is None: # <<<<<<<<<<<<<< - * if self.use_baeza_yates: - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, BAEZA_YATES) + * elif offset_by_one: # <<<<<<<<<<<<<< + * for i from 1 <= i < loc1.size: + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: */ - __pyx_t_4 = (((PyObject *)__pyx_v_result) == Py_None); - if (__pyx_t_4) { + if (__pyx_v_offset_by_one) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":817 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":655 * - * if result is None: - * if self.use_baeza_yates: # <<<<<<<<<<<<<< - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, BAEZA_YATES) - * intersect_method="double binary" + * elif offset_by_one: + * for i from 1 <= i < loc1.size: # <<<<<<<<<<<<<< + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: + * return 1 */ - if (__pyx_v_self->use_baeza_yates) { + __pyx_t_4 = __pyx_v_loc1->size; + for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_4; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":818 - * if result is None: - * if self.use_baeza_yates: - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, BAEZA_YATES) # <<<<<<<<<<<<<< - * intersect_method="double binary" - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":656 + * elif offset_by_one: + * for i from 1 <= i < loc1.size: + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: # <<<<<<<<<<<<<< + * return 1 + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: */ - __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->intersect_helper(__pyx_v_self, __pyx_v_prefix, __pyx_v_suffix, __pyx_v_prefix_loc, __pyx_v_suffix_loc, __pyx_v_3_sa_BAEZA_YATES); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 818; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_v_result)); - __pyx_v_result = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) > (__pyx_v_loc2->arr[((__pyx_v_loc2->start + __pyx_v_i) - 1)])); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":819 - * if self.use_baeza_yates: - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, BAEZA_YATES) - * intersect_method="double binary" # <<<<<<<<<<<<<< - * else: - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, MERGE) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":657 + * for i from 1 <= i < loc1.size: + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: + * return 1 # <<<<<<<<<<<<<< + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: + * return -1 */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_120)); - __Pyx_XDECREF(__pyx_v_intersect_method); - __pyx_v_intersect_method = ((PyObject *)__pyx_kp_s_120); - goto __pyx_L5; - } - /*else*/ { + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L9; + } + __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":821 - * intersect_method="double binary" - * else: - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, MERGE) # <<<<<<<<<<<<<< - * intersect_method="merge" - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":658 + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i-1]: + * return 1 + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: # <<<<<<<<<<<<<< + * return -1 + * */ - __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->intersect_helper(__pyx_v_self, __pyx_v_prefix, __pyx_v_suffix, __pyx_v_prefix_loc, __pyx_v_suffix_loc, __pyx_v_3_sa_MERGE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_v_result)); - __pyx_v_result = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) < (__pyx_v_loc2->arr[((__pyx_v_loc2->start + __pyx_v_i) - 1)])); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":822 - * else: - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, MERGE) - * intersect_method="merge" # <<<<<<<<<<<<<< - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":659 + * return 1 + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i-1]: + * return -1 # <<<<<<<<<<<<<< * + * else: */ - __Pyx_INCREF(((PyObject *)__pyx_n_s__merge)); - __Pyx_XDECREF(__pyx_v_intersect_method); - __pyx_v_intersect_method = ((PyObject *)__pyx_n_s__merge); + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L10; + } + __pyx_L10:; } - __pyx_L5:; - goto __pyx_L4; + goto __pyx_L5; } - __pyx_L4:; + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":823 - * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, MERGE) - * intersect_method="merge" - * return result # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":662 * - * def advance(self, frontier, res, fwords): + * else: + * if loc1.arr[loc1.start]+1 > loc2.arr[loc2.start]: # <<<<<<<<<<<<<< + * return 1 + * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: */ - __Pyx_XDECREF(((PyObject *)__pyx_r)); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - __pyx_r = __pyx_v_result; - goto __pyx_L0; + __pyx_t_3 = (((__pyx_v_loc1->arr[__pyx_v_loc1->start]) + 1) > (__pyx_v_loc2->arr[__pyx_v_loc2->start])); + if (__pyx_t_3) { - __pyx_r = ((struct __pyx_obj_3_sa_PhraseLocation *)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("_sa.HieroCachingRuleFactory.intersect", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_prefix); - __Pyx_XDECREF((PyObject *)__pyx_v_suffix); - __Pyx_XDECREF((PyObject *)__pyx_v_prefix_loc); - __Pyx_XDECREF((PyObject *)__pyx_v_suffix_loc); - __Pyx_XDECREF((PyObject *)__pyx_v_result); - __Pyx_XDECREF(__pyx_v_intersect_method); - __Pyx_XGIVEREF((PyObject *)__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":663 + * else: + * if loc1.arr[loc1.start]+1 > loc2.arr[loc2.start]: + * return 1 # <<<<<<<<<<<<<< + * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: + * return -1 + */ + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L11; + } + __pyx_L11:; -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_13advance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_13advance(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_frontier = 0; - PyObject *__pyx_v_res = 0; - PyObject *__pyx_v_fwords = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("advance (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__frontier,&__pyx_n_s__res,&__pyx_n_s__fwords,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__frontier)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__res)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("advance", 1, 3, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("advance", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":664 + * if loc1.arr[loc1.start]+1 > loc2.arr[loc2.start]: + * return 1 + * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: # <<<<<<<<<<<<<< + * return -1 + * + */ + __pyx_t_3 = (((__pyx_v_loc1->arr[__pyx_v_loc1->start]) + 1) < (__pyx_v_loc2->arr[__pyx_v_loc2->start])); + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":665 + * return 1 + * if loc1.arr[loc1.start]+1 < loc2.arr[loc2.start]: + * return -1 # <<<<<<<<<<<<<< + * + * for i from 1 <= i < loc1.size: + */ + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L12; + } + __pyx_L12:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":667 + * return -1 + * + * for i from 1 <= i < loc1.size: # <<<<<<<<<<<<<< + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: + * return 1 + */ + __pyx_t_4 = __pyx_v_loc1->size; + for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_4; __pyx_v_i++) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":668 + * + * for i from 1 <= i < loc1.size: + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: # <<<<<<<<<<<<<< + * return 1 + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: + */ + __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) > (__pyx_v_loc2->arr[(__pyx_v_loc2->start + __pyx_v_i)])); + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":669 + * for i from 1 <= i < loc1.size: + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: + * return 1 # <<<<<<<<<<<<<< + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: + * return -1 + */ + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L15; } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "advance") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L15:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":670 + * if loc1.arr[loc1.start+i] > loc2.arr[loc2.start+i]: + * return 1 + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: # <<<<<<<<<<<<<< + * return -1 + * + */ + __pyx_t_3 = ((__pyx_v_loc1->arr[(__pyx_v_loc1->start + __pyx_v_i)]) < (__pyx_v_loc2->arr[(__pyx_v_loc2->start + __pyx_v_i)])); + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":671 + * return 1 + * if loc1.arr[loc1.start+i] < loc2.arr[loc2.start+i]: + * return -1 # <<<<<<<<<<<<<< + * + * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: + */ + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L16; } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + __pyx_L16:; } - __pyx_v_frontier = values[0]; - __pyx_v_res = values[1]; - __pyx_v_fwords = values[2]; } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("advance", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.advance", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_12advance(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_frontier, __pyx_v_res, __pyx_v_fwords); + __pyx_L5:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":673 + * return -1 + * + * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: # <<<<<<<<<<<<<< + * return -1 + * return 0 + */ + __pyx_t_3 = ((((__pyx_v_loc2->arr[(__pyx_v_loc2->end - 1)]) + __pyx_v_len_last) - (__pyx_v_loc1->arr[__pyx_v_loc1->start])) > __pyx_v_self->train_max_initial_size); + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":674 + * + * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: + * return -1 # <<<<<<<<<<<<<< + * return 0 + * + */ + __pyx_r = -1; + goto __pyx_L0; + goto __pyx_L17; + } + __pyx_L17:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":675 + * if loc2.arr[loc2.end-1] + len_last - loc1.arr[loc1.start] > self.train_max_initial_size: + * return -1 + * return 0 # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = 0; + goto __pyx_L0; + + __pyx_r = 0; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":825 - * return result +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":678 * - * def advance(self, frontier, res, fwords): # <<<<<<<<<<<<<< - * cdef unsigned na - * nf = [] + * + * cdef int* merge_helper(self, int low1, int high1, int* arr1, int step1, # <<<<<<<<<<<<<< + * int low2, int high2, int* arr2, int step2, + * int offset_by_one, int len_last, int num_subpatterns, int* result_len): */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_12advance(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_frontier, PyObject *__pyx_v_res, PyObject *__pyx_v_fwords) { - unsigned int __pyx_v_na; - PyObject *__pyx_v_nf = NULL; - PyObject *__pyx_v_toskip = NULL; - PyObject *__pyx_v_i = NULL; - PyObject *__pyx_v_alt = NULL; - PyObject *__pyx_v_pathlen = NULL; - PyObject *__pyx_v_spanlen = NULL; - PyObject *__pyx_v_ni = NULL; - PyObject *__pyx_r = NULL; +static int *__pyx_f_3_sa_23HieroCachingRuleFactory_merge_helper(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_low1, int __pyx_v_high1, int *__pyx_v_arr1, int __pyx_v_step1, int __pyx_v_low2, int __pyx_v_high2, int *__pyx_v_arr2, int __pyx_v_step2, int __pyx_v_offset_by_one, int __pyx_v_len_last, int __pyx_v_num_subpatterns, int *__pyx_v_result_len) { + int __pyx_v_i1; + int __pyx_v_i2; + int __pyx_v_j1; + int __pyx_v_j2; + long __pyx_v_comparison; + int *__pyx_v_result; + struct __pyx_t_3_sa_Matching __pyx_v_loc1; + struct __pyx_t_3_sa_Matching __pyx_v_loc2; + int *__pyx_r; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *(*__pyx_t_3)(PyObject *); - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *(*__pyx_t_8)(PyObject *); - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - PyObject *__pyx_t_11 = NULL; - int __pyx_t_12; - Py_ssize_t __pyx_t_13; - int __pyx_t_14; - int __pyx_t_15; - unsigned int __pyx_t_16; - int __pyx_t_17; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("advance", 0); + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; + __Pyx_RefNannySetupContext("merge_helper", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":827 - * def advance(self, frontier, res, fwords): - * cdef unsigned na - * nf = [] # <<<<<<<<<<<<<< - * for (toskip, (i, alt, pathlen)) in frontier: - * spanlen = fwords[i][alt][2] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":686 + * cdef Matching loc1, loc2 + * + * result_len[0] = 0 # <<<<<<<<<<<<<< + * result = malloc(0*sizeof(int)) + * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_nf = __pyx_t_1; - __pyx_t_1 = 0; + (__pyx_v_result_len[0]) = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":828 - * cdef unsigned na - * nf = [] - * for (toskip, (i, alt, pathlen)) in frontier: # <<<<<<<<<<<<<< - * spanlen = fwords[i][alt][2] - * if (toskip == 0): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":687 + * + * result_len[0] = 0 + * result = malloc(0*sizeof(int)) # <<<<<<<<<<<<<< + * + * i1 = low1 */ - if (PyList_CheckExact(__pyx_v_frontier) || PyTuple_CheckExact(__pyx_v_frontier)) { - __pyx_t_1 = __pyx_v_frontier; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; - __pyx_t_3 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_frontier); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; - } - for (;;) { - if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_4 = __pyx_t_3(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); + __pyx_v_result = ((int *)malloc((0 * (sizeof(int))))); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":689 + * result = malloc(0*sizeof(int)) + * + * i1 = low1 # <<<<<<<<<<<<<< + * i2 = low2 + * while i1 < high1 and i2 < high2: + */ + __pyx_v_i1 = __pyx_v_low1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":690 + * + * i1 = low1 + * i2 = low2 # <<<<<<<<<<<<<< + * while i1 < high1 and i2 < high2: + * + */ + __pyx_v_i2 = __pyx_v_low2; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":691 + * i1 = low1 + * i2 = low2 + * while i1 < high1 and i2 < high2: # <<<<<<<<<<<<<< + * + * # First, pop all unneeded loc2's off the stack + */ + while (1) { + __pyx_t_1 = (__pyx_v_i1 < __pyx_v_high1); + if (__pyx_t_1) { + __pyx_t_2 = (__pyx_v_i2 < __pyx_v_high2); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_1; } - if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { - PyObject* sequence = __pyx_t_4; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!__pyx_t_3) break; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":694 + * + * # First, pop all unneeded loc2's off the stack + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * while i2 < high2: + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + */ + __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":695 + * # First, pop all unneeded loc2's off the stack + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * while i2 < high2: # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + */ + while (1) { + __pyx_t_3 = (__pyx_v_i2 < __pyx_v_high2); + if (!__pyx_t_3) break; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":696 + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * while i2 < high2: + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + * i2 = i2 + step2 + */ + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_i2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":697 + * while i2 < high2: + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: # <<<<<<<<<<<<<< + * i2 = i2 + step2 + * else: + */ + __pyx_t_3 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last) == 1); + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":698 + * assign_matching(&loc2, arr2, i2, step2, self.fda.sent_id.arr) + * if self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) == 1: + * i2 = i2 + step2 # <<<<<<<<<<<<<< + * else: + * break + */ + __pyx_v_i2 = (__pyx_v_i2 + __pyx_v_step2); + goto __pyx_L7; } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - __pyx_t_6 = PyList_GET_ITEM(sequence, 1); + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":700 + * i2 = i2 + step2 + * else: + * break # <<<<<<<<<<<<<< + * + * # Next: process all loc1's with the same starting val + */ + goto __pyx_L6_break; } - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - { - Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; - __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = NULL; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - goto __pyx_L6_unpacking_done; - __pyx_L5_unpacking_failed:; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_8 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L6_unpacking_done:; + __pyx_L7:; } - __Pyx_XDECREF(__pyx_v_toskip); - __pyx_v_toskip = __pyx_t_5; - __pyx_t_5 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { - PyObject* sequence = __pyx_t_6; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 3)) { - if (size > 3) __Pyx_RaiseTooManyValuesError(3); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); + __pyx_L6_break:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":703 + * + * # Next: process all loc1's with the same starting val + * j1 = i1 # <<<<<<<<<<<<<< + * while i1 < high1 and arr1[j1] == arr1[i1]: + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + */ + __pyx_v_j1 = __pyx_v_i1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":704 + * # Next: process all loc1's with the same starting val + * j1 = i1 + * while i1 < high1 and arr1[j1] == arr1[i1]: # <<<<<<<<<<<<<< + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * j2 = i2 + */ + while (1) { + __pyx_t_3 = (__pyx_v_i1 < __pyx_v_high1); + if (__pyx_t_3) { + __pyx_t_1 = ((__pyx_v_arr1[__pyx_v_j1]) == (__pyx_v_arr1[__pyx_v_i1])); + __pyx_t_2 = __pyx_t_1; } else { - __pyx_t_7 = PyList_GET_ITEM(sequence, 0); - __pyx_t_9 = PyList_GET_ITEM(sequence, 1); - __pyx_t_10 = PyList_GET_ITEM(sequence, 2); + __pyx_t_2 = __pyx_t_3; } - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(__pyx_t_10); - #else - __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - { - Py_ssize_t index = -1; - __pyx_t_11 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_8 = Py_TYPE(__pyx_t_11)->tp_iternext; - index = 0; __pyx_t_7 = __pyx_t_8(__pyx_t_11); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed; - __Pyx_GOTREF(__pyx_t_7); - index = 1; __pyx_t_9 = __pyx_t_8(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed; - __Pyx_GOTREF(__pyx_t_9); - index = 2; __pyx_t_10 = __pyx_t_8(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L7_unpacking_failed; - __Pyx_GOTREF(__pyx_t_10); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = NULL; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - goto __pyx_L8_unpacking_done; - __pyx_L7_unpacking_failed:; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - __pyx_t_8 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L8_unpacking_done:; - } - __Pyx_XDECREF(__pyx_v_i); - __pyx_v_i = __pyx_t_7; - __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_v_alt); - __pyx_v_alt = __pyx_t_9; - __pyx_t_9 = 0; - __Pyx_XDECREF(__pyx_v_pathlen); - __pyx_v_pathlen = __pyx_t_10; - __pyx_t_10 = 0; + if (!__pyx_t_2) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":829 - * nf = [] - * for (toskip, (i, alt, pathlen)) in frontier: - * spanlen = fwords[i][alt][2] # <<<<<<<<<<<<<< - * if (toskip == 0): - * res.append((i, alt, pathlen)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":705 + * j1 = i1 + * while i1 < high1 and arr1[j1] == arr1[i1]: + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * j2 = i2 + * while j2 < high2: */ - __pyx_t_4 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_i); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_v_alt); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_6, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_XDECREF(__pyx_v_spanlen); - __pyx_v_spanlen = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_f_3_sa_assign_matching((&__pyx_v_loc1), __pyx_v_arr1, __pyx_v_i1, __pyx_v_step1, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":830 - * for (toskip, (i, alt, pathlen)) in frontier: - * spanlen = fwords[i][alt][2] - * if (toskip == 0): # <<<<<<<<<<<<<< - * res.append((i, alt, pathlen)) - * ni = i + spanlen + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":706 + * while i1 < high1 and arr1[j1] == arr1[i1]: + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * j2 = i2 # <<<<<<<<<<<<<< + * while j2 < high2: + * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) */ - __pyx_t_4 = PyObject_RichCompare(__pyx_v_toskip, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_12) { + __pyx_v_j2 = __pyx_v_i2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":831 - * spanlen = fwords[i][alt][2] - * if (toskip == 0): - * res.append((i, alt, pathlen)) # <<<<<<<<<<<<<< - * ni = i + spanlen - * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":707 + * assign_matching(&loc1, arr1, i1, step1, self.fda.sent_id.arr) + * j2 = i2 + * while j2 < high2: # <<<<<<<<<<<<<< + * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) */ - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_i); - __Pyx_GIVEREF(__pyx_v_i); - __Pyx_INCREF(__pyx_v_alt); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_alt); - __Pyx_GIVEREF(__pyx_v_alt); - __Pyx_INCREF(__pyx_v_pathlen); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_v_pathlen); - __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_res, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - goto __pyx_L9; - } - __pyx_L9:; + while (1) { + __pyx_t_2 = (__pyx_v_j2 < __pyx_v_high2); + if (!__pyx_t_2) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":832 - * if (toskip == 0): - * res.append((i, alt, pathlen)) - * ni = i + spanlen # <<<<<<<<<<<<<< - * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): - * for na in range(len(fwords[ni])): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":708 + * j2 = i2 + * while j2 < high2: + * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + * if comparison == 0: */ - __pyx_t_6 = PyNumber_Add(__pyx_v_i, __pyx_v_spanlen); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_v_ni); - __pyx_v_ni = __pyx_t_6; - __pyx_t_6 = 0; + __pyx_f_3_sa_assign_matching((&__pyx_v_loc2), __pyx_v_arr2, __pyx_v_j2, __pyx_v_step2, __pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":833 - * res.append((i, alt, pathlen)) - * ni = i + spanlen - * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): # <<<<<<<<<<<<<< - * for na in range(len(fwords[ni])): - * nf.append((toskip - 1, (ni, na, pathlen + 1))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":709 + * while j2 < high2: + * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) # <<<<<<<<<<<<<< + * if comparison == 0: + * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) */ - __pyx_t_13 = PyObject_Length(__pyx_v_fwords); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyObject_RichCompare(__pyx_v_ni, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_12) { - __pyx_t_4 = PyNumber_Add(__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyInt_FromLong(__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_15 = __pyx_t_14; - } else { - __pyx_t_15 = __pyx_t_12; - } - if (__pyx_t_15) { + __pyx_v_comparison = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->compare_matchings(__pyx_v_self, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_len_last); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":834 - * ni = i + spanlen - * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): - * for na in range(len(fwords[ni])): # <<<<<<<<<<<<<< - * nf.append((toskip - 1, (ni, na, pathlen + 1))) - * if (len(nf) > 0): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":710 + * assign_matching(&loc2, arr2, j2, step2, self.fda.sent_id.arr) + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + * if comparison == 0: # <<<<<<<<<<<<<< + * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) + * if comparison == 1: */ - __pyx_t_5 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ni); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_13 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_13; __pyx_t_16+=1) { - __pyx_v_na = __pyx_t_16; + __pyx_t_2 = (__pyx_v_comparison == 0); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":835 - * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): - * for na in range(len(fwords[ni])): - * nf.append((toskip - 1, (ni, na, pathlen + 1))) # <<<<<<<<<<<<<< - * if (len(nf) > 0): - * return self.advance(nf, res, fwords) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":711 + * comparison = self.compare_matchings(&loc1, &loc2, offset_by_one, len_last) + * if comparison == 0: + * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) # <<<<<<<<<<<<<< + * if comparison == 1: + * pass */ - __pyx_t_5 = PyNumber_Subtract(__pyx_v_toskip, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_na); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyNumber_Add(__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_INCREF(__pyx_v_ni); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_ni); - __Pyx_GIVEREF(__pyx_v_ni); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_6 = 0; - __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_10)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_10)); - __pyx_t_5 = 0; - __pyx_t_10 = 0; - __pyx_t_17 = PyList_Append(__pyx_v_nf, ((PyObject *)__pyx_t_4)); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - } - goto __pyx_L10; - } - __pyx_L10:; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_result = __pyx_f_3_sa_append_combined_matching(__pyx_v_result, (&__pyx_v_loc1), (&__pyx_v_loc2), __pyx_v_offset_by_one, __pyx_v_num_subpatterns, __pyx_v_result_len); + goto __pyx_L12; + } + __pyx_L12:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":836 - * for na in range(len(fwords[ni])): - * nf.append((toskip - 1, (ni, na, pathlen + 1))) - * if (len(nf) > 0): # <<<<<<<<<<<<<< - * return self.advance(nf, res, fwords) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":712 + * if comparison == 0: + * result = append_combined_matching(result, &loc1, &loc2, offset_by_one, num_subpatterns, result_len) + * if comparison == 1: # <<<<<<<<<<<<<< + * pass + * if comparison == -1: */ - __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_nf)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_15 = (__pyx_t_2 > 0); - if (__pyx_t_15) { + __pyx_t_2 = (__pyx_v_comparison == 1); + if (__pyx_t_2) { + goto __pyx_L13; + } + __pyx_L13:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":837 - * nf.append((toskip - 1, (ni, na, pathlen + 1))) - * if (len(nf) > 0): - * return self.advance(nf, res, fwords) # <<<<<<<<<<<<<< - * else: - * return res + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":714 + * if comparison == 1: + * pass + * if comparison == -1: # <<<<<<<<<<<<<< + * break + * else: */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__advance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(((PyObject *)__pyx_v_nf)); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_nf)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_nf)); - __Pyx_INCREF(__pyx_v_res); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_res); - __Pyx_GIVEREF(__pyx_v_res); - __Pyx_INCREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_fwords); - __Pyx_GIVEREF(__pyx_v_fwords); - __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_r = __pyx_t_10; - __pyx_t_10 = 0; - goto __pyx_L0; - goto __pyx_L13; - } - /*else*/ { + __pyx_t_2 = (__pyx_v_comparison == -1); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":839 - * return self.advance(nf, res, fwords) - * else: - * return res # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":715 + * pass + * if comparison == -1: + * break # <<<<<<<<<<<<<< + * else: + * j2 = j2 + step2 + */ + goto __pyx_L11_break; + goto __pyx_L14; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":717 + * break + * else: + * j2 = j2 + step2 # <<<<<<<<<<<<<< + * i1 = i1 + step1 + * return result + */ + __pyx_v_j2 = (__pyx_v_j2 + __pyx_v_step2); + } + __pyx_L14:; + } + __pyx_L11_break:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":718 + * else: + * j2 = j2 + step2 + * i1 = i1 + step1 # <<<<<<<<<<<<<< + * return result * - * def get_all_nodes_isteps_away(self, skip, i, spanlen, pathlen, fwords, next_states, reachable_buffer): */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_res); - __pyx_r = __pyx_v_res; - goto __pyx_L0; + __pyx_v_i1 = (__pyx_v_i1 + __pyx_v_step1); + } } - __pyx_L13:; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":719 + * j2 = j2 + step2 + * i1 = i1 + step1 + * return result # <<<<<<<<<<<<<< + * + * + */ + __pyx_r = __pyx_v_result; goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.advance", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + + __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_nf); - __Pyx_XDECREF(__pyx_v_toskip); - __Pyx_XDECREF(__pyx_v_i); - __Pyx_XDECREF(__pyx_v_alt); - __Pyx_XDECREF(__pyx_v_pathlen); - __Pyx_XDECREF(__pyx_v_spanlen); - __Pyx_XDECREF(__pyx_v_ni); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_15get_all_nodes_isteps_away(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_15get_all_nodes_isteps_away(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_skip = 0; - PyObject *__pyx_v_i = 0; - PyObject *__pyx_v_spanlen = 0; - PyObject *__pyx_v_pathlen = 0; - PyObject *__pyx_v_fwords = 0; - PyObject *__pyx_v_next_states = 0; - PyObject *__pyx_v_reachable_buffer = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("get_all_nodes_isteps_away (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__skip,&__pyx_n_s__i,&__pyx_n_s__spanlen,&__pyx_n_s__pathlen,&__pyx_n_s__fwords,&__pyx_n_s__next_states,&__pyx_n_s__reachable_buffer,0}; - PyObject* values[7] = {0,0,0,0,0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); - case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__skip)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__spanlen)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 3: - if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pathlen)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 3); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 4: - if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 4); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 5: - if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__next_states)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 5); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 6: - if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reachable_buffer)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 6); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_all_nodes_isteps_away") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - values[4] = PyTuple_GET_ITEM(__pyx_args, 4); - values[5] = PyTuple_GET_ITEM(__pyx_args, 5); - values[6] = PyTuple_GET_ITEM(__pyx_args, 6); +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":722 + * + * + * cdef void sort_phrase_loc(self, IntList arr, PhraseLocation loc, Phrase phrase): # <<<<<<<<<<<<<< + * cdef int i, j + * cdef VEB veb + */ + +static void __pyx_f_3_sa_23HieroCachingRuleFactory_sort_phrase_loc(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_IntList *__pyx_v_arr, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_loc, struct __pyx_obj_3_sa_Phrase *__pyx_v_phrase) { + int __pyx_v_i; + int __pyx_v_j; + struct __pyx_obj_3_sa_VEB *__pyx_v_veb = 0; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("sort_phrase_loc", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":727 + * cdef IntList result + * + * if phrase in self.precomputed_index: # <<<<<<<<<<<<<< + * loc.arr = self.precomputed_index[phrase] + * else: + */ + __pyx_t_1 = ((PySequence_Contains(__pyx_v_self->precomputed_index, ((PyObject *)__pyx_v_phrase)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 727; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_1) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":728 + * + * if phrase in self.precomputed_index: + * loc.arr = self.precomputed_index[phrase] # <<<<<<<<<<<<<< + * else: + * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) + */ + __pyx_t_2 = PyObject_GetItem(__pyx_v_self->precomputed_index, ((PyObject *)__pyx_v_phrase)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_GOTREF(__pyx_v_loc->arr); + __Pyx_DECREF(((PyObject *)__pyx_v_loc->arr)); + __pyx_v_loc->arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); + __pyx_t_2 = 0; + goto __pyx_L3; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":730 + * loc.arr = self.precomputed_index[phrase] + * else: + * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) # <<<<<<<<<<<<<< + * veb = VEB(arr.len) + * for i from loc.sa_low <= i < loc.sa_high: + */ + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_3 = PyInt_FromLong((__pyx_v_loc->sa_high - __pyx_v_loc->sa_low)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_v_loc->arr); + __Pyx_DECREF(((PyObject *)__pyx_v_loc->arr)); + __pyx_v_loc->arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":731 + * else: + * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) + * veb = VEB(arr.len) # <<<<<<<<<<<<<< + * for i from loc.sa_low <= i < loc.sa_high: + * veb._insert(arr.arr[i]) + */ + __pyx_t_3 = PyInt_FromLong(__pyx_v_arr->len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_VEB)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_v_veb = ((struct __pyx_obj_3_sa_VEB *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":732 + * loc.arr = IntList(initial_len=loc.sa_high-loc.sa_low) + * veb = VEB(arr.len) + * for i from loc.sa_low <= i < loc.sa_high: # <<<<<<<<<<<<<< + * veb._insert(arr.arr[i]) + * i = veb.veb.min_val + */ + __pyx_t_4 = __pyx_v_loc->sa_high; + for (__pyx_v_i = __pyx_v_loc->sa_low; __pyx_v_i < __pyx_t_4; __pyx_v_i++) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":733 + * veb = VEB(arr.len) + * for i from loc.sa_low <= i < loc.sa_high: + * veb._insert(arr.arr[i]) # <<<<<<<<<<<<<< + * i = veb.veb.min_val + * for j from 0 <= j < loc.sa_high-loc.sa_low: + */ + ((struct __pyx_vtabstruct_3_sa_VEB *)__pyx_v_veb->__pyx_vtab)->_insert(__pyx_v_veb, (__pyx_v_arr->arr[__pyx_v_i])); + } + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":734 + * for i from loc.sa_low <= i < loc.sa_high: + * veb._insert(arr.arr[i]) + * i = veb.veb.min_val # <<<<<<<<<<<<<< + * for j from 0 <= j < loc.sa_high-loc.sa_low: + * loc.arr.arr[j] = i + */ + __pyx_v_i = __pyx_v_veb->veb->min_val; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":735 + * veb._insert(arr.arr[i]) + * i = veb.veb.min_val + * for j from 0 <= j < loc.sa_high-loc.sa_low: # <<<<<<<<<<<<<< + * loc.arr.arr[j] = i + * i = veb._findsucc(i) + */ + __pyx_t_4 = (__pyx_v_loc->sa_high - __pyx_v_loc->sa_low); + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_4; __pyx_v_j++) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":736 + * i = veb.veb.min_val + * for j from 0 <= j < loc.sa_high-loc.sa_low: + * loc.arr.arr[j] = i # <<<<<<<<<<<<<< + * i = veb._findsucc(i) + * loc.arr_low = 0 + */ + (__pyx_v_loc->arr->arr[__pyx_v_j]) = __pyx_v_i; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":737 + * for j from 0 <= j < loc.sa_high-loc.sa_low: + * loc.arr.arr[j] = i + * i = veb._findsucc(i) # <<<<<<<<<<<<<< + * loc.arr_low = 0 + * loc.arr_high = loc.arr.len + */ + __pyx_v_i = ((struct __pyx_vtabstruct_3_sa_VEB *)__pyx_v_veb->__pyx_vtab)->_findsucc(__pyx_v_veb, __pyx_v_i); } - __pyx_v_skip = values[0]; - __pyx_v_i = values[1]; - __pyx_v_spanlen = values[2]; - __pyx_v_pathlen = values[3]; - __pyx_v_fwords = values[4]; - __pyx_v_next_states = values[5]; - __pyx_v_reachable_buffer = values[6]; } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_all_nodes_isteps_away", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_14get_all_nodes_isteps_away(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_skip, __pyx_v_i, __pyx_v_spanlen, __pyx_v_pathlen, __pyx_v_fwords, __pyx_v_next_states, __pyx_v_reachable_buffer); + __pyx_L3:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":738 + * loc.arr.arr[j] = i + * i = veb._findsucc(i) + * loc.arr_low = 0 # <<<<<<<<<<<<<< + * loc.arr_high = loc.arr.len + * + */ + __pyx_v_loc->arr_low = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":739 + * i = veb._findsucc(i) + * loc.arr_low = 0 + * loc.arr_high = loc.arr.len # <<<<<<<<<<<<<< + * + * + */ + __pyx_v_loc->arr_high = __pyx_v_loc->arr->len; + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_WriteUnraisable("_sa.HieroCachingRuleFactory.sort_phrase_loc", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_veb); __Pyx_RefNannyFinishContext(); - return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":841 - * return res +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":742 + * + * + * cdef intersect_helper(self, Phrase prefix, Phrase suffix, # <<<<<<<<<<<<<< + * PhraseLocation prefix_loc, PhraseLocation suffix_loc, int algorithm): * - * def get_all_nodes_isteps_away(self, skip, i, spanlen, pathlen, fwords, next_states, reachable_buffer): # <<<<<<<<<<<<<< - * cdef unsigned alt_it - * frontier = [] */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_14get_all_nodes_isteps_away(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_skip, PyObject *__pyx_v_i, PyObject *__pyx_v_spanlen, PyObject *__pyx_v_pathlen, PyObject *__pyx_v_fwords, PyObject *__pyx_v_next_states, PyObject *__pyx_v_reachable_buffer) { - PyObject *__pyx_v_frontier = NULL; - PyObject *__pyx_v_key = NULL; - PyObject *__pyx_v_reachable = NULL; - PyObject *__pyx_v_nextreachable = NULL; - PyObject *__pyx_v_next_id = NULL; - PyObject *__pyx_v_jump = NULL; - PyObject *__pyx_v_alt_id = NULL; - PyObject *__pyx_v_newel = NULL; +static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_intersect_helper(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_prefix, struct __pyx_obj_3_sa_Phrase *__pyx_v_suffix, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_prefix_loc, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_suffix_loc, int __pyx_v_algorithm) { + struct __pyx_obj_3_sa_IntList *__pyx_v_arr1 = 0; + struct __pyx_obj_3_sa_IntList *__pyx_v_arr2 = 0; + struct __pyx_obj_3_sa_IntList *__pyx_v_result = 0; + int __pyx_v_low1; + int __pyx_v_high1; + int __pyx_v_step1; + int __pyx_v_low2; + int __pyx_v_high2; + int __pyx_v_step2; + int __pyx_v_offset_by_one; + int __pyx_v_len_last; + int __pyx_v_num_subpatterns; + int __pyx_v_result_len; + int *__pyx_v_result_ptr; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; + int __pyx_t_2; + int __pyx_t_3; PyObject *__pyx_t_4 = NULL; - int __pyx_t_5; - PyObject *(*__pyx_t_6)(PyObject *); - Py_ssize_t __pyx_t_7; - PyObject *(*__pyx_t_8)(PyObject *); - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - Py_ssize_t __pyx_t_11; - PyObject *(*__pyx_t_12)(PyObject *); - PyObject *__pyx_t_13 = NULL; - int __pyx_t_14; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + int __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_all_nodes_isteps_away", 0); + __Pyx_RefNannySetupContext("intersect_helper", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":843 - * def get_all_nodes_isteps_away(self, skip, i, spanlen, pathlen, fwords, next_states, reachable_buffer): - * cdef unsigned alt_it - * frontier = [] # <<<<<<<<<<<<<< - * if (i+spanlen+skip >= len(next_states)): - * return frontier + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":749 + * cdef int* result_ptr + * + * result_len = 0 # <<<<<<<<<<<<<< + * + * if sym_isvar(suffix[0]): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_frontier = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_v_result_len = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":844 - * cdef unsigned alt_it - * frontier = [] - * if (i+spanlen+skip >= len(next_states)): # <<<<<<<<<<<<<< - * return frontier - * key = tuple([i,spanlen]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":751 + * result_len = 0 + * + * if sym_isvar(suffix[0]): # <<<<<<<<<<<<<< + * offset_by_one = 1 + * else: */ - __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_v_spanlen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_skip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = PyObject_Length(__pyx_v_next_states); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_suffix), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { + __pyx_t_3 = __pyx_f_3_sa_sym_isvar(__pyx_t_2); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":845 - * frontier = [] - * if (i+spanlen+skip >= len(next_states)): - * return frontier # <<<<<<<<<<<<<< - * key = tuple([i,spanlen]) - * reachable = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":752 + * + * if sym_isvar(suffix[0]): + * offset_by_one = 1 # <<<<<<<<<<<<<< + * else: + * offset_by_one = 0 */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_frontier)); - __pyx_r = ((PyObject *)__pyx_v_frontier); - goto __pyx_L0; + __pyx_v_offset_by_one = 1; goto __pyx_L3; } - __pyx_L3:; + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":846 - * if (i+spanlen+skip >= len(next_states)): - * return frontier - * key = tuple([i,spanlen]) # <<<<<<<<<<<<<< - * reachable = [] - * if (key in reachable_buffer): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":754 + * offset_by_one = 1 + * else: + * offset_by_one = 0 # <<<<<<<<<<<<<< + * + * len_last = len(suffix.getchunk(suffix.arity())) */ - __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_i); - PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_i); - __Pyx_GIVEREF(__pyx_v_i); - __Pyx_INCREF(__pyx_v_spanlen); - PyList_SET_ITEM(__pyx_t_4, 1, __pyx_v_spanlen); - __Pyx_GIVEREF(__pyx_v_spanlen); - __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_v_key = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_v_offset_by_one = 0; + } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":847 - * return frontier - * key = tuple([i,spanlen]) - * reachable = [] # <<<<<<<<<<<<<< - * if (key in reachable_buffer): - * reachable = reachable_buffer[key] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":756 + * offset_by_one = 0 + * + * len_last = len(suffix.getchunk(suffix.arity())) # <<<<<<<<<<<<<< + * + * if prefix_loc.arr is None: */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_suffix), __pyx_n_s__getchunk); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_v_reachable = ((PyObject *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_suffix), __pyx_n_s__arity); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_5 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_t_6 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_len_last = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":848 - * key = tuple([i,spanlen]) - * reachable = [] - * if (key in reachable_buffer): # <<<<<<<<<<<<<< - * reachable = reachable_buffer[key] - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":758 + * len_last = len(suffix.getchunk(suffix.arity())) + * + * if prefix_loc.arr is None: # <<<<<<<<<<<<<< + * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) + * arr1 = prefix_loc.arr */ - __pyx_t_5 = ((PySequence_Contains(__pyx_v_reachable_buffer, ((PyObject *)__pyx_v_key)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_5) { + __pyx_t_7 = (((PyObject *)__pyx_v_prefix_loc->arr) == Py_None); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":849 - * reachable = [] - * if (key in reachable_buffer): - * reachable = reachable_buffer[key] # <<<<<<<<<<<<<< - * else: - * reachable = self.reachable(fwords, i, spanlen) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":759 + * + * if prefix_loc.arr is None: + * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) # <<<<<<<<<<<<<< + * arr1 = prefix_loc.arr + * low1 = prefix_loc.arr_low */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_reachable_buffer, ((PyObject *)__pyx_v_key)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_v_reachable); - __pyx_v_reachable = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_5 = ((PyObject *)__pyx_v_self->fsa->sa); + __Pyx_INCREF(__pyx_t_5); + ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->sort_phrase_loc(__pyx_v_self, ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5), __pyx_v_prefix_loc, __pyx_v_prefix); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L4; } - /*else*/ { + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":851 - * reachable = reachable_buffer[key] - * else: - * reachable = self.reachable(fwords, i, spanlen) # <<<<<<<<<<<<<< - * reachable_buffer[key] = reachable - * for nextreachable in reachable: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":760 + * if prefix_loc.arr is None: + * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) + * arr1 = prefix_loc.arr # <<<<<<<<<<<<<< + * low1 = prefix_loc.arr_low + * high1 = prefix_loc.arr_high */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reachable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fwords); - __Pyx_GIVEREF(__pyx_v_fwords); - __Pyx_INCREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_i); - __Pyx_GIVEREF(__pyx_v_i); - __Pyx_INCREF(__pyx_v_spanlen); - PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_spanlen); - __Pyx_GIVEREF(__pyx_v_spanlen); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 851; __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_4)); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_v_reachable); - __pyx_v_reachable = __pyx_t_2; - __pyx_t_2 = 0; + __Pyx_INCREF(((PyObject *)__pyx_v_prefix_loc->arr)); + __pyx_v_arr1 = __pyx_v_prefix_loc->arr; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":852 - * else: - * reachable = self.reachable(fwords, i, spanlen) - * reachable_buffer[key] = reachable # <<<<<<<<<<<<<< - * for nextreachable in reachable: - * for next_id in next_states[nextreachable]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":761 + * self.sort_phrase_loc(self.fsa.sa, prefix_loc, prefix) + * arr1 = prefix_loc.arr + * low1 = prefix_loc.arr_low # <<<<<<<<<<<<<< + * high1 = prefix_loc.arr_high + * step1 = prefix_loc.num_subpatterns */ - if (PyObject_SetItem(__pyx_v_reachable_buffer, ((PyObject *)__pyx_v_key), __pyx_v_reachable) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_L4:; + __pyx_v_low1 = __pyx_v_prefix_loc->arr_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":853 - * reachable = self.reachable(fwords, i, spanlen) - * reachable_buffer[key] = reachable - * for nextreachable in reachable: # <<<<<<<<<<<<<< - * for next_id in next_states[nextreachable]: - * jump = self.shortest(fwords,i,next_id) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":762 + * arr1 = prefix_loc.arr + * low1 = prefix_loc.arr_low + * high1 = prefix_loc.arr_high # <<<<<<<<<<<<<< + * step1 = prefix_loc.num_subpatterns + * */ - if (PyList_CheckExact(__pyx_v_reachable) || PyTuple_CheckExact(__pyx_v_reachable)) { - __pyx_t_2 = __pyx_v_reachable; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; - __pyx_t_6 = NULL; - } else { - __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_reachable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; - } - for (;;) { - if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_2)) { - if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_2)) { - if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_4 = __pyx_t_6(__pyx_t_2); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF(__pyx_v_nextreachable); - __pyx_v_nextreachable = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_v_high1 = __pyx_v_prefix_loc->arr_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":854 - * reachable_buffer[key] = reachable - * for nextreachable in reachable: - * for next_id in next_states[nextreachable]: # <<<<<<<<<<<<<< - * jump = self.shortest(fwords,i,next_id) - * if jump < skip: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":763 + * low1 = prefix_loc.arr_low + * high1 = prefix_loc.arr_high + * step1 = prefix_loc.num_subpatterns # <<<<<<<<<<<<<< + * + * if suffix_loc.arr is None: */ - __pyx_t_4 = PyObject_GetItem(__pyx_v_next_states, __pyx_v_nextreachable); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { - __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; - __pyx_t_8 = NULL; - } else { - __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - for (;;) { - if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_4 = __pyx_t_8(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF(__pyx_v_next_id); - __pyx_v_next_id = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_v_step1 = __pyx_v_prefix_loc->num_subpatterns; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":855 - * for nextreachable in reachable: - * for next_id in next_states[nextreachable]: - * jump = self.shortest(fwords,i,next_id) # <<<<<<<<<<<<<< - * if jump < skip: - * continue + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":765 + * step1 = prefix_loc.num_subpatterns + * + * if suffix_loc.arr is None: # <<<<<<<<<<<<<< + * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) + * arr2 = suffix_loc.arr */ - __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__shortest); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_INCREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_fwords); - __Pyx_GIVEREF(__pyx_v_fwords); - __Pyx_INCREF(__pyx_v_i); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_i); - __Pyx_GIVEREF(__pyx_v_i); - __Pyx_INCREF(__pyx_v_next_id); - PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_next_id); - __Pyx_GIVEREF(__pyx_v_next_id); - __pyx_t_10 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_XDECREF(__pyx_v_jump); - __pyx_v_jump = __pyx_t_10; - __pyx_t_10 = 0; + __pyx_t_7 = (((PyObject *)__pyx_v_suffix_loc->arr) == Py_None); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":856 - * for next_id in next_states[nextreachable]: - * jump = self.shortest(fwords,i,next_id) - * if jump < skip: # <<<<<<<<<<<<<< - * continue - * if pathlen+jump <= self.max_initial_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":766 + * + * if suffix_loc.arr is None: + * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) # <<<<<<<<<<<<<< + * arr2 = suffix_loc.arr + * low2 = suffix_loc.arr_low */ - __pyx_t_10 = PyObject_RichCompare(__pyx_v_jump, __pyx_v_skip, Py_LT); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_5) { + __pyx_t_5 = ((PyObject *)__pyx_v_self->fsa->sa); + __Pyx_INCREF(__pyx_t_5); + ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->sort_phrase_loc(__pyx_v_self, ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5), __pyx_v_suffix_loc, __pyx_v_suffix); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L5; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":857 - * jump = self.shortest(fwords,i,next_id) - * if jump < skip: - * continue # <<<<<<<<<<<<<< - * if pathlen+jump <= self.max_initial_size: - * for alt_id in range(len(fwords[next_id])): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":767 + * if suffix_loc.arr is None: + * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) + * arr2 = suffix_loc.arr # <<<<<<<<<<<<<< + * low2 = suffix_loc.arr_low + * high2 = suffix_loc.arr_high */ - goto __pyx_L7_continue; - goto __pyx_L9; - } - __pyx_L9:; + __Pyx_INCREF(((PyObject *)__pyx_v_suffix_loc->arr)); + __pyx_v_arr2 = __pyx_v_suffix_loc->arr; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":858 - * if jump < skip: - * continue - * if pathlen+jump <= self.max_initial_size: # <<<<<<<<<<<<<< - * for alt_id in range(len(fwords[next_id])): - * if (fwords[next_id][alt_id][0] != EPSILON): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":768 + * self.sort_phrase_loc(self.fsa.sa, suffix_loc, suffix) + * arr2 = suffix_loc.arr + * low2 = suffix_loc.arr_low # <<<<<<<<<<<<<< + * high2 = suffix_loc.arr_high + * step2 = suffix_loc.num_subpatterns */ - __pyx_t_10 = PyNumber_Add(__pyx_v_pathlen, __pyx_v_jump); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyInt_FromLong(__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, __pyx_t_9, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if (__pyx_t_5) { + __pyx_v_low2 = __pyx_v_suffix_loc->arr_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":859 - * continue - * if pathlen+jump <= self.max_initial_size: - * for alt_id in range(len(fwords[next_id])): # <<<<<<<<<<<<<< - * if (fwords[next_id][alt_id][0] != EPSILON): - * newel = (next_id,alt_id,pathlen+jump) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":769 + * arr2 = suffix_loc.arr + * low2 = suffix_loc.arr_low + * high2 = suffix_loc.arr_high # <<<<<<<<<<<<<< + * step2 = suffix_loc.num_subpatterns + * */ - __pyx_t_4 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_next_id); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_11 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); - __Pyx_GIVEREF(__pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { - __pyx_t_9 = __pyx_t_4; __Pyx_INCREF(__pyx_t_9); __pyx_t_11 = 0; - __pyx_t_12 = NULL; - } else { - __pyx_t_11 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_12 = Py_TYPE(__pyx_t_9)->tp_iternext; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - for (;;) { - if (!__pyx_t_12 && PyList_CheckExact(__pyx_t_9)) { - if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_9)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_12 && PyTuple_CheckExact(__pyx_t_9)) { - if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_9)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++; - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_4 = __pyx_t_12(__pyx_t_9); - if (unlikely(!__pyx_t_4)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - __Pyx_XDECREF(__pyx_v_alt_id); - __pyx_v_alt_id = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_v_high2 = __pyx_v_suffix_loc->arr_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":860 - * if pathlen+jump <= self.max_initial_size: - * for alt_id in range(len(fwords[next_id])): - * if (fwords[next_id][alt_id][0] != EPSILON): # <<<<<<<<<<<<<< - * newel = (next_id,alt_id,pathlen+jump) - * if newel not in frontier: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":770 + * low2 = suffix_loc.arr_low + * high2 = suffix_loc.arr_high + * step2 = suffix_loc.num_subpatterns # <<<<<<<<<<<<<< + * + * num_subpatterns = prefix.arity()+1 */ - __pyx_t_4 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_next_id); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = PyObject_GetItem(__pyx_t_4, __pyx_v_alt_id); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_10, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_13 = PyObject_RichCompare(__pyx_t_4, __pyx_t_10, Py_NE); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - if (__pyx_t_5) { + __pyx_v_step2 = __pyx_v_suffix_loc->num_subpatterns; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":861 - * for alt_id in range(len(fwords[next_id])): - * if (fwords[next_id][alt_id][0] != EPSILON): - * newel = (next_id,alt_id,pathlen+jump) # <<<<<<<<<<<<<< - * if newel not in frontier: - * frontier.append((next_id,alt_id,pathlen+jump)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":772 + * step2 = suffix_loc.num_subpatterns + * + * num_subpatterns = prefix.arity()+1 # <<<<<<<<<<<<<< + * + * if algorithm == MERGE: */ - __pyx_t_13 = PyNumber_Add(__pyx_v_pathlen, __pyx_v_jump); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_INCREF(__pyx_v_next_id); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_next_id); - __Pyx_GIVEREF(__pyx_v_next_id); - __Pyx_INCREF(__pyx_v_alt_id); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_alt_id); - __Pyx_GIVEREF(__pyx_v_alt_id); - PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_13); - __Pyx_GIVEREF(__pyx_t_13); - __pyx_t_13 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_v_newel)); - __pyx_v_newel = __pyx_t_10; - __pyx_t_10 = 0; + __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_prefix), __pyx_n_s__arity); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 772; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_v_num_subpatterns = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":862 - * if (fwords[next_id][alt_id][0] != EPSILON): - * newel = (next_id,alt_id,pathlen+jump) - * if newel not in frontier: # <<<<<<<<<<<<<< - * frontier.append((next_id,alt_id,pathlen+jump)) - * return frontier + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":774 + * num_subpatterns = prefix.arity()+1 + * + * if algorithm == MERGE: # <<<<<<<<<<<<<< + * result_ptr = self.merge_helper(low1, high1, arr1.arr, step1, + * low2, high2, arr2.arr, step2, */ - __pyx_t_5 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_frontier), ((PyObject *)__pyx_v_newel)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_5) { + __pyx_t_7 = (__pyx_v_algorithm == __pyx_v_3_sa_MERGE); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":863 - * newel = (next_id,alt_id,pathlen+jump) - * if newel not in frontier: - * frontier.append((next_id,alt_id,pathlen+jump)) # <<<<<<<<<<<<<< - * return frontier + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":777 + * result_ptr = self.merge_helper(low1, high1, arr1.arr, step1, + * low2, high2, arr2.arr, step2, + * offset_by_one, len_last, num_subpatterns, &result_len) # <<<<<<<<<<<<<< + * else: + * result_ptr = self.baeza_yates_helper(low1, high1, arr1.arr, step1, + */ + __pyx_v_result_ptr = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->merge_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_high1, __pyx_v_arr1->arr, __pyx_v_step1, __pyx_v_low2, __pyx_v_high2, __pyx_v_arr2->arr, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_result_len)); + goto __pyx_L6; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":781 + * result_ptr = self.baeza_yates_helper(low1, high1, arr1.arr, step1, + * low2, high2, arr2.arr, step2, + * offset_by_one, len_last, num_subpatterns, &result_len) # <<<<<<<<<<<<<< * + * if result_len == 0: */ - __pyx_t_10 = PyNumber_Add(__pyx_v_pathlen, __pyx_v_jump); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - __Pyx_INCREF(__pyx_v_next_id); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_next_id); - __Pyx_GIVEREF(__pyx_v_next_id); - __Pyx_INCREF(__pyx_v_alt_id); - PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_alt_id); - __Pyx_GIVEREF(__pyx_v_alt_id); - PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_10 = 0; - __pyx_t_14 = PyList_Append(__pyx_v_frontier, ((PyObject *)__pyx_t_13)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0; - goto __pyx_L14; - } - __pyx_L14:; - goto __pyx_L13; - } - __pyx_L13:; - } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L10; - } - __pyx_L10:; - __pyx_L7_continue:; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_result_ptr = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->baeza_yates_helper(__pyx_v_self, __pyx_v_low1, __pyx_v_high1, __pyx_v_arr1->arr, __pyx_v_step1, __pyx_v_low2, __pyx_v_high2, __pyx_v_arr2->arr, __pyx_v_step2, __pyx_v_offset_by_one, __pyx_v_len_last, __pyx_v_num_subpatterns, (&__pyx_v_result_len)); } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":864 - * if newel not in frontier: - * frontier.append((next_id,alt_id,pathlen+jump)) - * return frontier # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":783 + * offset_by_one, len_last, num_subpatterns, &result_len) * - * def reachable(self, fwords, ifrom, dist): + * if result_len == 0: # <<<<<<<<<<<<<< + * free(result_ptr) + * return None */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_frontier)); - __pyx_r = ((PyObject *)__pyx_v_frontier); - goto __pyx_L0; + __pyx_t_7 = (__pyx_v_result_len == 0); + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":784 + * + * if result_len == 0: + * free(result_ptr) # <<<<<<<<<<<<<< + * return None + * else: + */ + free(__pyx_v_result_ptr); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":785 + * if result_len == 0: + * free(result_ptr) + * return None # <<<<<<<<<<<<<< + * else: + * result = IntList() + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(Py_None); + __pyx_r = Py_None; + goto __pyx_L0; + goto __pyx_L7; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":787 + * return None + * else: + * result = IntList() # <<<<<<<<<<<<<< + * free(result.arr) + * result.arr = result_ptr + */ + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 787; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_v_result = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_5); + __pyx_t_5 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":788 + * else: + * result = IntList() + * free(result.arr) # <<<<<<<<<<<<<< + * result.arr = result_ptr + * result.len = result_len + */ + free(__pyx_v_result->arr); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":789 + * result = IntList() + * free(result.arr) + * result.arr = result_ptr # <<<<<<<<<<<<<< + * result.len = result_len + * result.size = result_len + */ + __pyx_v_result->arr = __pyx_v_result_ptr; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":790 + * free(result.arr) + * result.arr = result_ptr + * result.len = result_len # <<<<<<<<<<<<<< + * result.size = result_len + * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) + */ + __pyx_v_result->len = __pyx_v_result_len; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":791 + * result.arr = result_ptr + * result.len = result_len + * result.size = result_len # <<<<<<<<<<<<<< + * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) + * + */ + __pyx_v_result->size = __pyx_v_result_len; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":792 + * result.len = result_len + * result.size = result_len + * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) # <<<<<<<<<<<<<< + * + * cdef loc2str(self, PhraseLocation loc): + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_5)); + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__arr_low), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_result_len); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__arr_high), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__arr), ((PyObject *)__pyx_v_result)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(__pyx_v_num_subpatterns); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__num_subpatterns), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + goto __pyx_L0; + } + __pyx_L7:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_all_nodes_isteps_away", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_XDECREF(__pyx_t_5); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.intersect_helper", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_frontier); - __Pyx_XDECREF(__pyx_v_key); - __Pyx_XDECREF(__pyx_v_reachable); - __Pyx_XDECREF(__pyx_v_nextreachable); - __Pyx_XDECREF(__pyx_v_next_id); - __Pyx_XDECREF(__pyx_v_jump); - __Pyx_XDECREF(__pyx_v_alt_id); - __Pyx_XDECREF(__pyx_v_newel); + __Pyx_XDECREF((PyObject *)__pyx_v_arr1); + __Pyx_XDECREF((PyObject *)__pyx_v_arr2); + __Pyx_XDECREF((PyObject *)__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_17reachable(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_17reachable(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_fwords = 0; - PyObject *__pyx_v_ifrom = 0; - PyObject *__pyx_v_dist = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("reachable (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fwords,&__pyx_n_s__ifrom,&__pyx_n_s__dist,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ifrom)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("reachable", 1, 3, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dist)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("reachable", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reachable") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_fwords = values[0]; - __pyx_v_ifrom = values[1]; - __pyx_v_dist = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("reachable", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.reachable", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_16reachable(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fwords, __pyx_v_ifrom, __pyx_v_dist); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":866 - * return frontier +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":794 + * return PhraseLocation(arr_low=0, arr_high=result_len, arr=result, num_subpatterns=num_subpatterns) * - * def reachable(self, fwords, ifrom, dist): # <<<<<<<<<<<<<< - * ret = [] - * if (ifrom >= len(fwords)): + * cdef loc2str(self, PhraseLocation loc): # <<<<<<<<<<<<<< + * cdef int i, j + * result = "{" */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_16reachable(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_ifrom, PyObject *__pyx_v_dist) { - PyObject *__pyx_v_ret = NULL; - PyObject *__pyx_v_alt_id = NULL; - PyObject *__pyx_v_ifromchild = NULL; +static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_loc2str(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_loc) { + int __pyx_v_i; + int __pyx_v_j; + PyObject *__pyx_v_result = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - PyObject *(*__pyx_t_5)(PyObject *); - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - PyObject *__pyx_t_8 = NULL; - int __pyx_t_9; - Py_ssize_t __pyx_t_10; - PyObject *(*__pyx_t_11)(PyObject *); + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + PyObject *__pyx_t_4 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("reachable", 0); + __Pyx_RefNannySetupContext("loc2str", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":867 - * - * def reachable(self, fwords, ifrom, dist): - * ret = [] # <<<<<<<<<<<<<< - * if (ifrom >= len(fwords)): - * return ret - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_ret = __pyx_t_1; - __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":868 - * def reachable(self, fwords, ifrom, dist): - * ret = [] - * if (ifrom >= len(fwords)): # <<<<<<<<<<<<<< - * return ret - * for alt_id in range(len(fwords[ifrom])): - */ - __pyx_t_2 = PyObject_Length(__pyx_v_fwords); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_RichCompare(__pyx_v_ifrom, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_4) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":869 - * ret = [] - * if (ifrom >= len(fwords)): - * return ret # <<<<<<<<<<<<<< - * for alt_id in range(len(fwords[ifrom])): - * if (fwords[ifrom][alt_id][0] == EPSILON): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = ((PyObject *)__pyx_v_ret); - goto __pyx_L0; - goto __pyx_L3; - } - __pyx_L3:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":870 - * if (ifrom >= len(fwords)): - * return ret - * for alt_id in range(len(fwords[ifrom])): # <<<<<<<<<<<<<< - * if (fwords[ifrom][alt_id][0] == EPSILON): - * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":796 + * cdef loc2str(self, PhraseLocation loc): + * cdef int i, j + * result = "{" # <<<<<<<<<<<<<< + * i = 0 + * while i < loc.arr_high: */ - __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __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[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__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_2 = 0; - __pyx_t_5 = NULL; - } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __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_2 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_3 = __pyx_t_5(__pyx_t_1); - if (unlikely(!__pyx_t_3)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_3); - } - __Pyx_XDECREF(__pyx_v_alt_id); - __pyx_v_alt_id = __pyx_t_3; - __pyx_t_3 = 0; + __Pyx_INCREF(((PyObject *)__pyx_kp_s_118)); + __pyx_v_result = ((PyObject *)__pyx_kp_s_118); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":871 - * return ret - * for alt_id in range(len(fwords[ifrom])): - * if (fwords[ifrom][alt_id][0] == EPSILON): # <<<<<<<<<<<<<< - * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":797 + * cdef int i, j + * result = "{" + * i = 0 # <<<<<<<<<<<<<< + * while i < loc.arr_high: + * result = result + "(" */ - __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_v_alt_id); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_6, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_4) { + __pyx_v_i = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":872 - * for alt_id in range(len(fwords[ifrom])): - * if (fwords[ifrom][alt_id][0] == EPSILON): - * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) # <<<<<<<<<<<<<< - * else: - * if (dist==0): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":798 + * result = "{" + * i = 0 + * while i < loc.arr_high: # <<<<<<<<<<<<<< + * result = result + "(" + * for j from i <= j < i + loc.num_subpatterns: */ - __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_ret), __pyx_n_s__extend); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reachable); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_alt_id); if (!__pyx_t_8) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_8 = PyNumber_Add(__pyx_v_ifrom, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fwords); - __Pyx_GIVEREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __Pyx_INCREF(__pyx_v_dist); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_dist); - __Pyx_GIVEREF(__pyx_v_dist); - __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); - __Pyx_GIVEREF(__pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L6; - } - /*else*/ { + while (1) { + __pyx_t_1 = (__pyx_v_i < __pyx_v_loc->arr_high); + if (!__pyx_t_1) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":874 - * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) - * else: - * if (dist==0): # <<<<<<<<<<<<<< - * if (ifrom not in ret): - * ret.append(ifrom) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":799 + * i = 0 + * while i < loc.arr_high: + * result = result + "(" # <<<<<<<<<<<<<< + * for j from i <= j < i + loc.num_subpatterns: + * result = result + ("%d " %loc.arr[j]) */ - __pyx_t_8 = PyObject_RichCompare(__pyx_v_dist, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - if (__pyx_t_4) { + __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_kp_s_119)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":875 - * else: - * if (dist==0): - * if (ifrom not in ret): # <<<<<<<<<<<<<< - * ret.append(ifrom) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":800 + * while i < loc.arr_high: + * result = result + "(" + * for j from i <= j < i + loc.num_subpatterns: # <<<<<<<<<<<<<< + * result = result + ("%d " %loc.arr[j]) + * result = result + ")" */ - __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_ret), __pyx_v_ifrom))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_4) { + __pyx_t_3 = (__pyx_v_i + __pyx_v_loc->num_subpatterns); + for (__pyx_v_j = __pyx_v_i; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":876 - * if (dist==0): - * if (ifrom not in ret): - * ret.append(ifrom) # <<<<<<<<<<<<<< - * else: - * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":801 + * result = result + "(" + * for j from i <= j < i + loc.num_subpatterns: + * result = result + ("%d " %loc.arr[j]) # <<<<<<<<<<<<<< + * result = result + ")" + * i = i + loc.num_subpatterns */ - __pyx_t_9 = PyList_Append(__pyx_v_ret, __pyx_v_ifrom); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L8; - } - __pyx_L8:; - goto __pyx_L7; - } - /*else*/ { + __pyx_t_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_loc->arr), __pyx_v_j, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":878 - * ret.append(ifrom) - * else: - * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): # <<<<<<<<<<<<<< - * if (ifromchild not in ret): - * ret.append(ifromchild) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":802 + * for j from i <= j < i + loc.num_subpatterns: + * result = result + ("%d " %loc.arr[j]) + * result = result + ")" # <<<<<<<<<<<<<< + * i = i + loc.num_subpatterns + * result = result + "}" */ - __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reachable); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_7 = PyObject_GetItem(__pyx_t_3, __pyx_v_alt_id); if (!__pyx_t_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_7, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyNumber_Add(__pyx_v_ifrom, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Subtract(__pyx_v_dist, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_INCREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_fwords); - __Pyx_GIVEREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_t_7 = 0; - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { - __pyx_t_6 = __pyx_t_3; __Pyx_INCREF(__pyx_t_6); __pyx_t_10 = 0; - __pyx_t_11 = NULL; - } else { - __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - for (;;) { - if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_6)) { - if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_6)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_6)) { - if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_6)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_3 = __pyx_t_11(__pyx_t_6); - if (unlikely(!__pyx_t_3)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_3); - } - __Pyx_XDECREF(__pyx_v_ifromchild); - __pyx_v_ifromchild = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_kp_s_59)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 802; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":879 - * else: - * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): - * if (ifromchild not in ret): # <<<<<<<<<<<<<< - * ret.append(ifromchild) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":803 + * result = result + ("%d " %loc.arr[j]) + * result = result + ")" + * i = i + loc.num_subpatterns # <<<<<<<<<<<<<< + * result = result + "}" + * return result */ - __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_ret), __pyx_v_ifromchild))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_4) { + __pyx_v_i = (__pyx_v_i + __pyx_v_loc->num_subpatterns); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":880 - * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): - * if (ifromchild not in ret): - * ret.append(ifromchild) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":804 + * result = result + ")" + * i = i + loc.num_subpatterns + * result = result + "}" # <<<<<<<<<<<<<< + * return result * - * return ret */ - __pyx_t_9 = PyList_Append(__pyx_v_ret, __pyx_v_ifromchild); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L11; - } - __pyx_L11:; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __pyx_L7:; - } - __pyx_L6:; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = PyNumber_Add(__pyx_v_result, ((PyObject *)__pyx_kp_s_120)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 804; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_v_result); + __pyx_v_result = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":882 - * ret.append(ifromchild) - * - * return ret # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":805 + * i = i + loc.num_subpatterns + * result = result + "}" + * return result # <<<<<<<<<<<<<< * - * def shortest(self, fwords, ifrom, ito): + * cdef PhraseLocation intersect(self, prefix_node, suffix_node, Phrase phrase): */ __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = ((PyObject *)__pyx_v_ret); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; goto __pyx_L0; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.reachable", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.loc2str", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_ret); - __Pyx_XDECREF(__pyx_v_alt_id); - __Pyx_XDECREF(__pyx_v_ifromchild); + __Pyx_XDECREF(__pyx_v_result); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_19shortest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_19shortest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_fwords = 0; - PyObject *__pyx_v_ifrom = 0; - PyObject *__pyx_v_ito = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("shortest (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fwords,&__pyx_n_s__ifrom,&__pyx_n_s__ito,0}; - PyObject* values[3] = {0,0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ifrom)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("shortest", 1, 3, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 2: - if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ito)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("shortest", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "shortest") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - } - __pyx_v_fwords = values[0]; - __pyx_v_ifrom = values[1]; - __pyx_v_ito = values[2]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("shortest", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.shortest", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_18shortest(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fwords, __pyx_v_ifrom, __pyx_v_ito); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":884 - * return ret +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":807 + * return result * - * def shortest(self, fwords, ifrom, ito): # <<<<<<<<<<<<<< - * cdef unsigned alt_id - * min = 1000 + * cdef PhraseLocation intersect(self, prefix_node, suffix_node, Phrase phrase): # <<<<<<<<<<<<<< + * cdef Phrase prefix, suffix + * cdef PhraseLocation prefix_loc, suffix_loc, result */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_18shortest(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_ifrom, PyObject *__pyx_v_ito) { - unsigned int __pyx_v_alt_id; - PyObject *__pyx_v_min = NULL; - PyObject *__pyx_v_currmin = NULL; - PyObject *__pyx_r = NULL; +static struct __pyx_obj_3_sa_PhraseLocation *__pyx_f_3_sa_23HieroCachingRuleFactory_intersect(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_prefix_node, PyObject *__pyx_v_suffix_node, struct __pyx_obj_3_sa_Phrase *__pyx_v_phrase) { + struct __pyx_obj_3_sa_Phrase *__pyx_v_prefix = 0; + struct __pyx_obj_3_sa_Phrase *__pyx_v_suffix = 0; + struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_prefix_loc = 0; + struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_suffix_loc = 0; + struct __pyx_obj_3_sa_PhraseLocation *__pyx_v_result = 0; + CYTHON_UNUSED PyObject *__pyx_v_intersect_method = NULL; + struct __pyx_obj_3_sa_PhraseLocation *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - Py_ssize_t __pyx_t_3; - unsigned int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("shortest", 0); + __Pyx_RefNannySetupContext("intersect", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":886 - * def shortest(self, fwords, ifrom, ito): - * cdef unsigned alt_id - * min = 1000 # <<<<<<<<<<<<<< - * if (ifrom > ito): - * return min + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":811 + * cdef PhraseLocation prefix_loc, suffix_loc, result + * + * prefix = prefix_node.phrase # <<<<<<<<<<<<<< + * suffix = suffix_node.phrase + * prefix_loc = prefix_node.phrase_location */ - __Pyx_INCREF(__pyx_int_1000); - __pyx_v_min = __pyx_int_1000; + __pyx_t_1 = PyObject_GetAttr(__pyx_v_prefix_node, __pyx_n_s__phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_Phrase))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_prefix = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":887 - * cdef unsigned alt_id - * min = 1000 - * if (ifrom > ito): # <<<<<<<<<<<<<< - * return min - * if (ifrom == ito): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":812 + * + * prefix = prefix_node.phrase + * suffix = suffix_node.phrase # <<<<<<<<<<<<<< + * prefix_loc = prefix_node.phrase_location + * suffix_loc = suffix_node.phrase_location */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_ifrom, __pyx_v_ito, Py_GT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_suffix_node, __pyx_n_s__phrase); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 812; __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[8]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_Phrase))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 812; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_suffix = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":888 - * min = 1000 - * if (ifrom > ito): - * return min # <<<<<<<<<<<<<< - * if (ifrom == ito): - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":813 + * prefix = prefix_node.phrase + * suffix = suffix_node.phrase + * prefix_loc = prefix_node.phrase_location # <<<<<<<<<<<<<< + * suffix_loc = suffix_node.phrase_location + * */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_min); - __pyx_r = __pyx_v_min; - goto __pyx_L0; - goto __pyx_L3; - } - __pyx_L3:; + __pyx_t_1 = PyObject_GetAttr(__pyx_v_prefix_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 813; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_prefix_loc = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":889 - * if (ifrom > ito): - * return min - * if (ifrom == ito): # <<<<<<<<<<<<<< - * return 0 - * for alt_id in range(len(fwords[ifrom])): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":814 + * suffix = suffix_node.phrase + * prefix_loc = prefix_node.phrase_location + * suffix_loc = suffix_node.phrase_location # <<<<<<<<<<<<<< + * + * result = self.get_precomputed_collocation(phrase) */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_ifrom, __pyx_v_ito, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_suffix_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 814; __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[8]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { + if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_suffix_loc = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":890 - * return min - * if (ifrom == ito): - * return 0 # <<<<<<<<<<<<<< - * for alt_id in range(len(fwords[ifrom])): - * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":816 + * suffix_loc = suffix_node.phrase_location + * + * result = self.get_precomputed_collocation(phrase) # <<<<<<<<<<<<<< + * if result is not None: + * intersect_method = "precomputed" */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_int_0); - __pyx_r = __pyx_int_0; - goto __pyx_L0; - goto __pyx_L4; + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_121); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_phrase)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_phrase)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_phrase)); + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_result = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":817 + * + * result = self.get_precomputed_collocation(phrase) + * if result is not None: # <<<<<<<<<<<<<< + * intersect_method = "precomputed" + * + */ + __pyx_t_4 = (((PyObject *)__pyx_v_result) != Py_None); + if (__pyx_t_4) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":818 + * result = self.get_precomputed_collocation(phrase) + * if result is not None: + * intersect_method = "precomputed" # <<<<<<<<<<<<<< + * + * if result is None: + */ + __Pyx_INCREF(((PyObject *)__pyx_n_s__precomputed)); + __pyx_v_intersect_method = ((PyObject *)__pyx_n_s__precomputed); + goto __pyx_L3; } - __pyx_L4:; + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":891 - * if (ifrom == ito): - * return 0 - * for alt_id in range(len(fwords[ifrom])): # <<<<<<<<<<<<<< - * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) - * if (fwords[ifrom][alt_id][0] != EPSILON): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":820 + * intersect_method = "precomputed" + * + * if result is None: # <<<<<<<<<<<<<< + * if self.use_baeza_yates: + * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, BAEZA_YATES) */ - __pyx_t_1 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_alt_id = __pyx_t_4; + __pyx_t_4 = (((PyObject *)__pyx_v_result) == Py_None); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":892 - * return 0 - * for alt_id in range(len(fwords[ifrom])): - * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) # <<<<<<<<<<<<<< - * if (fwords[ifrom][alt_id][0] != EPSILON): - * currmin += 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":821 + * + * if result is None: + * if self.use_baeza_yates: # <<<<<<<<<<<<<< + * result = self.intersect_helper(prefix, suffix, prefix_loc, suffix_loc, BAEZA_YATES) + * intersect_method="double binary" */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__shortest); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_alt_id, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyNumber_Add(__pyx_v_ifrom, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_fwords); - __Pyx_GIVEREF(__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); - __Pyx_GIVEREF(__pyx_t_6); - __Pyx_INCREF(__pyx_v_ito); - PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_ito); - __Pyx_GIVEREF(__pyx_v_ito); - __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __Pyx_XDECREF(__pyx_v_currmin); - __pyx_v_currmin = __pyx_t_6; - __pyx_t_6 = 0; + if (__pyx_v_self->use_baeza_yates) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":893 - * for alt_id in range(len(fwords[ifrom])): - * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) - * if (fwords[ifrom][alt_id][0] != EPSILON): # <<<<<<<<<<<<<< - * currmin += 1 - * if (currmin__pyx_vtab)->intersect_helper(__pyx_v_self, __pyx_v_prefix, __pyx_v_suffix, __pyx_v_prefix_loc, __pyx_v_suffix_loc, __pyx_v_3_sa_BAEZA_YATES); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_v_result)); + __pyx_v_result = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":894 - * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) - * if (fwords[ifrom][alt_id][0] != EPSILON): - * currmin += 1 # <<<<<<<<<<<<<< - * if (currmin__pyx_vtab)->intersect_helper(__pyx_v_self, __pyx_v_prefix, __pyx_v_suffix, __pyx_v_prefix_loc, __pyx_v_suffix_loc, __pyx_v_3_sa_MERGE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_v_result)); + __pyx_v_result = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":896 - * currmin += 1 - * if (currmin 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_dist); - if (value) { values[2] = value; kw_args--; } + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("advance", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_next_states") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "advance") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } - __pyx_v__columns = values[0]; - __pyx_v_curr_idx = values[1]; - __pyx_v_min_dist = values[2]; + __pyx_v_frontier = values[0]; + __pyx_v_res = values[1]; + __pyx_v_fwords = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("get_next_states", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("advance", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_next_states", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.advance", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_20get_next_states(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v__columns, __pyx_v_curr_idx, __pyx_v_min_dist); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_12advance(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_frontier, __pyx_v_res, __pyx_v_fwords); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":899 - * return min +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":829 + * return result * - * def get_next_states(self, _columns, curr_idx, min_dist=2): # <<<<<<<<<<<<<< - * result = [] - * candidate = [[curr_idx,0]] + * def advance(self, frontier, res, fwords): # <<<<<<<<<<<<<< + * cdef unsigned na + * nf = [] */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_20get_next_states(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v__columns, PyObject *__pyx_v_curr_idx, PyObject *__pyx_v_min_dist) { - PyObject *__pyx_v_result = NULL; - PyObject *__pyx_v_candidate = NULL; - PyObject *__pyx_v_curr = NULL; - PyObject *__pyx_v_curr_col = NULL; +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_12advance(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_frontier, PyObject *__pyx_v_res, PyObject *__pyx_v_fwords) { + unsigned int __pyx_v_na; + PyObject *__pyx_v_nf = NULL; + PyObject *__pyx_v_toskip = NULL; + PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_alt = NULL; - PyObject *__pyx_v_next_id = NULL; - PyObject *__pyx_v_jump = NULL; + PyObject *__pyx_v_pathlen = NULL; + PyObject *__pyx_v_spanlen = NULL; + PyObject *__pyx_v_ni = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - Py_ssize_t __pyx_t_3; - int __pyx_t_4; + Py_ssize_t __pyx_t_2; + PyObject *(*__pyx_t_3)(PyObject *); + PyObject *__pyx_t_4 = NULL; PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - PyObject *(*__pyx_t_9)(PyObject *); + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; PyObject *__pyx_t_10 = NULL; + PyObject *__pyx_t_11 = NULL; + int __pyx_t_12; + Py_ssize_t __pyx_t_13; + int __pyx_t_14; + int __pyx_t_15; + unsigned int __pyx_t_16; + int __pyx_t_17; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("get_next_states", 0); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":900 - * - * def get_next_states(self, _columns, curr_idx, min_dist=2): - * result = [] # <<<<<<<<<<<<<< - * candidate = [[curr_idx,0]] - * - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_result = __pyx_t_1; - __pyx_t_1 = 0; + __Pyx_RefNannySetupContext("advance", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":901 - * def get_next_states(self, _columns, curr_idx, min_dist=2): - * result = [] - * candidate = [[curr_idx,0]] # <<<<<<<<<<<<<< - * - * while len(candidate) > 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":831 + * def advance(self, frontier, res, fwords): + * cdef unsigned na + * nf = [] # <<<<<<<<<<<<<< + * for (toskip, (i, alt, pathlen)) in frontier: + * spanlen = fwords[i][alt][2] */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_curr_idx); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_curr_idx); - __Pyx_GIVEREF(__pyx_v_curr_idx); - __Pyx_INCREF(__pyx_int_0); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_v_nf = __pyx_t_1; __pyx_t_1 = 0; - __pyx_v_candidate = __pyx_t_2; - __pyx_t_2 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":903 - * candidate = [[curr_idx,0]] - * - * while len(candidate) > 0: # <<<<<<<<<<<<<< - * curr = candidate.pop() - * if curr[0] >= len(_columns): - */ - while (1) { - __pyx_t_3 = PyList_GET_SIZE(((PyObject *)__pyx_v_candidate)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_4 = (__pyx_t_3 > 0); - if (!__pyx_t_4) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":904 - * - * while len(candidate) > 0: - * curr = candidate.pop() # <<<<<<<<<<<<<< - * if curr[0] >= len(_columns): - * continue - */ - __pyx_t_2 = __Pyx_PyObject_Pop(((PyObject *)__pyx_v_candidate)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_v_curr); - __pyx_v_curr = __pyx_t_2; - __pyx_t_2 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":905 - * while len(candidate) > 0: - * curr = candidate.pop() - * if curr[0] >= len(_columns): # <<<<<<<<<<<<<< - * continue - * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: - */ - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Length(__pyx_v__columns); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_4) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":906 - * curr = candidate.pop() - * if curr[0] >= len(_columns): - * continue # <<<<<<<<<<<<<< - * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: - * result.append(curr[0]); - */ - goto __pyx_L3_continue; - goto __pyx_L5; - } - __pyx_L5:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":907 - * if curr[0] >= len(_columns): - * continue - * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: # <<<<<<<<<<<<<< - * result.append(curr[0]); - * curr_col = _columns[curr[0]] - */ - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_result), __pyx_t_5))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_4) { - __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_curr, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_min_dist, __pyx_t_5, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_2, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = __pyx_t_6; - } else { - __pyx_t_7 = __pyx_t_4; - } - if (__pyx_t_7) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":908 - * continue - * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: - * result.append(curr[0]); # <<<<<<<<<<<<<< - * curr_col = _columns[curr[0]] - * for alt in curr_col: - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_8 = PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L6; - } - __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":909 - * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: - * result.append(curr[0]); - * curr_col = _columns[curr[0]] # <<<<<<<<<<<<<< - * for alt in curr_col: - * next_id = curr[0]+alt[2] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":832 + * cdef unsigned na + * nf = [] + * for (toskip, (i, alt, pathlen)) in frontier: # <<<<<<<<<<<<<< + * spanlen = fwords[i][alt][2] + * if (toskip == 0): */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyList_CheckExact(__pyx_v_frontier) || PyTuple_CheckExact(__pyx_v_frontier)) { + __pyx_t_1 = __pyx_v_frontier; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; + __pyx_t_3 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_frontier); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_GetItem(__pyx_v__columns, __pyx_t_1); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_v_curr_col); - __pyx_v_curr_col = __pyx_t_5; - __pyx_t_5 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":910 - * result.append(curr[0]); - * curr_col = _columns[curr[0]] - * for alt in curr_col: # <<<<<<<<<<<<<< - * next_id = curr[0]+alt[2] - * jump = 1 - */ - if (PyList_CheckExact(__pyx_v_curr_col) || PyTuple_CheckExact(__pyx_v_curr_col)) { - __pyx_t_5 = __pyx_v_curr_col; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0; - __pyx_t_9 = NULL; + __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif } else { - __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_curr_col); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; + __pyx_t_4 = __pyx_t_3(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); } - for (;;) { - if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_5)) { - if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_5)) { - if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif + if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { + PyObject* sequence = __pyx_t_4; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); } else { - __pyx_t_1 = __pyx_t_9(__pyx_t_5); - if (unlikely(!__pyx_t_1)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 910; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyList_GET_ITEM(sequence, 0); + __pyx_t_6 = PyList_GET_ITEM(sequence, 1); } - __Pyx_XDECREF(__pyx_v_alt); - __pyx_v_alt = __pyx_t_1; - __pyx_t_1 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":911 - * curr_col = _columns[curr[0]] - * for alt in curr_col: - * next_id = curr[0]+alt[2] # <<<<<<<<<<<<<< - * jump = 1 - * if (alt[0] == EPSILON): - */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_alt, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_t_5); + __Pyx_INCREF(__pyx_t_6); + #else + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; + index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_5); + index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; + __Pyx_GOTREF(__pyx_t_6); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L6_unpacking_done; + __pyx_L5_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L6_unpacking_done:; + } + __Pyx_XDECREF(__pyx_v_toskip); + __pyx_v_toskip = __pyx_t_5; + __pyx_t_5 = 0; + if ((likely(PyTuple_CheckExact(__pyx_t_6))) || (PyList_CheckExact(__pyx_t_6))) { + PyObject* sequence = __pyx_t_6; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_10 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_7 = 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_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_10); + #else + __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_11 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_8 = Py_TYPE(__pyx_t_11)->tp_iternext; + index = 0; __pyx_t_7 = __pyx_t_8(__pyx_t_11); if (unlikely(!__pyx_t_7)) goto __pyx_L7_unpacking_failed; + __Pyx_GOTREF(__pyx_t_7); + index = 1; __pyx_t_9 = __pyx_t_8(__pyx_t_11); if (unlikely(!__pyx_t_9)) goto __pyx_L7_unpacking_failed; + __Pyx_GOTREF(__pyx_t_9); + index = 2; __pyx_t_10 = __pyx_t_8(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L7_unpacking_failed; __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XDECREF(__pyx_v_next_id); - __pyx_v_next_id = __pyx_t_10; - __pyx_t_10 = 0; + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = NULL; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + goto __pyx_L8_unpacking_done; + __pyx_L7_unpacking_failed:; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + __pyx_t_8 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 832; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L8_unpacking_done:; + } + __Pyx_XDECREF(__pyx_v_i); + __pyx_v_i = __pyx_t_7; + __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_v_alt); + __pyx_v_alt = __pyx_t_9; + __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_v_pathlen); + __pyx_v_pathlen = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":912 - * for alt in curr_col: - * next_id = curr[0]+alt[2] - * jump = 1 # <<<<<<<<<<<<<< - * if (alt[0] == EPSILON): - * jump = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":833 + * nf = [] + * for (toskip, (i, alt, pathlen)) in frontier: + * spanlen = fwords[i][alt][2] # <<<<<<<<<<<<<< + * if (toskip == 0): + * res.append((i, alt, pathlen)) */ - __Pyx_INCREF(__pyx_int_1); - __Pyx_XDECREF(__pyx_v_jump); - __pyx_v_jump = __pyx_int_1; + __pyx_t_4 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_i); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyObject_GetItem(__pyx_t_4, __pyx_v_alt); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_6, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 833; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_XDECREF(__pyx_v_spanlen); + __pyx_v_spanlen = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":913 - * next_id = curr[0]+alt[2] - * jump = 1 - * if (alt[0] == EPSILON): # <<<<<<<<<<<<<< - * jump = 0 - * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":834 + * for (toskip, (i, alt, pathlen)) in frontier: + * spanlen = fwords[i][alt][2] + * if (toskip == 0): # <<<<<<<<<<<<<< + * res.append((i, alt, pathlen)) + * ni = i + spanlen */ - __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_alt, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_RichCompare(__pyx_t_10, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { + __pyx_t_4 = PyObject_RichCompare(__pyx_v_toskip, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 834; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_12) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":914 - * jump = 1 - * if (alt[0] == EPSILON): - * jump = 0 # <<<<<<<<<<<<<< - * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: - * candidate.append([next_id,curr[1]+jump]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":835 + * spanlen = fwords[i][alt][2] + * if (toskip == 0): + * res.append((i, alt, pathlen)) # <<<<<<<<<<<<<< + * ni = i + spanlen + * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): */ - __Pyx_INCREF(__pyx_int_0); - __Pyx_DECREF(__pyx_v_jump); - __pyx_v_jump = __pyx_int_0; - goto __pyx_L9; - } - __pyx_L9:; + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + __Pyx_INCREF(__pyx_v_alt); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_alt); + __Pyx_GIVEREF(__pyx_v_alt); + __Pyx_INCREF(__pyx_v_pathlen); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_v_pathlen); + __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_res, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + goto __pyx_L9; + } + __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":915 - * if (alt[0] == EPSILON): - * jump = 0 - * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: # <<<<<<<<<<<<<< - * candidate.append([next_id,curr[1]+jump]) - * return sorted(result); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":836 + * if (toskip == 0): + * res.append((i, alt, pathlen)) + * ni = i + spanlen # <<<<<<<<<<<<<< + * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): + * for na in range(len(fwords[ni])): */ - __pyx_t_7 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_result), __pyx_v_next_id))); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_7) { - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_jump); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_RichCompare(__pyx_v_min_dist, __pyx_t_2, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_10 = PyInt_FromLong((__pyx_v_self->max_initial_size + 1)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_10, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __pyx_t_4; - } else { - __pyx_t_6 = __pyx_t_7; - } - if (__pyx_t_6) { + __pyx_t_6 = PyNumber_Add(__pyx_v_i, __pyx_v_spanlen); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_v_ni); + __pyx_v_ni = __pyx_t_6; + __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":916 - * jump = 0 - * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: - * candidate.append([next_id,curr[1]+jump]) # <<<<<<<<<<<<<< - * return sorted(result); - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":837 + * res.append((i, alt, pathlen)) + * ni = i + spanlen + * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): # <<<<<<<<<<<<<< + * for na in range(len(fwords[ni])): + * nf.append((toskip - 1, (ni, na, pathlen + 1))) */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_jump); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_next_id); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_next_id); - __Pyx_GIVEREF(__pyx_v_next_id); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_8 = PyList_Append(__pyx_v_candidate, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 916; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - goto __pyx_L10; + __pyx_t_13 = PyObject_Length(__pyx_v_fwords); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = PyObject_RichCompare(__pyx_v_ni, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_12) { + __pyx_t_4 = PyNumber_Add(__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_6 = PyInt_FromLong(__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_15 = __pyx_t_14; + } else { + __pyx_t_15 = __pyx_t_12; + } + if (__pyx_t_15) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":838 + * ni = i + spanlen + * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): + * for na in range(len(fwords[ni])): # <<<<<<<<<<<<<< + * nf.append((toskip - 1, (ni, na, pathlen + 1))) + * if (len(nf) > 0): + */ + __pyx_t_5 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ni); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_13 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_13; __pyx_t_16+=1) { + __pyx_v_na = __pyx_t_16; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":839 + * if (ni < len(fwords) and (pathlen + 1) < self.max_initial_size): + * for na in range(len(fwords[ni])): + * nf.append((toskip - 1, (ni, na, pathlen + 1))) # <<<<<<<<<<<<<< + * if (len(nf) > 0): + * return self.advance(nf, res, fwords) + */ + __pyx_t_5 = PyNumber_Subtract(__pyx_v_toskip, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = PyLong_FromUnsignedLong(__pyx_v_na); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_4 = PyNumber_Add(__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_v_ni); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_ni); + __Pyx_GIVEREF(__pyx_v_ni); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_6 = 0; + __pyx_t_4 = 0; + __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_10)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_10)); + __pyx_t_5 = 0; + __pyx_t_10 = 0; + __pyx_t_17 = PyList_Append(__pyx_v_nf, ((PyObject *)__pyx_t_4)); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; } - __pyx_L10:; + goto __pyx_L10; } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_L3_continue:; + __pyx_L10:; } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":917 - * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: - * candidate.append([next_id,curr[1]+jump]) - * return sorted(result); # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":840 + * for na in range(len(fwords[ni])): + * nf.append((toskip - 1, (ni, na, pathlen + 1))) + * if (len(nf) > 0): # <<<<<<<<<<<<<< + * return self.advance(nf, res, fwords) + * else: + */ + __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_nf)); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = (__pyx_t_2 > 0); + if (__pyx_t_15) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":841 + * nf.append((toskip - 1, (ni, na, pathlen + 1))) + * if (len(nf) > 0): + * return self.advance(nf, res, fwords) # <<<<<<<<<<<<<< + * else: + * return res + */ + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__advance); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(((PyObject *)__pyx_v_nf)); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_nf)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_nf)); + __Pyx_INCREF(__pyx_v_res); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_res); + __Pyx_GIVEREF(__pyx_v_res); + __Pyx_INCREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_fwords); + __Pyx_GIVEREF(__pyx_v_fwords); + __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_r = __pyx_t_10; + __pyx_t_10 = 0; + goto __pyx_L0; + goto __pyx_L13; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":843 + * return self.advance(nf, res, fwords) + * else: + * return res # <<<<<<<<<<<<<< * - * def input(self, fwords, models): + * def get_all_nodes_isteps_away(self, skip, i, spanlen, pathlen, fwords, next_states, reachable_buffer): */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_INCREF(((PyObject *)__pyx_v_result)); - PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_result)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_result)); - __pyx_t_1 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_res); + __pyx_r = __pyx_v_res; + goto __pyx_L0; + } + __pyx_L13:; __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_next_states", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.advance", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_candidate); - __Pyx_XDECREF(__pyx_v_curr); - __Pyx_XDECREF(__pyx_v_curr_col); + __Pyx_XDECREF(__pyx_v_nf); + __Pyx_XDECREF(__pyx_v_toskip); + __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_alt); - __Pyx_XDECREF(__pyx_v_next_id); - __Pyx_XDECREF(__pyx_v_jump); + __Pyx_XDECREF(__pyx_v_pathlen); + __Pyx_XDECREF(__pyx_v_spanlen); + __Pyx_XDECREF(__pyx_v_ni); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_3_sa_23HieroCachingRuleFactory_24generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ /* Python wrapper */ -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_23input(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_3_sa_23HieroCachingRuleFactory_22input[] = "When this function is called on the RuleFactory,\n it looks up all of the rules that can be used to translate\n the input sentence"; -static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_23input(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_15get_all_nodes_isteps_away(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_15get_all_nodes_isteps_away(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_skip = 0; + PyObject *__pyx_v_i = 0; + PyObject *__pyx_v_spanlen = 0; + PyObject *__pyx_v_pathlen = 0; PyObject *__pyx_v_fwords = 0; - PyObject *__pyx_v_models = 0; + PyObject *__pyx_v_next_states = 0; + PyObject *__pyx_v_reachable_buffer = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("input (wrapper)", 0); + __Pyx_RefNannySetupContext("get_all_nodes_isteps_away (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fwords,&__pyx_n_s__models,0}; - PyObject* values[2] = {0,0}; + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__skip,&__pyx_n_s__i,&__pyx_n_s__spanlen,&__pyx_n_s__pathlen,&__pyx_n_s__fwords,&__pyx_n_s__next_states,&__pyx_n_s__reachable_buffer,0}; + PyObject* values[7] = {0,0,0,0,0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { + case 7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6); + case 6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); case 0: break; @@ -44403,9192 +44430,9505 @@ static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_23input(PyObject *__pyx kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__skip)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__models)) != 0)) kw_args--; + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__i)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__spanlen)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 3: + if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pathlen)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 3); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 4: + if (likely((values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 4); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 5: + if (likely((values[5] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__next_states)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 5); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 6: + if (likely((values[6] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reachable_buffer)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("input", 1, 2, 2, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, 6); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "input") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_all_nodes_isteps_away") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { + } else if (PyTuple_GET_SIZE(__pyx_args) != 7) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + values[3] = PyTuple_GET_ITEM(__pyx_args, 3); + values[4] = PyTuple_GET_ITEM(__pyx_args, 4); + values[5] = PyTuple_GET_ITEM(__pyx_args, 5); + values[6] = PyTuple_GET_ITEM(__pyx_args, 6); } - __pyx_v_fwords = values[0]; - __pyx_v_models = values[1]; + __pyx_v_skip = values[0]; + __pyx_v_i = values[1]; + __pyx_v_spanlen = values[2]; + __pyx_v_pathlen = values[3]; + __pyx_v_fwords = values[4]; + __pyx_v_next_states = values[5]; + __pyx_v_reachable_buffer = values[6]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("input", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("get_all_nodes_isteps_away", 1, 7, 7, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.input", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_all_nodes_isteps_away", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_22input(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fwords, __pyx_v_models); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_14get_all_nodes_isteps_away(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_skip, __pyx_v_i, __pyx_v_spanlen, __pyx_v_pathlen, __pyx_v_fwords, __pyx_v_next_states, __pyx_v_reachable_buffer); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":919 - * return sorted(result); +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":845 + * return res * - * def input(self, fwords, models): # <<<<<<<<<<<<<< - * '''When this function is called on the RuleFactory, - * it looks up all of the rules that can be used to translate + * def get_all_nodes_isteps_away(self, skip, i, spanlen, pathlen, fwords, next_states, reachable_buffer): # <<<<<<<<<<<<<< + * cdef unsigned alt_it + * frontier = [] */ -static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_22input(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_models) { - struct __pyx_obj_3_sa___pyx_scope_struct_4_input *__pyx_cur_scope; +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_14get_all_nodes_isteps_away(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_skip, PyObject *__pyx_v_i, PyObject *__pyx_v_spanlen, PyObject *__pyx_v_pathlen, PyObject *__pyx_v_fwords, PyObject *__pyx_v_next_states, PyObject *__pyx_v_reachable_buffer) { + PyObject *__pyx_v_frontier = NULL; + PyObject *__pyx_v_key = NULL; + PyObject *__pyx_v_reachable = NULL; + PyObject *__pyx_v_nextreachable = NULL; + PyObject *__pyx_v_next_id = NULL; + PyObject *__pyx_v_jump = NULL; + PyObject *__pyx_v_alt_id = NULL; + PyObject *__pyx_v_newel = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + PyObject *__pyx_t_4 = NULL; + int __pyx_t_5; + PyObject *(*__pyx_t_6)(PyObject *); + Py_ssize_t __pyx_t_7; + PyObject *(*__pyx_t_8)(PyObject *); + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + Py_ssize_t __pyx_t_11; + PyObject *(*__pyx_t_12)(PyObject *); + PyObject *__pyx_t_13 = NULL; + int __pyx_t_14; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("input", 0); - __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_4_input *)__pyx_ptype_3_sa___pyx_scope_struct_4_input->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_4_input, __pyx_empty_tuple, NULL); - if (unlikely(!__pyx_cur_scope)) { - __Pyx_RefNannyFinishContext(); - return NULL; - } - __Pyx_GOTREF(__pyx_cur_scope); - __pyx_cur_scope->__pyx_v_self = __pyx_v_self; - __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - __pyx_cur_scope->__pyx_v_fwords = __pyx_v_fwords; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fwords); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fwords); - __pyx_cur_scope->__pyx_v_models = __pyx_v_models; - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_models); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_models); - { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_23HieroCachingRuleFactory_24generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_cur_scope); - __Pyx_RefNannyFinishContext(); - return (PyObject *) gen; - } + __Pyx_RefNannySetupContext("get_all_nodes_isteps_away", 0); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.input", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":847 + * def get_all_nodes_isteps_away(self, skip, i, spanlen, pathlen, fwords, next_states, reachable_buffer): + * cdef unsigned alt_it + * frontier = [] # <<<<<<<<<<<<<< + * if (i+spanlen+skip >= len(next_states)): + * return frontier + */ + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_frontier = __pyx_t_1; + __pyx_t_1 = 0; -static PyObject *__pyx_gb_3_sa_23HieroCachingRuleFactory_24generator2(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ -{ - struct __pyx_obj_3_sa___pyx_scope_struct_4_input *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_4_input *)__pyx_generator->closure); - PyObject *__pyx_r = NULL; - Py_ssize_t __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - Py_ssize_t __pyx_t_5; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - PyObject *__pyx_t_10 = NULL; - int __pyx_t_11; - PyObject *__pyx_t_12 = NULL; - PyObject *__pyx_t_13 = NULL; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *__pyx_t_16 = NULL; - PyObject *(*__pyx_t_17)(PyObject *); - int __pyx_t_18; - int __pyx_t_19; - float __pyx_t_20; - Py_ssize_t __pyx_t_21; - Py_ssize_t __pyx_t_22; - Py_ssize_t __pyx_t_23; - Py_ssize_t __pyx_t_24; - Py_ssize_t __pyx_t_25; - int __pyx_t_26; - PyObject *(*__pyx_t_27)(PyObject *); - int __pyx_t_28; - int __pyx_t_29; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("None", 0); - switch (__pyx_generator->resume_label) { - case 0: goto __pyx_L3_first_run; - case 1: goto __pyx_L59_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[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":930 - * cdef Phrase hiero_phrase - * - * flen = len(fwords) # <<<<<<<<<<<<<< - * start_time = monitor_cpu() - * self.extract_time = 0.0 - */ - __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_cur_scope->__pyx_v_flen = __pyx_t_1; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":931 - * - * flen = len(fwords) - * start_time = monitor_cpu() # <<<<<<<<<<<<<< - * self.extract_time = 0.0 - * nodes_isteps_away_buffer = {} - */ - __pyx_cur_scope->__pyx_v_start_time = __pyx_f_3_sa_monitor_cpu(); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":932 - * flen = len(fwords) - * start_time = monitor_cpu() - * self.extract_time = 0.0 # <<<<<<<<<<<<<< - * nodes_isteps_away_buffer = {} - * hit = 0 - */ - __pyx_cur_scope->__pyx_v_self->extract_time = 0.0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":933 - * start_time = monitor_cpu() - * self.extract_time = 0.0 - * nodes_isteps_away_buffer = {} # <<<<<<<<<<<<<< - * hit = 0 - * reachable_buffer = {} - */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 933; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - __pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer = __pyx_t_2; - __pyx_t_2 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":934 - * self.extract_time = 0.0 - * nodes_isteps_away_buffer = {} - * hit = 0 # <<<<<<<<<<<<<< - * reachable_buffer = {} - * - */ - __pyx_cur_scope->__pyx_v_hit = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":935 - * nodes_isteps_away_buffer = {} - * hit = 0 - * reachable_buffer = {} # <<<<<<<<<<<<<< - * - * # Do not cache between sentences - */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - __pyx_cur_scope->__pyx_v_reachable_buffer = __pyx_t_2; - __pyx_t_2 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":938 - * - * # Do not cache between sentences - * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) # <<<<<<<<<<<<<< - * - * frontier = [] - */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->rules->root); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->rules->root); - __pyx_cur_scope->__pyx_v_self->rules->root = __pyx_t_3; - __pyx_t_3 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":940 - * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) - * - * frontier = [] # <<<<<<<<<<<<<< - * for i in range(len(fwords)): - * for alt in range(0, len(fwords[i])): - */ - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_cur_scope->__pyx_v_frontier = __pyx_t_3; - __pyx_t_3 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":941 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":848 + * cdef unsigned alt_it * frontier = [] - * for i in range(len(fwords)): # <<<<<<<<<<<<<< - * for alt in range(0, len(fwords[i])): - * if fwords[i][alt][0] != EPSILON: + * if (i+spanlen+skip >= len(next_states)): # <<<<<<<<<<<<<< + * return frontier + * key = tuple([i,spanlen]) */ - __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 941; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) { - __pyx_cur_scope->__pyx_v_i = __pyx_t_4; + __pyx_t_1 = PyNumber_Add(__pyx_v_i, __pyx_v_spanlen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_skip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_3 = PyObject_Length(__pyx_v_next_states); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 848; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":942 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":849 * frontier = [] - * for i in range(len(fwords)): - * for alt in range(0, len(fwords[i])): # <<<<<<<<<<<<<< - * if fwords[i][alt][0] != EPSILON: - * frontier.append((i, i, alt, 0, self.rules.root, (), False)) - */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_cur_scope->__pyx_v_alt = __pyx_t_6; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":943 - * for i in range(len(fwords)): - * for alt in range(0, len(fwords[i])): - * if fwords[i][alt][0] != EPSILON: # <<<<<<<<<<<<<< - * frontier.append((i, i, alt, 0, self.rules.root, (), False)) - * - */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":944 - * for alt in range(0, len(fwords[i])): - * if fwords[i][alt][0] != EPSILON: - * frontier.append((i, i, alt, 0, self.rules.root, (), False)) # <<<<<<<<<<<<<< - * - * xroot = None + * if (i+spanlen+skip >= len(next_states)): + * return frontier # <<<<<<<<<<<<<< + * key = tuple([i,spanlen]) + * reachable = [] */ - __pyx_t_7 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - __Pyx_INCREF(__pyx_int_0); - PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_int_0); - __Pyx_GIVEREF(__pyx_int_0); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->rules->root); - PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_cur_scope->__pyx_v_self->rules->root); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->rules->root); - __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); - PyTuple_SET_ITEM(__pyx_t_10, 5, ((PyObject *)__pyx_empty_tuple)); - __Pyx_GIVEREF(((PyObject *)__pyx_empty_tuple)); - PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_7 = 0; - __pyx_t_2 = 0; - __pyx_t_3 = 0; - __pyx_t_9 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_frontier, ((PyObject *)__pyx_t_10)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - goto __pyx_L8; - } - __pyx_L8:; - } + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_frontier)); + __pyx_r = ((PyObject *)__pyx_v_frontier); + goto __pyx_L0; + goto __pyx_L3; } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":946 - * frontier.append((i, i, alt, 0, self.rules.root, (), False)) - * - * xroot = None # <<<<<<<<<<<<<< - * x1 = sym_setindex(self.category, 1) - * if x1 in self.rules.root.children: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":850 + * if (i+spanlen+skip >= len(next_states)): + * return frontier + * key = tuple([i,spanlen]) # <<<<<<<<<<<<<< + * reachable = [] + * if (key in reachable_buffer): */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __pyx_cur_scope->__pyx_v_xroot = Py_None; + __pyx_t_4 = PyList_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_i); + PyList_SET_ITEM(__pyx_t_4, 0, __pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + __Pyx_INCREF(__pyx_v_spanlen); + PyList_SET_ITEM(__pyx_t_4, 1, __pyx_v_spanlen); + __Pyx_GIVEREF(__pyx_v_spanlen); + __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __pyx_v_key = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":947 - * - * xroot = None - * x1 = sym_setindex(self.category, 1) # <<<<<<<<<<<<<< - * if x1 in self.rules.root.children: - * xroot = self.rules.root.children[x1] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":851 + * return frontier + * key = tuple([i,spanlen]) + * reachable = [] # <<<<<<<<<<<<<< + * if (key in reachable_buffer): + * reachable = reachable_buffer[key] */ - __pyx_cur_scope->__pyx_v_x1 = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, 1); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_reachable = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":948 - * xroot = None - * x1 = sym_setindex(self.category, 1) - * if x1 in self.rules.root.children: # <<<<<<<<<<<<<< - * xroot = self.rules.root.children[x1] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":852 + * key = tuple([i,spanlen]) + * reachable = [] + * if (key in reachable_buffer): # <<<<<<<<<<<<<< + * reachable = reachable_buffer[key] * else: */ - __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_x1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_self->rules->root, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_8 = ((PySequence_Contains(__pyx_t_9, __pyx_t_10))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (__pyx_t_8) { + __pyx_t_5 = ((PySequence_Contains(__pyx_v_reachable_buffer, ((PyObject *)__pyx_v_key)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":949 - * x1 = sym_setindex(self.category, 1) - * if x1 in self.rules.root.children: - * xroot = self.rules.root.children[x1] # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":853 + * reachable = [] + * if (key in reachable_buffer): + * reachable = reachable_buffer[key] # <<<<<<<<<<<<<< * else: - * xroot = ExtendedTrieNode(suffix_link=self.rules.root, phrase_location=PhraseLocation()) + * reachable = self.reachable(fwords, i, spanlen) */ - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_self->rules->root, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_x1, sizeof(int), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_xroot); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_xroot); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_xroot = __pyx_t_10; - __pyx_t_10 = 0; - goto __pyx_L9; + __pyx_t_1 = PyObject_GetItem(__pyx_v_reachable_buffer, ((PyObject *)__pyx_v_key)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_v_reachable); + __pyx_v_reachable = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L4; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":951 - * xroot = self.rules.root.children[x1] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":855 + * reachable = reachable_buffer[key] * else: - * xroot = ExtendedTrieNode(suffix_link=self.rules.root, phrase_location=PhraseLocation()) # <<<<<<<<<<<<<< - * self.rules.root.children[x1] = xroot - * + * reachable = self.reachable(fwords, i, spanlen) # <<<<<<<<<<<<<< + * reachable_buffer[key] = reachable + * for nextreachable in reachable: */ - __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__suffix_link), __pyx_cur_scope->__pyx_v_self->rules->root) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_xroot); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_xroot); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_cur_scope->__pyx_v_xroot = __pyx_t_9; - __pyx_t_9 = 0; + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reachable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_INCREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fwords); + __Pyx_GIVEREF(__pyx_v_fwords); + __Pyx_INCREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + __Pyx_INCREF(__pyx_v_spanlen); + PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_v_spanlen); + __Pyx_GIVEREF(__pyx_v_spanlen); + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 855; __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_4)); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_v_reachable); + __pyx_v_reachable = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":952 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":856 * else: - * xroot = ExtendedTrieNode(suffix_link=self.rules.root, phrase_location=PhraseLocation()) - * self.rules.root.children[x1] = xroot # <<<<<<<<<<<<<< - * - * for i in range(self.min_gap_size, len(fwords)): + * reachable = self.reachable(fwords, i, spanlen) + * reachable_buffer[key] = reachable # <<<<<<<<<<<<<< + * for nextreachable in reachable: + * for next_id in next_states[nextreachable]: */ - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_self->rules->root, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - if (__Pyx_SetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_x1, __pyx_cur_scope->__pyx_v_xroot, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (PyObject_SetItem(__pyx_v_reachable_buffer, ((PyObject *)__pyx_v_key), __pyx_v_reachable) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_L9:; + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":954 - * self.rules.root.children[x1] = xroot - * - * for i in range(self.min_gap_size, len(fwords)): # <<<<<<<<<<<<<< - * for alt in range(0, len(fwords[i])): - * if fwords[i][alt][0] != EPSILON: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":857 + * reachable = self.reachable(fwords, i, spanlen) + * reachable_buffer[key] = reachable + * for nextreachable in reachable: # <<<<<<<<<<<<<< + * for next_id in next_states[nextreachable]: + * jump = self.shortest(fwords,i,next_id) */ - __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - for (__pyx_t_4 = __pyx_cur_scope->__pyx_v_self->min_gap_size; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) { - __pyx_cur_scope->__pyx_v_i = __pyx_t_4; + if (PyList_CheckExact(__pyx_v_reachable) || PyTuple_CheckExact(__pyx_v_reachable)) { + __pyx_t_2 = __pyx_v_reachable; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; + __pyx_t_6 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_reachable); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + for (;;) { + if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_6(__pyx_t_2); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_nextreachable); + __pyx_v_nextreachable = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":955 - * - * for i in range(self.min_gap_size, len(fwords)): - * for alt in range(0, len(fwords[i])): # <<<<<<<<<<<<<< - * if fwords[i][alt][0] != EPSILON: - * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":858 + * reachable_buffer[key] = reachable + * for nextreachable in reachable: + * for next_id in next_states[nextreachable]: # <<<<<<<<<<<<<< + * jump = self.shortest(fwords,i,next_id) + * if jump < skip: */ - __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_cur_scope->__pyx_v_alt = __pyx_t_6; + __pyx_t_4 = PyObject_GetItem(__pyx_v_next_states, __pyx_v_nextreachable); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { + __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; + __pyx_t_8 = NULL; + } else { + __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + for (;;) { + if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_4); __pyx_t_7++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_8(__pyx_t_1); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_next_id); + __pyx_v_next_id = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":956 - * for i in range(self.min_gap_size, len(fwords)): - * for alt in range(0, len(fwords[i])): - * if fwords[i][alt][0] != EPSILON: # <<<<<<<<<<<<<< - * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":859 + * for nextreachable in reachable: + * for next_id in next_states[nextreachable]: + * jump = self.shortest(fwords,i,next_id) # <<<<<<<<<<<<<< + * if jump < skip: + * continue */ - __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__shortest); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_fwords); + __Pyx_GIVEREF(__pyx_v_fwords); + __Pyx_INCREF(__pyx_v_i); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_v_i); + __Pyx_GIVEREF(__pyx_v_i); + __Pyx_INCREF(__pyx_v_next_id); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_v_next_id); + __Pyx_GIVEREF(__pyx_v_next_id); + __pyx_t_10 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_10, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_v_jump); + __pyx_v_jump = __pyx_t_10; + __pyx_t_10 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":860 + * for next_id in next_states[nextreachable]: + * jump = self.shortest(fwords,i,next_id) + * if jump < skip: # <<<<<<<<<<<<<< + * continue + * if pathlen+jump <= self.max_initial_size: + */ + __pyx_t_10 = PyObject_RichCompare(__pyx_v_jump, __pyx_v_skip, Py_LT); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_9, __pyx_t_10, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_8) { + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":957 - * for alt in range(0, len(fwords[i])): - * if fwords[i][alt][0] != EPSILON: - * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) # <<<<<<<<<<<<<< - * - * next_states = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":861 + * jump = self.shortest(fwords,i,next_id) + * if jump < skip: + * continue # <<<<<<<<<<<<<< + * if pathlen+jump <= self.max_initial_size: + * for alt_id in range(len(fwords[next_id])): */ - __pyx_t_3 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_i - __pyx_cur_scope->__pyx_v_self->min_gap_size)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_x1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_13 = PyTuple_New(7); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_xroot); - PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_cur_scope->__pyx_v_xroot); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_xroot); - PyTuple_SET_ITEM(__pyx_t_13, 5, ((PyObject *)__pyx_t_12)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_12)); - PyTuple_SET_ITEM(__pyx_t_13, 6, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - __pyx_t_3 = 0; - __pyx_t_10 = 0; - __pyx_t_9 = 0; - __pyx_t_2 = 0; - __pyx_t_12 = 0; - __pyx_t_7 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_frontier, ((PyObject *)__pyx_t_13)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0; - goto __pyx_L14; + goto __pyx_L7_continue; + goto __pyx_L9; } - __pyx_L14:; - } - } + __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":959 - * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) - * - * next_states = [] # <<<<<<<<<<<<<< - * for i in range(len(fwords)): - * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":862 + * if jump < skip: + * continue + * if pathlen+jump <= self.max_initial_size: # <<<<<<<<<<<<<< + * for alt_id in range(len(fwords[next_id])): + * if (fwords[next_id][alt_id][0] != EPSILON): */ - __pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - __Pyx_GIVEREF(((PyObject *)__pyx_t_13)); - __pyx_cur_scope->__pyx_v_next_states = __pyx_t_13; - __pyx_t_13 = 0; + __pyx_t_10 = PyNumber_Add(__pyx_v_pathlen, __pyx_v_jump); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyInt_FromLong(__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_4 = PyObject_RichCompare(__pyx_t_10, __pyx_t_9, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":960 - * - * next_states = [] - * for i in range(len(fwords)): # <<<<<<<<<<<<<< - * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":863 + * continue + * if pathlen+jump <= self.max_initial_size: + * for alt_id in range(len(fwords[next_id])): # <<<<<<<<<<<<<< + * if (fwords[next_id][alt_id][0] != EPSILON): + * newel = (next_id,alt_id,pathlen+jump) */ - __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) { - __pyx_cur_scope->__pyx_v_i = __pyx_t_4; + __pyx_t_4 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_next_id); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_11 = PyObject_Length(__pyx_t_4); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); + __Pyx_GIVEREF(__pyx_t_4); + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) { + __pyx_t_9 = __pyx_t_4; __Pyx_INCREF(__pyx_t_9); __pyx_t_11 = 0; + __pyx_t_12 = NULL; + } else { + __pyx_t_11 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_12 = Py_TYPE(__pyx_t_9)->tp_iternext; + } + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + for (;;) { + if (!__pyx_t_12 && PyList_CheckExact(__pyx_t_9)) { + if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_9)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_12 && PyTuple_CheckExact(__pyx_t_9)) { + if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_9)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++; + #else + __pyx_t_4 = PySequence_ITEM(__pyx_t_9, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_4 = __pyx_t_12(__pyx_t_9); + if (unlikely(!__pyx_t_4)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 863; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_4); + } + __Pyx_XDECREF(__pyx_v_alt_id); + __pyx_v_alt_id = __pyx_t_4; + __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":961 - * next_states = [] - * for i in range(len(fwords)): - * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) # <<<<<<<<<<<<<< - * - * while len(frontier) > 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":864 + * if pathlen+jump <= self.max_initial_size: + * for alt_id in range(len(fwords[next_id])): + * if (fwords[next_id][alt_id][0] != EPSILON): # <<<<<<<<<<<<<< + * newel = (next_id,alt_id,pathlen+jump) + * if newel not in frontier: */ - __pyx_t_13 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__get_next_states); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_13); - __pyx_t_7 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_12 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_fwords); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_12); - __Pyx_GIVEREF(__pyx_t_12); - __pyx_t_7 = 0; - __pyx_t_12 = 0; - __pyx_t_12 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_next_states, __pyx_t_12); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - } + __pyx_t_4 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_next_id); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_10 = PyObject_GetItem(__pyx_t_4, __pyx_v_alt_id); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_10, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_13 = PyObject_RichCompare(__pyx_t_4, __pyx_t_10, Py_NE); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":963 - * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) - * - * while len(frontier) > 0: # <<<<<<<<<<<<<< - * new_frontier = [] - * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":865 + * for alt_id in range(len(fwords[next_id])): + * if (fwords[next_id][alt_id][0] != EPSILON): + * newel = (next_id,alt_id,pathlen+jump) # <<<<<<<<<<<<<< + * if newel not in frontier: + * frontier.append((next_id,alt_id,pathlen+jump)) */ - while (1) { - __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_frontier)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = (__pyx_t_1 > 0); - if (!__pyx_t_8) break; + __pyx_t_13 = PyNumber_Add(__pyx_v_pathlen, __pyx_v_jump); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_v_next_id); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_next_id); + __Pyx_GIVEREF(__pyx_v_next_id); + __Pyx_INCREF(__pyx_v_alt_id); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_alt_id); + __Pyx_GIVEREF(__pyx_v_alt_id); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_13); + __Pyx_GIVEREF(__pyx_t_13); + __pyx_t_13 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_newel)); + __pyx_v_newel = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":964 - * - * while len(frontier) > 0: - * new_frontier = [] # <<<<<<<<<<<<<< - * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: - * word_id = fwords[i][alt][0] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":866 + * if (fwords[next_id][alt_id][0] != EPSILON): + * newel = (next_id,alt_id,pathlen+jump) + * if newel not in frontier: # <<<<<<<<<<<<<< + * frontier.append((next_id,alt_id,pathlen+jump)) + * return frontier */ - __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_12)); - __pyx_cur_scope->__pyx_v_new_frontier = __pyx_t_12; - __pyx_t_12 = 0; + __pyx_t_5 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_frontier), ((PyObject *)__pyx_v_newel)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":965 - * while len(frontier) > 0: - * new_frontier = [] - * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: # <<<<<<<<<<<<<< - * word_id = fwords[i][alt][0] - * spanlen = fwords[i][alt][2] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":867 + * newel = (next_id,alt_id,pathlen+jump) + * if newel not in frontier: + * frontier.append((next_id,alt_id,pathlen+jump)) # <<<<<<<<<<<<<< + * return frontier + * */ - __pyx_t_12 = ((PyObject *)__pyx_cur_scope->__pyx_v_frontier); __Pyx_INCREF(__pyx_t_12); __pyx_t_1 = 0; - for (;;) { - if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_12)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; - #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_12, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 7)) { - if (size > 7) __Pyx_RaiseTooManyValuesError(7); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_13 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 4); - __pyx_t_14 = PyTuple_GET_ITEM(sequence, 5); - __pyx_t_15 = PyTuple_GET_ITEM(sequence, 6); - } else { - __pyx_t_13 = PyList_GET_ITEM(sequence, 0); - __pyx_t_7 = PyList_GET_ITEM(sequence, 1); - __pyx_t_9 = PyList_GET_ITEM(sequence, 2); - __pyx_t_10 = PyList_GET_ITEM(sequence, 3); - __pyx_t_3 = PyList_GET_ITEM(sequence, 4); - __pyx_t_14 = PyList_GET_ITEM(sequence, 5); - __pyx_t_15 = PyList_GET_ITEM(sequence, 6); + __pyx_t_10 = PyNumber_Add(__pyx_v_pathlen, __pyx_v_jump); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_13 = PyTuple_New(3); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_INCREF(__pyx_v_next_id); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_v_next_id); + __Pyx_GIVEREF(__pyx_v_next_id); + __Pyx_INCREF(__pyx_v_alt_id); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_v_alt_id); + __Pyx_GIVEREF(__pyx_v_alt_id); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_14 = PyList_Append(__pyx_v_frontier, ((PyObject *)__pyx_t_13)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0; + goto __pyx_L14; + } + __pyx_L14:; + goto __pyx_L13; + } + __pyx_L13:; } - __Pyx_INCREF(__pyx_t_13); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(__pyx_t_15); - #else - Py_ssize_t i; - PyObject** temps[7] = {&__pyx_t_13,&__pyx_t_7,&__pyx_t_9,&__pyx_t_10,&__pyx_t_3,&__pyx_t_14,&__pyx_t_15}; - for (i=0; i < 7; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - *(temps[i]) = item; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L10; + } + __pyx_L10:; + __pyx_L7_continue:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":868 + * if newel not in frontier: + * frontier.append((next_id,alt_id,pathlen+jump)) + * return frontier # <<<<<<<<<<<<<< + * + * def reachable(self, fwords, ifrom, dist): + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_frontier)); + __pyx_r = ((PyObject *)__pyx_v_frontier); + 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_4); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_all_nodes_isteps_away", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_frontier); + __Pyx_XDECREF(__pyx_v_key); + __Pyx_XDECREF(__pyx_v_reachable); + __Pyx_XDECREF(__pyx_v_nextreachable); + __Pyx_XDECREF(__pyx_v_next_id); + __Pyx_XDECREF(__pyx_v_jump); + __Pyx_XDECREF(__pyx_v_alt_id); + __Pyx_XDECREF(__pyx_v_newel); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_17reachable(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_17reachable(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_fwords = 0; + PyObject *__pyx_v_ifrom = 0; + PyObject *__pyx_v_dist = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("reachable (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fwords,&__pyx_n_s__ifrom,&__pyx_n_s__dist,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ifrom)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("reachable", 1, 3, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - { - Py_ssize_t index = -1; - PyObject** temps[7] = {&__pyx_t_13,&__pyx_t_7,&__pyx_t_9,&__pyx_t_10,&__pyx_t_3,&__pyx_t_14,&__pyx_t_15}; - __pyx_t_16 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_16); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_17 = Py_TYPE(__pyx_t_16)->tp_iternext; - for (index=0; index < 7; index++) { - PyObject* item = __pyx_t_17(__pyx_t_16); if (unlikely(!item)) goto __pyx_L21_unpacking_failed; - __Pyx_GOTREF(item); - *(temps[index]) = item; + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__dist)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("reachable", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_16), 7) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_17 = NULL; - __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; - goto __pyx_L22_unpacking_done; - __pyx_L21_unpacking_failed:; - __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; - __pyx_t_17 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L22_unpacking_done:; } - __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_13); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_cur_scope->__pyx_v_k = __pyx_t_4; - __pyx_cur_scope->__pyx_v_i = __pyx_t_6; - __pyx_cur_scope->__pyx_v_alt = __pyx_t_18; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_pathlen = __pyx_t_10; - __pyx_t_10 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_node = __pyx_t_3; - __pyx_t_3 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_prefix); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_prefix); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_cur_scope->__pyx_v_prefix = __pyx_t_14; - __pyx_t_14 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_is_shadow_path = __pyx_t_15; - __pyx_t_15 = 0; + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "reachable") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_fwords = values[0]; + __pyx_v_ifrom = values[1]; + __pyx_v_dist = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("reachable", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.reachable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_16reachable(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fwords, __pyx_v_ifrom, __pyx_v_dist); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":966 - * new_frontier = [] - * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: - * word_id = fwords[i][alt][0] # <<<<<<<<<<<<<< - * spanlen = fwords[i][alt][2] - * # TODO get rid of k -- pathlen is replacing it +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":870 + * return frontier + * + * def reachable(self, fwords, ifrom, dist): # <<<<<<<<<<<<<< + * ret = [] + * if (ifrom >= len(fwords)): */ - __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_2, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_15, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_word_id); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_word_id); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_word_id = __pyx_t_2; - __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":967 - * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: - * word_id = fwords[i][alt][0] - * spanlen = fwords[i][alt][2] # <<<<<<<<<<<<<< - * # TODO get rid of k -- pathlen is replacing it - * if word_id == EPSILON: - */ - __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_2, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_15, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_spanlen); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_spanlen); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_spanlen = __pyx_t_2; - __pyx_t_2 = 0; +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_16reachable(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_ifrom, PyObject *__pyx_v_dist) { + PyObject *__pyx_v_ret = NULL; + PyObject *__pyx_v_alt_id = NULL; + PyObject *__pyx_v_ifromchild = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; + int __pyx_t_9; + Py_ssize_t __pyx_t_10; + PyObject *(*__pyx_t_11)(PyObject *); + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("reachable", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":969 - * spanlen = fwords[i][alt][2] - * # TODO get rid of k -- pathlen is replacing it - * if word_id == EPSILON: # <<<<<<<<<<<<<< - * # skipping because word_id is epsilon - * if i+spanlen >= len(fwords): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":871 + * + * def reachable(self, fwords, ifrom, dist): + * ret = [] # <<<<<<<<<<<<<< + * if (ifrom >= len(fwords)): + * return ret */ - __pyx_t_2 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_word_id, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (__pyx_t_8) { + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_ret = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":971 - * if word_id == EPSILON: - * # skipping because word_id is epsilon - * if i+spanlen >= len(fwords): # <<<<<<<<<<<<<< - * continue - * for nualt in range(0,len(fwords[i+spanlen])): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":872 + * def reachable(self, fwords, ifrom, dist): + * ret = [] + * if (ifrom >= len(fwords)): # <<<<<<<<<<<<<< + * return ret + * for alt_id in range(len(fwords[ifrom])): */ - __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_2 = PyNumber_Add(__pyx_t_15, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_5 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_15 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_14 = PyObject_RichCompare(__pyx_t_2, __pyx_t_15, Py_GE); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - if (__pyx_t_8) { + __pyx_t_2 = PyObject_Length(__pyx_v_fwords); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_RichCompare(__pyx_v_ifrom, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":972 - * # skipping because word_id is epsilon - * if i+spanlen >= len(fwords): - * continue # <<<<<<<<<<<<<< - * for nualt in range(0,len(fwords[i+spanlen])): - * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":873 + * ret = [] + * if (ifrom >= len(fwords)): + * return ret # <<<<<<<<<<<<<< + * for alt_id in range(len(fwords[ifrom])): + * if (fwords[ifrom][alt_id][0] == EPSILON): */ - goto __pyx_L19_continue; - goto __pyx_L24; - } - __pyx_L24:; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_ret)); + __pyx_r = ((PyObject *)__pyx_v_ret); + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":973 - * if i+spanlen >= len(fwords): - * continue - * for nualt in range(0,len(fwords[i+spanlen])): # <<<<<<<<<<<<<< - * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) - * continue - */ - __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = PyNumber_Add(__pyx_t_14, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fwords, __pyx_t_15); if (!__pyx_t_14) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_5 = PyObject_Length(__pyx_t_14); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_5; __pyx_t_18+=1) { - __pyx_cur_scope->__pyx_v_nualt = __pyx_t_18; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":974 - * continue - * for nualt in range(0,len(fwords[i+spanlen])): - * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) # <<<<<<<<<<<<<< - * continue - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":874 + * if (ifrom >= len(fwords)): + * return ret + * for alt_id in range(len(fwords[ifrom])): # <<<<<<<<<<<<<< + * if (fwords[ifrom][alt_id][0] == EPSILON): + * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) */ - __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_k); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_2 = PyNumber_Add(__pyx_t_15, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_nualt); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); - PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_cur_scope->__pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_node); - PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_cur_scope->__pyx_v_node); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_prefix); - PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_cur_scope->__pyx_v_prefix); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_prefix); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_cur_scope->__pyx_v_is_shadow_path); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - __pyx_t_14 = 0; - __pyx_t_2 = 0; - __pyx_t_15 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_frontier, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __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[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_builtin_range, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__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_2 = 0; + __pyx_t_5 = NULL; + } else { + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __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_2 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_3 = __pyx_t_5(__pyx_t_1); + if (unlikely(!__pyx_t_3)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":975 - * for nualt in range(0,len(fwords[i+spanlen])): - * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) - * continue # <<<<<<<<<<<<<< - * - * phrase = prefix + (word_id,) - */ - goto __pyx_L19_continue; - goto __pyx_L23; + break; } - __pyx_L23:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":977 - * continue - * - * phrase = prefix + (word_id,) # <<<<<<<<<<<<<< - * hiero_phrase = Phrase(phrase) - * arity = hiero_phrase.arity() - */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_word_id); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_word_id); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_word_id); - __pyx_t_15 = PyNumber_Add(__pyx_cur_scope->__pyx_v_prefix, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_phrase); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_phrase); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_phrase = __pyx_t_15; - __pyx_t_15 = 0; + } + __Pyx_XDECREF(__pyx_v_alt_id); + __pyx_v_alt_id = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":978 - * - * phrase = prefix + (word_id,) - * hiero_phrase = Phrase(phrase) # <<<<<<<<<<<<<< - * arity = hiero_phrase.arity() - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":875 + * return ret + * for alt_id in range(len(fwords[ifrom])): + * if (fwords[ifrom][alt_id][0] == EPSILON): # <<<<<<<<<<<<<< + * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) + * else: */ - __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_phrase); - PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_cur_scope->__pyx_v_phrase); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_phrase); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_hiero_phrase = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyObject_GetItem(__pyx_t_3, __pyx_v_alt_id); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_6, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":979 - * phrase = prefix + (word_id,) - * hiero_phrase = Phrase(phrase) - * arity = hiero_phrase.arity() # <<<<<<<<<<<<<< - * - * lookup_required = False + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":876 + * for alt_id in range(len(fwords[ifrom])): + * if (fwords[ifrom][alt_id][0] == EPSILON): + * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) # <<<<<<<<<<<<<< + * else: + * if (dist==0): */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase), __pyx_n_s__arity); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_ret), __pyx_n_s__extend); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reachable); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_15 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); + __pyx_t_8 = PyObject_GetItem(__pyx_t_3, __pyx_v_alt_id); if (!__pyx_t_8) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_15); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_cur_scope->__pyx_v_arity = __pyx_t_18; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":981 - * arity = hiero_phrase.arity() - * - * lookup_required = False # <<<<<<<<<<<<<< - * if word_id in node.children: - * if node.children[word_id] is None: - */ - __pyx_cur_scope->__pyx_v_lookup_required = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":982 - * - * lookup_required = False - * if word_id in node.children: # <<<<<<<<<<<<<< - * if node.children[word_id] is None: - * # Path dead-ends at this node - */ - __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_8 = ((PySequence_Contains(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (__pyx_t_8) { + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_8, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_8 = PyNumber_Add(__pyx_v_ifrom, __pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fwords); + __Pyx_GIVEREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __Pyx_INCREF(__pyx_v_dist); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_dist); + __Pyx_GIVEREF(__pyx_v_dist); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8); + __Pyx_GIVEREF(__pyx_t_8); + __pyx_t_8 = 0; + __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + goto __pyx_L6; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":983 - * lookup_required = False - * if word_id in node.children: - * if node.children[word_id] is None: # <<<<<<<<<<<<<< - * # Path dead-ends at this node - * continue + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":878 + * ret.extend(self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist)) + * else: + * if (dist==0): # <<<<<<<<<<<<<< + * if (ifrom not in ret): + * ret.append(ifrom) */ - __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_3 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_8 = (__pyx_t_3 == Py_None); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_8) { + __pyx_t_8 = PyObject_RichCompare(__pyx_v_dist, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":985 - * if node.children[word_id] is None: - * # Path dead-ends at this node - * continue # <<<<<<<<<<<<<< - * else: - * # Path continues at this node + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":879 + * else: + * if (dist==0): + * if (ifrom not in ret): # <<<<<<<<<<<<<< + * ret.append(ifrom) + * else: */ - goto __pyx_L19_continue; - goto __pyx_L28; - } - /*else*/ { + __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_ret), __pyx_v_ifrom))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 879; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":988 - * else: - * # Path continues at this node - * node = node.children[word_id] # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":880 + * if (dist==0): + * if (ifrom not in ret): + * ret.append(ifrom) # <<<<<<<<<<<<<< * else: - * if node.suffix_link is None: + * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): */ - __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_15 = PyObject_GetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_node = __pyx_t_15; - __pyx_t_15 = 0; + __pyx_t_9 = PyList_Append(__pyx_v_ret, __pyx_v_ifrom); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L8; } - __pyx_L28:; - goto __pyx_L27; + __pyx_L8:; + goto __pyx_L7; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":990 - * node = node.children[word_id] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":882 + * ret.append(ifrom) * else: - * if node.suffix_link is None: # <<<<<<<<<<<<<< - * # Current node is root; lookup required - * lookup_required = True - */ - __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_8 = (__pyx_t_15 == Py_None); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":992 - * if node.suffix_link is None: - * # Current node is root; lookup required - * lookup_required = True # <<<<<<<<<<<<<< - * else: - * if word_id in node.suffix_link.children: + * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): # <<<<<<<<<<<<<< + * if (ifromchild not in ret): + * ret.append(ifromchild) */ - __pyx_cur_scope->__pyx_v_lookup_required = 1; - goto __pyx_L29; + __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reachable); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); + __pyx_t_3 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_7 = PyObject_GetItem(__pyx_t_3, __pyx_v_alt_id); if (!__pyx_t_7) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_7, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_7 = PyNumber_Add(__pyx_v_ifrom, __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyNumber_Subtract(__pyx_v_dist, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_fwords); + __Pyx_GIVEREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_t_7 = 0; + __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; + if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { + __pyx_t_6 = __pyx_t_3; __Pyx_INCREF(__pyx_t_6); __pyx_t_10 = 0; + __pyx_t_11 = NULL; + } else { + __pyx_t_10 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_11 = Py_TYPE(__pyx_t_6)->tp_iternext; } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":994 - * lookup_required = True - * else: - * if word_id in node.suffix_link.children: # <<<<<<<<<<<<<< - * if node.suffix_link.children[word_id] is None: - * # Suffix link reports path is dead end - */ - __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_8 = ((PySequence_Contains(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":995 - * else: - * if word_id in node.suffix_link.children: - * if node.suffix_link.children[word_id] is None: # <<<<<<<<<<<<<< - * # Suffix link reports path is dead end - * node.children[word_id] = None - */ - __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_15 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_8 = (__pyx_t_3 == Py_None); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":997 - * if node.suffix_link.children[word_id] is None: - * # Suffix link reports path is dead end - * node.children[word_id] = None # <<<<<<<<<<<<<< - * continue - * else: - */ - __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (PyObject_SetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id, Py_None) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 997; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":998 - * # Suffix link reports path is dead end - * node.children[word_id] = None - * continue # <<<<<<<<<<<<<< - * else: - * # Suffix link indicates lookup is reqired - */ - goto __pyx_L19_continue; - goto __pyx_L31; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (;;) { + if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_6)) { + if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_6)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_6)) { + if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_6)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_10); __Pyx_INCREF(__pyx_t_3); __pyx_t_10++; + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_6, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_3 = __pyx_t_11(__pyx_t_6); + if (unlikely(!__pyx_t_3)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; } - /*else*/ { + __Pyx_GOTREF(__pyx_t_3); + } + __Pyx_XDECREF(__pyx_v_ifromchild); + __pyx_v_ifromchild = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1001 - * else: - * # Suffix link indicates lookup is reqired - * lookup_required = True # <<<<<<<<<<<<<< - * else: - * #ERROR: We never get here + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":883 + * else: + * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): + * if (ifromchild not in ret): # <<<<<<<<<<<<<< + * ret.append(ifromchild) + * */ - __pyx_cur_scope->__pyx_v_lookup_required = 1; - } - __pyx_L31:; - goto __pyx_L30; - } - /*else*/ { + __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_ret), __pyx_v_ifromchild))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1004 - * else: - * #ERROR: We never get here - * raise Exception("Keyword trie error") # <<<<<<<<<<<<<< - * # checking whether lookup_required - * if lookup_required: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":884 + * for ifromchild in self.reachable(fwords,ifrom+fwords[ifrom][alt_id][2],dist-1): + * if (ifromchild not in ret): + * ret.append(ifromchild) # <<<<<<<<<<<<<< + * + * return ret */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_k_tuple_122), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1004; __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[8]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyList_Append(__pyx_v_ret, __pyx_v_ifromchild); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + goto __pyx_L11; } - __pyx_L30:; + __pyx_L11:; } - __pyx_L29:; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } - __pyx_L27:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1006 - * raise Exception("Keyword trie error") - * # checking whether lookup_required - * if lookup_required: # <<<<<<<<<<<<<< - * new_node = None - * if is_shadow_path: - */ - if (__pyx_cur_scope->__pyx_v_lookup_required) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1007 - * # checking whether lookup_required - * if lookup_required: - * new_node = None # <<<<<<<<<<<<<< - * if is_shadow_path: - * # Extending shadow path - */ - __Pyx_INCREF(Py_None); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_new_node); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_new_node); - __Pyx_GIVEREF(Py_None); - __pyx_cur_scope->__pyx_v_new_node = Py_None; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1008 - * if lookup_required: - * new_node = None - * if is_shadow_path: # <<<<<<<<<<<<<< - * # Extending shadow path - * # on the shadow path we don't do any search, we just use info from suffix link - */ - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_8) { + __pyx_L7:; + } + __pyx_L6:; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1011 - * # Extending shadow path - * # on the shadow path we don't do any search, we just use info from suffix link - * new_node = ExtendedTrieNode(phrase_location=node.suffix_link.children[word_id].phrase_location, # <<<<<<<<<<<<<< - * suffix_link=node.suffix_link.children[word_id], - * phrase=hiero_phrase) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":886 + * ret.append(ifromchild) + * + * return ret # <<<<<<<<<<<<<< + * + * def shortest(self, fwords, ifrom, ito): */ - __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__children); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_15 = PyObject_GetItem(__pyx_t_2, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(((PyObject *)__pyx_v_ret)); + __pyx_r = ((PyObject *)__pyx_v_ret); + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1012 - * # on the shadow path we don't do any search, we just use info from suffix link - * new_node = ExtendedTrieNode(phrase_location=node.suffix_link.children[word_id].phrase_location, - * suffix_link=node.suffix_link.children[word_id], # <<<<<<<<<<<<<< - * phrase=hiero_phrase) - * else: - */ - __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__suffix_link), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __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_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.reachable", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XDECREF(__pyx_v_alt_id); + __Pyx_XDECREF(__pyx_v_ifromchild); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1013 - * new_node = ExtendedTrieNode(phrase_location=node.suffix_link.children[word_id].phrase_location, - * suffix_link=node.suffix_link.children[word_id], - * phrase=hiero_phrase) # <<<<<<<<<<<<<< - * else: - * if arity > 0: - */ - if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__phrase), ((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_new_node); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_new_node); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_new_node = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L33; +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_19shortest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_19shortest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v_fwords = 0; + PyObject *__pyx_v_ifrom = 0; + PyObject *__pyx_v_ito = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("shortest (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fwords,&__pyx_n_s__ifrom,&__pyx_n_s__ito,0}; + PyObject* values[3] = {0,0,0}; + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fwords)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ifrom)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("shortest", 1, 3, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1015 - * phrase=hiero_phrase) - * else: - * if arity > 0: # <<<<<<<<<<<<<< - * # Intersecting because of arity > 0 - * phrase_location = self.intersect(node, node.suffix_link.children[word_id], hiero_phrase) - */ - __pyx_t_8 = (__pyx_cur_scope->__pyx_v_arity > 0); - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1017 - * if arity > 0: - * # Intersecting because of arity > 0 - * phrase_location = self.intersect(node, node.suffix_link.children[word_id], hiero_phrase) # <<<<<<<<<<<<<< - * else: - * # Suffix array search - */ - __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1017; __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_GetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->intersect(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_node, __pyx_t_2, __pyx_cur_scope->__pyx_v_hiero_phrase)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L34; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1020 - * else: - * # Suffix array search - * phrase_location = node.phrase_location # <<<<<<<<<<<<<< - * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) - * if sa_range is not None: - */ - __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1020; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); - __pyx_t_3 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1021 - * # Suffix array search - * phrase_location = node.phrase_location - * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) # <<<<<<<<<<<<<< - * if sa_range is not None: - * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) - */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self->fsa), __pyx_n_s__lookup); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_phrase, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyBytes_FromString(__pyx_f_3_sa_sym_tostring(__pyx_t_18)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_5 = PyObject_Length(__pyx_cur_scope->__pyx_v_phrase); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_15 = PyInt_FromSsize_t((__pyx_t_5 - 1)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_phrase_location->sa_low); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_phrase_location->sa_high); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_2 = 0; - __pyx_t_15 = 0; - __pyx_t_14 = 0; - __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sa_range); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_sa_range); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_sa_range = __pyx_t_10; - __pyx_t_10 = 0; + case 2: + if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__ito)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("shortest", 1, 3, 3, 2); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "shortest") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; + } else { + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + } + __pyx_v_fwords = values[0]; + __pyx_v_ifrom = values[1]; + __pyx_v_ito = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("shortest", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.shortest", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_18shortest(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v_fwords, __pyx_v_ifrom, __pyx_v_ito); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1022 - * phrase_location = node.phrase_location - * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) - * if sa_range is not None: # <<<<<<<<<<<<<< - * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) - * else: +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":888 + * return ret + * + * def shortest(self, fwords, ifrom, ito): # <<<<<<<<<<<<<< + * cdef unsigned alt_id + * min = 1000 */ - __pyx_t_8 = (__pyx_cur_scope->__pyx_v_sa_range != Py_None); - if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1023 - * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) - * if sa_range is not None: - * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) # <<<<<<<<<<<<<< - * else: - * phrase_location = None - */ - __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_sa_range, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__sa_low), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_sa_range, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__sa_high), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1023; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_9); - __pyx_t_9 = 0; - goto __pyx_L35; - } - /*else*/ { +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_18shortest(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords, PyObject *__pyx_v_ifrom, PyObject *__pyx_v_ito) { + unsigned int __pyx_v_alt_id; + PyObject *__pyx_v_min = NULL; + PyObject *__pyx_v_currmin = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + int __pyx_t_2; + Py_ssize_t __pyx_t_3; + unsigned int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + PyObject *__pyx_t_6 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("shortest", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1025 - * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) - * else: - * phrase_location = None # <<<<<<<<<<<<<< - * - * if phrase_location is None: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":890 + * def shortest(self, fwords, ifrom, ito): + * cdef unsigned alt_id + * min = 1000 # <<<<<<<<<<<<<< + * if (ifrom > ito): + * return min */ - __Pyx_INCREF(Py_None); - __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); - __Pyx_GIVEREF(Py_None); - __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)Py_None); - } - __pyx_L35:; - } - __pyx_L34:; + __Pyx_INCREF(__pyx_int_1000); + __pyx_v_min = __pyx_int_1000; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1027 - * phrase_location = None - * - * if phrase_location is None: # <<<<<<<<<<<<<< - * node.children[word_id] = None - * # Search failed + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":891 + * cdef unsigned alt_id + * min = 1000 + * if (ifrom > ito): # <<<<<<<<<<<<<< + * return min + * if (ifrom == ito): */ - __pyx_t_8 = (((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location) == Py_None); - if (__pyx_t_8) { + __pyx_t_1 = PyObject_RichCompare(__pyx_v_ifrom, __pyx_v_ito, Py_GT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 891; __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[8]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1028 - * - * if phrase_location is None: - * node.children[word_id] = None # <<<<<<<<<<<<<< - * # Search failed - * continue + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":892 + * min = 1000 + * if (ifrom > ito): + * return min # <<<<<<<<<<<<<< + * if (ifrom == ito): + * return 0 */ - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - if (PyObject_SetItem(__pyx_t_9, __pyx_cur_scope->__pyx_v_word_id, Py_None) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_min); + __pyx_r = __pyx_v_min; + goto __pyx_L0; + goto __pyx_L3; + } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1030 - * node.children[word_id] = None - * # Search failed - * continue # <<<<<<<<<<<<<< - * # Search succeeded - * suffix_link = self.rules.root + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":893 + * if (ifrom > ito): + * return min + * if (ifrom == ito): # <<<<<<<<<<<<<< + * return 0 + * for alt_id in range(len(fwords[ifrom])): */ - goto __pyx_L19_continue; - goto __pyx_L36; - } - __pyx_L36:; + __pyx_t_1 = PyObject_RichCompare(__pyx_v_ifrom, __pyx_v_ito, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 893; __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[8]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1032 - * continue - * # Search succeeded - * suffix_link = self.rules.root # <<<<<<<<<<<<<< - * if node.suffix_link is not None: - * suffix_link = node.suffix_link.children[word_id] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":894 + * return min + * if (ifrom == ito): + * return 0 # <<<<<<<<<<<<<< + * for alt_id in range(len(fwords[ifrom])): + * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) */ - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->rules->root); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_suffix_link); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_suffix_link); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->rules->root); - __pyx_cur_scope->__pyx_v_suffix_link = __pyx_cur_scope->__pyx_v_self->rules->root; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_int_0); + __pyx_r = __pyx_int_0; + goto __pyx_L0; + goto __pyx_L4; + } + __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1033 - * # Search succeeded - * suffix_link = self.rules.root - * if node.suffix_link is not None: # <<<<<<<<<<<<<< - * suffix_link = node.suffix_link.children[word_id] - * new_node = ExtendedTrieNode(phrase_location=phrase_location, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":895 + * if (ifrom == ito): + * return 0 + * for alt_id in range(len(fwords[ifrom])): # <<<<<<<<<<<<<< + * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) + * if (fwords[ifrom][alt_id][0] != EPSILON): */ - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1033; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_8 = (__pyx_t_9 != Py_None); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if (__pyx_t_8) { + __pyx_t_1 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_alt_id = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1034 - * suffix_link = self.rules.root - * if node.suffix_link is not None: - * suffix_link = node.suffix_link.children[word_id] # <<<<<<<<<<<<<< - * new_node = ExtendedTrieNode(phrase_location=phrase_location, - * suffix_link=suffix_link, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":896 + * return 0 + * for alt_id in range(len(fwords[ifrom])): + * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) # <<<<<<<<<<<<<< + * if (fwords[ifrom][alt_id][0] != EPSILON): + * currmin += 1 */ - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_GetItem(__pyx_t_10, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1034; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_suffix_link); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_suffix_link); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_cur_scope->__pyx_v_suffix_link = __pyx_t_9; - __pyx_t_9 = 0; - goto __pyx_L37; - } - __pyx_L37:; + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__shortest); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, __pyx_v_alt_id, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyNumber_Add(__pyx_v_ifrom, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_fwords); + __Pyx_GIVEREF(__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6); + __Pyx_GIVEREF(__pyx_t_6); + __Pyx_INCREF(__pyx_v_ito); + PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_ito); + __Pyx_GIVEREF(__pyx_v_ito); + __pyx_t_6 = 0; + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __Pyx_XDECREF(__pyx_v_currmin); + __pyx_v_currmin = __pyx_t_6; + __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1035 - * if node.suffix_link is not None: - * suffix_link = node.suffix_link.children[word_id] - * new_node = ExtendedTrieNode(phrase_location=phrase_location, # <<<<<<<<<<<<<< - * suffix_link=suffix_link, - * phrase=hiero_phrase) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":897 + * for alt_id in range(len(fwords[ifrom])): + * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) + * if (fwords[ifrom][alt_id][0] != EPSILON): # <<<<<<<<<<<<<< + * currmin += 1 + * if (currmin__pyx_v_phrase_location)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetItem(__pyx_v_fwords, __pyx_v_ifrom); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_5 = __Pyx_GetItemInt(__pyx_t_6, __pyx_v_alt_id, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_5, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 897; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1036 - * suffix_link = node.suffix_link.children[word_id] - * new_node = ExtendedTrieNode(phrase_location=phrase_location, - * suffix_link=suffix_link, # <<<<<<<<<<<<<< - * phrase=hiero_phrase) - * node.children[word_id] = new_node + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":898 + * currmin = self.shortest(fwords,ifrom+fwords[ifrom][alt_id][2],ito) + * if (fwords[ifrom][alt_id][0] != EPSILON): + * currmin += 1 # <<<<<<<<<<<<<< + * if (currmin__pyx_v_suffix_link) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_currmin, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_v_currmin); + __pyx_v_currmin = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L7; + } + __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1037 - * new_node = ExtendedTrieNode(phrase_location=phrase_location, - * suffix_link=suffix_link, - * phrase=hiero_phrase) # <<<<<<<<<<<<<< - * node.children[word_id] = new_node - * node = new_node + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":899 + * if (fwords[ifrom][alt_id][0] != EPSILON): + * currmin += 1 + * if (currmin__pyx_v_hiero_phrase)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_10 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_new_node); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_new_node); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_new_node = __pyx_t_10; - __pyx_t_10 = 0; - } - __pyx_L33:; + __pyx_t_1 = PyObject_RichCompare(__pyx_v_currmin, __pyx_v_min, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 899; __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[8]; __pyx_lineno = 899; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1038 - * suffix_link=suffix_link, - * phrase=hiero_phrase) - * node.children[word_id] = new_node # <<<<<<<<<<<<<< - * node = new_node + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":900 + * currmin += 1 + * if (currmin__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - if (PyObject_SetItem(__pyx_t_10, __pyx_cur_scope->__pyx_v_word_id, __pyx_cur_scope->__pyx_v_new_node) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_INCREF(__pyx_v_currmin); + __Pyx_DECREF(__pyx_v_min); + __pyx_v_min = __pyx_v_currmin; + goto __pyx_L8; + } + __pyx_L8:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1039 - * phrase=hiero_phrase) - * node.children[word_id] = new_node - * node = new_node # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":901 + * if (currmin__pyx_v_new_node); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_new_node); - __pyx_cur_scope->__pyx_v_node = __pyx_cur_scope->__pyx_v_new_node; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1044 - * This should happen before we get to extraction (so that - * the node will exist if needed)''' - * if arity < self.max_nonterminals: # <<<<<<<<<<<<<< - * xcat_index = arity+1 - * xcat = sym_setindex(self.category, xcat_index) - */ - __pyx_t_8 = (__pyx_cur_scope->__pyx_v_arity < __pyx_cur_scope->__pyx_v_self->max_nonterminals); - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1045 - * the node will exist if needed)''' - * if arity < self.max_nonterminals: - * xcat_index = arity+1 # <<<<<<<<<<<<<< - * xcat = sym_setindex(self.category, xcat_index) - * suffix_link_xcat_index = xcat_index + * def get_next_states(self, _columns, curr_idx, min_dist=2): */ - __pyx_t_10 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_arity + 1)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_xcat_index); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_xcat_index); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_xcat_index = __pyx_t_10; - __pyx_t_10 = 0; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_min); + __pyx_r = __pyx_v_min; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1046 - * if arity < self.max_nonterminals: - * xcat_index = arity+1 - * xcat = sym_setindex(self.category, xcat_index) # <<<<<<<<<<<<<< - * suffix_link_xcat_index = xcat_index - * if is_shadow_path: - */ - __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_cur_scope->__pyx_v_xcat_index); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_cur_scope->__pyx_v_xcat = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, __pyx_t_18); + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.shortest", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_min); + __Pyx_XDECREF(__pyx_v_currmin); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1047 - * xcat_index = arity+1 - * xcat = sym_setindex(self.category, xcat_index) - * suffix_link_xcat_index = xcat_index # <<<<<<<<<<<<<< - * if is_shadow_path: - * suffix_link_xcat_index = xcat_index-1 - */ - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_xcat_index); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_xcat_index); - __pyx_cur_scope->__pyx_v_suffix_link_xcat_index = __pyx_cur_scope->__pyx_v_xcat_index; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1048 - * xcat = sym_setindex(self.category, xcat_index) - * suffix_link_xcat_index = xcat_index - * if is_shadow_path: # <<<<<<<<<<<<<< - * suffix_link_xcat_index = xcat_index-1 - * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) - */ - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_8) { +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_21get_next_states(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_21get_next_states(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { + PyObject *__pyx_v__columns = 0; + PyObject *__pyx_v_curr_idx = 0; + PyObject *__pyx_v_min_dist = 0; + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("get_next_states (wrapper)", 0); + { + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s___columns,&__pyx_n_s__curr_idx,&__pyx_n_s__min_dist,0}; + PyObject* values[3] = {0,0,0}; + values[2] = ((PyObject *)__pyx_int_2); + if (unlikely(__pyx_kwds)) { + Py_ssize_t kw_args; + const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); + switch (pos_args) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + case 0: break; + default: goto __pyx_L5_argtuple_error; + } + kw_args = PyDict_Size(__pyx_kwds); + switch (pos_args) { + case 0: + if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s___columns)) != 0)) kw_args--; + else goto __pyx_L5_argtuple_error; + case 1: + if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__curr_idx)) != 0)) kw_args--; + else { + __Pyx_RaiseArgtupleInvalid("get_next_states", 0, 2, 3, 1); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + case 2: + if (kw_args > 0) { + PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__min_dist); + if (value) { values[2] = value; kw_args--; } + } + } + if (unlikely(kw_args > 0)) { + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_next_states") < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + } + } else { + switch (PyTuple_GET_SIZE(__pyx_args)) { + case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); + case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + break; + default: goto __pyx_L5_argtuple_error; + } + } + __pyx_v__columns = values[0]; + __pyx_v_curr_idx = values[1]; + __pyx_v_min_dist = values[2]; + } + goto __pyx_L4_argument_unpacking_done; + __pyx_L5_argtuple_error:; + __Pyx_RaiseArgtupleInvalid("get_next_states", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[8]; __pyx_lineno = 903; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_L3_error:; + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_next_states", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_RefNannyFinishContext(); + return NULL; + __pyx_L4_argument_unpacking_done:; + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_20get_next_states(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), __pyx_v__columns, __pyx_v_curr_idx, __pyx_v_min_dist); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1049 - * suffix_link_xcat_index = xcat_index - * if is_shadow_path: - * suffix_link_xcat_index = xcat_index-1 # <<<<<<<<<<<<<< - * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) - * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":903 + * return min + * + * def get_next_states(self, _columns, curr_idx, min_dist=2): # <<<<<<<<<<<<<< + * result = [] + * candidate = [[curr_idx,0]] */ - __pyx_t_10 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_xcat_index, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_suffix_link_xcat_index = __pyx_t_10; - __pyx_t_10 = 0; - goto __pyx_L39; - } - __pyx_L39:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1050 - * if is_shadow_path: - * suffix_link_xcat_index = xcat_index-1 - * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) # <<<<<<<<<<<<<< - * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, - * suffix_link=node.suffix_link.children[suffix_link_xcat], - */ - __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_cur_scope->__pyx_v_suffix_link_xcat = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, __pyx_t_18); +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_20get_next_states(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v__columns, PyObject *__pyx_v_curr_idx, PyObject *__pyx_v_min_dist) { + PyObject *__pyx_v_result = NULL; + PyObject *__pyx_v_candidate = NULL; + PyObject *__pyx_v_curr = NULL; + PyObject *__pyx_v_curr_col = NULL; + PyObject *__pyx_v_alt = NULL; + PyObject *__pyx_v_next_id = NULL; + PyObject *__pyx_v_jump = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + PyObject *(*__pyx_t_9)(PyObject *); + PyObject *__pyx_t_10 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("get_next_states", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1051 - * suffix_link_xcat_index = xcat_index-1 - * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) - * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, # <<<<<<<<<<<<<< - * suffix_link=node.suffix_link.children[suffix_link_xcat], - * phrase= Phrase(phrase + (xcat,))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":904 + * + * def get_next_states(self, _columns, curr_idx, min_dist=2): + * result = [] # <<<<<<<<<<<<<< + * candidate = [[curr_idx,0]] + * */ - __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_result = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1052 - * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) - * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, - * suffix_link=node.suffix_link.children[suffix_link_xcat], # <<<<<<<<<<<<<< - * phrase= Phrase(phrase + (xcat,))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":905 + * def get_next_states(self, _columns, curr_idx, min_dist=2): + * result = [] + * candidate = [[curr_idx,0]] # <<<<<<<<<<<<<< * + * while len(candidate) > 0: */ - __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_3, __pyx_cur_scope->__pyx_v_suffix_link_xcat, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__suffix_link), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_curr_idx); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_curr_idx); + __Pyx_GIVEREF(__pyx_v_curr_idx); + __Pyx_INCREF(__pyx_int_0); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 905; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_v_candidate = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1053 - * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, - * suffix_link=node.suffix_link.children[suffix_link_xcat], - * phrase= Phrase(phrase + (xcat,))) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":907 + * candidate = [[curr_idx,0]] * - * # sample from range + * while len(candidate) > 0: # <<<<<<<<<<<<<< + * curr = candidate.pop() + * if curr[0] >= len(_columns): */ - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_xcat); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Add(__pyx_cur_scope->__pyx_v_phrase, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__phrase), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + while (1) { + __pyx_t_3 = PyList_GET_SIZE(((PyObject *)__pyx_v_candidate)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = (__pyx_t_3 > 0); + if (!__pyx_t_4) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1051 - * suffix_link_xcat_index = xcat_index-1 - * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) - * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, # <<<<<<<<<<<<<< - * suffix_link=node.suffix_link.children[suffix_link_xcat], - * phrase= Phrase(phrase + (xcat,))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":908 + * + * while len(candidate) > 0: + * curr = candidate.pop() # <<<<<<<<<<<<<< + * if curr[0] >= len(_columns): + * continue */ - __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - if (__Pyx_SetItemInt(__pyx_t_10, __pyx_cur_scope->__pyx_v_xcat, __pyx_t_9, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L38; - } - __pyx_L38:; + __pyx_t_2 = __Pyx_PyObject_Pop(((PyObject *)__pyx_v_candidate)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_v_curr); + __pyx_v_curr = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1056 - * - * # sample from range - * if not is_shadow_path: # <<<<<<<<<<<<<< - * sample = self.sampler.sample(node.phrase_location) - * num_subpatterns = ( node.phrase_location).num_subpatterns + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":909 + * while len(candidate) > 0: + * curr = candidate.pop() + * if curr[0] >= len(_columns): # <<<<<<<<<<<<<< + * continue + * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: */ - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_19 = (!__pyx_t_8); - if (__pyx_t_19) { + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_Length(__pyx_v__columns); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, __pyx_t_1, Py_GE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 909; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1057 - * # sample from range - * if not is_shadow_path: - * sample = self.sampler.sample(node.phrase_location) # <<<<<<<<<<<<<< - * num_subpatterns = ( node.phrase_location).num_subpatterns - * chunklen = IntList(initial_len=num_subpatterns) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":910 + * curr = candidate.pop() + * if curr[0] >= len(_columns): + * continue # <<<<<<<<<<<<<< + * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: + * result.append(curr[0]); */ - __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self->sampler), __pyx_n_s__sample); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_sample)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_sample)); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_sample = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_10); - __pyx_t_10 = 0; + goto __pyx_L3_continue; + goto __pyx_L5; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1058 - * if not is_shadow_path: - * sample = self.sampler.sample(node.phrase_location) - * num_subpatterns = ( node.phrase_location).num_subpatterns # <<<<<<<<<<<<<< - * chunklen = IntList(initial_len=num_subpatterns) - * for j from 0 <= j < num_subpatterns: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":911 + * if curr[0] >= len(_columns): + * continue + * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: # <<<<<<<<<<<<<< + * result.append(curr[0]); + * curr_col = _columns[curr[0]] */ - __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_num_subpatterns = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_10)->num_subpatterns; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_4 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_result), __pyx_t_5))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (__pyx_t_4) { + __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_curr, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyObject_RichCompare(__pyx_v_min_dist, __pyx_t_5, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { + __Pyx_DECREF(__pyx_t_1); + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_t_2, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 911; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_7 = __pyx_t_6; + } else { + __pyx_t_7 = __pyx_t_4; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1059 - * sample = self.sampler.sample(node.phrase_location) - * num_subpatterns = ( node.phrase_location).num_subpatterns - * chunklen = IntList(initial_len=num_subpatterns) # <<<<<<<<<<<<<< - * for j from 0 <= j < num_subpatterns: - * chunklen.arr[j] = hiero_phrase.chunklen(j) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":912 + * continue + * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: + * result.append(curr[0]); # <<<<<<<<<<<<<< + * curr_col = _columns[curr[0]] + * for alt in curr_col: */ - __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_num_subpatterns); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_chunklen)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_chunklen)); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_chunklen = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_8 = PyList_Append(__pyx_v_result, __pyx_t_1); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 912; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L6; + } + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1060 - * num_subpatterns = ( node.phrase_location).num_subpatterns - * chunklen = IntList(initial_len=num_subpatterns) - * for j from 0 <= j < num_subpatterns: # <<<<<<<<<<<<<< - * chunklen.arr[j] = hiero_phrase.chunklen(j) - * extracts = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":913 + * if curr[0] not in result and min_dist <= curr[1] <= self.max_initial_size: + * result.append(curr[0]); + * curr_col = _columns[curr[0]] # <<<<<<<<<<<<<< + * for alt in curr_col: + * next_id = curr[0]+alt[2] */ - __pyx_t_18 = __pyx_cur_scope->__pyx_v_num_subpatterns; - for (__pyx_cur_scope->__pyx_v_j = 0; __pyx_cur_scope->__pyx_v_j < __pyx_t_18; __pyx_cur_scope->__pyx_v_j++) { + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_GetItem(__pyx_v__columns, __pyx_t_1); if (!__pyx_t_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 913; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_v_curr_col); + __pyx_v_curr_col = __pyx_t_5; + __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1061 - * chunklen = IntList(initial_len=num_subpatterns) - * for j from 0 <= j < num_subpatterns: - * chunklen.arr[j] = hiero_phrase.chunklen(j) # <<<<<<<<<<<<<< - * extracts = [] - * j = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":914 + * result.append(curr[0]); + * curr_col = _columns[curr[0]] + * for alt in curr_col: # <<<<<<<<<<<<<< + * next_id = curr[0]+alt[2] + * jump = 1 */ - (__pyx_cur_scope->__pyx_v_chunklen->arr[__pyx_cur_scope->__pyx_v_j]) = ((struct __pyx_vtabstruct_3_sa_Phrase *)__pyx_cur_scope->__pyx_v_hiero_phrase->__pyx_vtab)->chunklen(__pyx_cur_scope->__pyx_v_hiero_phrase, __pyx_cur_scope->__pyx_v_j); + if (PyList_CheckExact(__pyx_v_curr_col) || PyTuple_CheckExact(__pyx_v_curr_col)) { + __pyx_t_5 = __pyx_v_curr_col; __Pyx_INCREF(__pyx_t_5); __pyx_t_3 = 0; + __pyx_t_9 = NULL; + } else { + __pyx_t_3 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_curr_col); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_9 = Py_TYPE(__pyx_t_5)->tp_iternext; + } + for (;;) { + if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_5)) { + if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_5)) { + if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_5)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + #else + __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_1 = __pyx_t_9(__pyx_t_5); + if (unlikely(!__pyx_t_1)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 914; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + break; + } + __Pyx_GOTREF(__pyx_t_1); + } + __Pyx_XDECREF(__pyx_v_alt); + __pyx_v_alt = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1062 - * for j from 0 <= j < num_subpatterns: - * chunklen.arr[j] = hiero_phrase.chunklen(j) - * extracts = [] # <<<<<<<<<<<<<< - * j = 0 - * extract_start = monitor_cpu() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":915 + * curr_col = _columns[curr[0]] + * for alt in curr_col: + * next_id = curr[0]+alt[2] # <<<<<<<<<<<<<< + * jump = 1 + * if (alt[0] == EPSILON): */ - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_extracts)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_extracts)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_cur_scope->__pyx_v_extracts = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_alt, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_10 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 915; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XDECREF(__pyx_v_next_id); + __pyx_v_next_id = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1063 - * chunklen.arr[j] = hiero_phrase.chunklen(j) - * extracts = [] - * j = 0 # <<<<<<<<<<<<<< - * extract_start = monitor_cpu() - * while j < sample.len: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":916 + * for alt in curr_col: + * next_id = curr[0]+alt[2] + * jump = 1 # <<<<<<<<<<<<<< + * if (alt[0] == EPSILON): + * jump = 0 */ - __pyx_cur_scope->__pyx_v_j = 0; + __Pyx_INCREF(__pyx_int_1); + __Pyx_XDECREF(__pyx_v_jump); + __pyx_v_jump = __pyx_int_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1064 - * extracts = [] - * j = 0 - * extract_start = monitor_cpu() # <<<<<<<<<<<<<< - * while j < sample.len: - * extract = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":917 + * next_id = curr[0]+alt[2] + * jump = 1 + * if (alt[0] == EPSILON): # <<<<<<<<<<<<<< + * jump = 0 + * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: */ - __pyx_t_3 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_extract_start); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_extract_start); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_extract_start = __pyx_t_3; - __pyx_t_3 = 0; + __pyx_t_10 = __Pyx_GetItemInt(__pyx_v_alt, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyObject_RichCompare(__pyx_t_10, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1065 - * j = 0 - * extract_start = monitor_cpu() - * while j < sample.len: # <<<<<<<<<<<<<< - * extract = [] - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":918 + * jump = 1 + * if (alt[0] == EPSILON): + * jump = 0 # <<<<<<<<<<<<<< + * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: + * candidate.append([next_id,curr[1]+jump]) */ - while (1) { - __pyx_t_19 = (__pyx_cur_scope->__pyx_v_j < __pyx_cur_scope->__pyx_v_sample->len); - if (!__pyx_t_19) break; + __Pyx_INCREF(__pyx_int_0); + __Pyx_DECREF(__pyx_v_jump); + __pyx_v_jump = __pyx_int_0; + goto __pyx_L9; + } + __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1066 - * extract_start = monitor_cpu() - * while j < sample.len: - * extract = [] # <<<<<<<<<<<<<< - * - * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":919 + * if (alt[0] == EPSILON): + * jump = 0 + * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: # <<<<<<<<<<<<<< + * candidate.append([next_id,curr[1]+jump]) + * return sorted(result); */ - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_extract); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_extract); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); - __pyx_cur_scope->__pyx_v_extract = ((PyObject *)__pyx_t_3); - __pyx_t_3 = 0; + __pyx_t_7 = (__Pyx_NegateNonNeg(PySequence_Contains(((PyObject *)__pyx_v_result), __pyx_v_next_id))); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_7) { + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_jump); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_RichCompare(__pyx_v_min_dist, __pyx_t_2, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { + __Pyx_DECREF(__pyx_t_1); + __pyx_t_10 = PyInt_FromLong((__pyx_v_self->max_initial_size + 1)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_10, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_6 = __pyx_t_4; + } else { + __pyx_t_6 = __pyx_t_7; + } + if (__pyx_t_6) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1068 - * extract = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":920 + * jump = 0 + * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: + * candidate.append([next_id,curr[1]+jump]) # <<<<<<<<<<<<<< + * return sorted(result); * - * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) # <<<<<<<<<<<<<< - * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) - * extracts.extend(extract) */ - __pyx_f_3_sa_assign_matching((&__pyx_cur_scope->__pyx_v_matching), __pyx_cur_scope->__pyx_v_sample->arr, __pyx_cur_scope->__pyx_v_j, __pyx_cur_scope->__pyx_v_num_subpatterns, __pyx_cur_scope->__pyx_v_self->fda->sent_id->arr); + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_curr, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_jump); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(__pyx_v_next_id); + PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_next_id); + __Pyx_GIVEREF(__pyx_v_next_id); + PyList_SET_ITEM(__pyx_t_1, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_t_2 = 0; + __pyx_t_8 = PyList_Append(__pyx_v_candidate, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 920; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + goto __pyx_L10; + } + __pyx_L10:; + } + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_L3_continue:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1069 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":921 + * if next_id not in result and min_dist <= curr[1]+jump <= self.max_initial_size+1: + * candidate.append([next_id,curr[1]+jump]) + * return sorted(result); # <<<<<<<<<<<<<< * - * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) - * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) # <<<<<<<<<<<<<< - * extracts.extend(extract) - * j = j + num_subpatterns + * def input(self, fwords): */ - __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->extract(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_hiero_phrase, (&__pyx_cur_scope->__pyx_v_matching), __pyx_cur_scope->__pyx_v_chunklen->arr, __pyx_cur_scope->__pyx_v_num_subpatterns); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_extract); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_extract); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_extract = __pyx_t_3; - __pyx_t_3 = 0; + __Pyx_XDECREF(__pyx_r); + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_INCREF(((PyObject *)__pyx_v_result)); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_result)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_result)); + __pyx_t_1 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1070 - * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) - * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) - * extracts.extend(extract) # <<<<<<<<<<<<<< - * j = j + num_subpatterns - * - */ - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_extracts), __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_extract); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_cur_scope->__pyx_v_extract); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_extract); - __pyx_t_9 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.get_next_states", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_candidate); + __Pyx_XDECREF(__pyx_v_curr); + __Pyx_XDECREF(__pyx_v_curr_col); + __Pyx_XDECREF(__pyx_v_alt); + __Pyx_XDECREF(__pyx_v_next_id); + __Pyx_XDECREF(__pyx_v_jump); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static PyObject *__pyx_gb_3_sa_23HieroCachingRuleFactory_24generator5(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1071 - * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) - * extracts.extend(extract) - * j = j + num_subpatterns # <<<<<<<<<<<<<< - * - * num_samples = sample.len/num_subpatterns - */ - __pyx_cur_scope->__pyx_v_j = (__pyx_cur_scope->__pyx_v_j + __pyx_cur_scope->__pyx_v_num_subpatterns); - } +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_23input(PyObject *__pyx_v_self, PyObject *__pyx_v_fwords); /*proto*/ +static char __pyx_doc_3_sa_23HieroCachingRuleFactory_22input[] = "When this function is called on the RuleFactory,\n it looks up all of the rules that can be used to translate\n the input sentence"; +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_23input(PyObject *__pyx_v_self, PyObject *__pyx_v_fwords) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("input (wrapper)", 0); + __pyx_r = __pyx_pf_3_sa_23HieroCachingRuleFactory_22input(((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)__pyx_v_self), ((PyObject *)__pyx_v_fwords)); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1073 - * j = j + num_subpatterns - * - * num_samples = sample.len/num_subpatterns # <<<<<<<<<<<<<< - * extract_stop = monitor_cpu() - * self.extract_time = self.extract_time + extract_stop - extract_start - */ - if (unlikely(__pyx_cur_scope->__pyx_v_num_subpatterns == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - else if (sizeof(int) == sizeof(long) && unlikely(__pyx_cur_scope->__pyx_v_num_subpatterns == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_cur_scope->__pyx_v_sample->len))) { - PyErr_Format(PyExc_OverflowError, "value too large to perform division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_cur_scope->__pyx_v_num_samples = __Pyx_div_int(__pyx_cur_scope->__pyx_v_sample->len, __pyx_cur_scope->__pyx_v_num_subpatterns); +/* Python wrapper */ +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_5input_lambda1(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static PyMethodDef __pyx_mdef_3_sa_23HieroCachingRuleFactory_5input_lambda1 = {__Pyx_NAMESTR("lambda1"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_5input_lambda1, METH_NOARGS, __Pyx_DOCSTR(0)}; +static PyObject *__pyx_pw_3_sa_23HieroCachingRuleFactory_5input_lambda1(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) { + PyObject *__pyx_r = 0; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("lambda1 (wrapper)", 0); + __pyx_r = __pyx_lambda_funcdef_lambda1(__pyx_self); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1074 - * - * num_samples = sample.len/num_subpatterns - * extract_stop = monitor_cpu() # <<<<<<<<<<<<<< - * self.extract_time = self.extract_time + extract_stop - extract_start +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1082 * if len(extracts) > 0: + * fcount = Counter() + * fphrases = defaultdict(lambda: defaultdict(Counter)) # <<<<<<<<<<<<<< + * for f, e, count, als in extracts: + * fcount[f] += count */ - __pyx_t_9 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_extract_stop); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_extract_stop); - __Pyx_GIVEREF(__pyx_t_9); - __pyx_cur_scope->__pyx_v_extract_stop = __pyx_t_9; - __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1075 - * num_samples = sample.len/num_subpatterns - * extract_stop = monitor_cpu() - * self.extract_time = self.extract_time + extract_stop - extract_start # <<<<<<<<<<<<<< - * if len(extracts) > 0: - * fphrases = {} - */ - __pyx_t_9 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->extract_time); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyNumber_Add(__pyx_t_9, __pyx_cur_scope->__pyx_v_extract_stop); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Subtract(__pyx_t_10, __pyx_cur_scope->__pyx_v_extract_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_20 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_20 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_cur_scope->__pyx_v_self->extract_time = __pyx_t_20; +static PyObject *__pyx_lambda_funcdef_lambda1(CYTHON_UNUSED PyObject *__pyx_self) { + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("lambda1", 0); + __Pyx_XDECREF(__pyx_r); + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__Counter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __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[8]; __pyx_lineno = 1082; __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[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_r = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1076 - * extract_stop = monitor_cpu() - * self.extract_time = self.extract_time + extract_stop - extract_start - * if len(extracts) > 0: # <<<<<<<<<<<<<< - * fphrases = {} - * fals = {} + __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("_sa.HieroCachingRuleFactory.input.lambda1", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":923 + * return sorted(result); + * + * def input(self, fwords): # <<<<<<<<<<<<<< + * '''When this function is called on the RuleFactory, + * it looks up all of the rules that can be used to translate */ - __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_extracts)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_19 = (__pyx_t_5 > 0); - if (__pyx_t_19) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1077 - * self.extract_time = self.extract_time + extract_stop - extract_start - * if len(extracts) > 0: - * fphrases = {} # <<<<<<<<<<<<<< - * fals = {} - * fcount = {} - */ - __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); - __pyx_cur_scope->__pyx_v_fphrases = __pyx_t_9; - __pyx_t_9 = 0; +static PyObject *__pyx_pf_3_sa_23HieroCachingRuleFactory_22input(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, PyObject *__pyx_v_fwords) { + struct __pyx_obj_3_sa___pyx_scope_struct_11_input *__pyx_cur_scope; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("input", 0); + __pyx_cur_scope = (struct __pyx_obj_3_sa___pyx_scope_struct_11_input *)__pyx_ptype_3_sa___pyx_scope_struct_11_input->tp_new(__pyx_ptype_3_sa___pyx_scope_struct_11_input, __pyx_empty_tuple, NULL); + if (unlikely(!__pyx_cur_scope)) { + __Pyx_RefNannyFinishContext(); + return NULL; + } + __Pyx_GOTREF(__pyx_cur_scope); + __pyx_cur_scope->__pyx_v_self = __pyx_v_self; + __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); + __pyx_cur_scope->__pyx_v_fwords = __pyx_v_fwords; + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fwords); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fwords); + { + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_3_sa_23HieroCachingRuleFactory_24generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_cur_scope); + __Pyx_RefNannyFinishContext(); + return (PyObject *) gen; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1078 - * if len(extracts) > 0: - * fphrases = {} - * fals = {} # <<<<<<<<<<<<<< - * fcount = {} - * for f, e, count, als in extracts: - */ - __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_fals)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_fals)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); - __pyx_cur_scope->__pyx_v_fals = __pyx_t_9; - __pyx_t_9 = 0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.input", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = NULL; + __pyx_L0:; + __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1079 - * fphrases = {} - * fals = {} - * fcount = {} # <<<<<<<<<<<<<< - * for f, e, count, als in extracts: - * fcount.setdefault(f, 0.0) - */ - __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_9)); - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_fcount)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_fcount)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_9)); - __pyx_cur_scope->__pyx_v_fcount = __pyx_t_9; - __pyx_t_9 = 0; +static PyObject *__pyx_gb_3_sa_23HieroCachingRuleFactory_24generator5(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +{ + struct __pyx_obj_3_sa___pyx_scope_struct_11_input *__pyx_cur_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_11_input *)__pyx_generator->closure); + PyObject *__pyx_r = NULL; + Py_ssize_t __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + PyObject *__pyx_t_3 = NULL; + int __pyx_t_4; + Py_ssize_t __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_t_8; + PyObject *__pyx_t_9 = NULL; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + PyObject *__pyx_t_12 = NULL; + PyObject *__pyx_t_13 = NULL; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *__pyx_t_16 = NULL; + PyObject *(*__pyx_t_17)(PyObject *); + int __pyx_t_18; + int __pyx_t_19; + float __pyx_t_20; + Py_ssize_t __pyx_t_21; + Py_ssize_t __pyx_t_22; + Py_ssize_t __pyx_t_23; + Py_ssize_t __pyx_t_24; + Py_ssize_t __pyx_t_25; + int __pyx_t_26; + unsigned int __pyx_t_27; + unsigned int __pyx_t_28; + int __pyx_t_29; + int __pyx_t_30; + PyObject *(*__pyx_t_31)(PyObject *); + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("None", 0); + switch (__pyx_generator->resume_label) { + case 0: goto __pyx_L3_first_run; + case 1: goto __pyx_L57_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[8]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1080 - * fals = {} - * fcount = {} - * for f, e, count, als in extracts: # <<<<<<<<<<<<<< - * fcount.setdefault(f, 0.0) - * fcount[f] = fcount[f] + count + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":934 + * cdef Phrase hiero_phrase + * + * flen = len(fwords) # <<<<<<<<<<<<<< + * start_time = monitor_cpu() + * self.extract_time = 0.0 */ - __pyx_t_9 = ((PyObject *)__pyx_cur_scope->__pyx_v_extracts); __Pyx_INCREF(__pyx_t_9); __pyx_t_5 = 0; - for (;;) { - if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_9)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_10 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_5); __Pyx_INCREF(__pyx_t_10); __pyx_t_5++; - #else - __pyx_t_10 = PySequence_ITEM(__pyx_t_9, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) { - PyObject* sequence = __pyx_t_10; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 4)) { - if (size > 4) __Pyx_RaiseTooManyValuesError(4); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_15 = PyTuple_GET_ITEM(sequence, 2); - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 3); - } else { - __pyx_t_3 = PyList_GET_ITEM(sequence, 0); - __pyx_t_14 = PyList_GET_ITEM(sequence, 1); - __pyx_t_15 = PyList_GET_ITEM(sequence, 2); - __pyx_t_2 = PyList_GET_ITEM(sequence, 3); - } - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(__pyx_t_15); - __Pyx_INCREF(__pyx_t_2); - #else - Py_ssize_t i; - PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_14,&__pyx_t_15,&__pyx_t_2}; - for (i=0; i < 4; i++) { - PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - *(temps[i]) = item; - } - #endif - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } else - { - Py_ssize_t index = -1; - PyObject** temps[4] = {&__pyx_t_3,&__pyx_t_14,&__pyx_t_15,&__pyx_t_2}; - __pyx_t_7 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_17 = Py_TYPE(__pyx_t_7)->tp_iternext; - for (index=0; index < 4; index++) { - PyObject* item = __pyx_t_17(__pyx_t_7); if (unlikely(!item)) goto __pyx_L48_unpacking_failed; - __Pyx_GOTREF(item); - *(temps[index]) = item; - } - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_7), 4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_17 = NULL; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - goto __pyx_L49_unpacking_done; - __pyx_L48_unpacking_failed:; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_17 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L49_unpacking_done:; - } - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_f); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_f); - __Pyx_GIVEREF(__pyx_t_3); - __pyx_cur_scope->__pyx_v_f = __pyx_t_3; - __pyx_t_3 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_e); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_cur_scope->__pyx_v_e = __pyx_t_14; - __pyx_t_14 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_count); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_count); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_count = __pyx_t_15; - __pyx_t_15 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_als); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_als); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_als = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_cur_scope->__pyx_v_flen = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1081 - * fcount = {} - * for f, e, count, als in extracts: - * fcount.setdefault(f, 0.0) # <<<<<<<<<<<<<< - * fcount[f] = fcount[f] + count - * fphrases.setdefault(f, {}) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":935 + * + * flen = len(fwords) + * start_time = monitor_cpu() # <<<<<<<<<<<<<< + * self.extract_time = 0.0 + * nodes_isteps_away_buffer = {} */ - __pyx_t_10 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = __Pyx_PyDict_SetDefault(((PyObject *)__pyx_cur_scope->__pyx_v_fcount), __pyx_cur_scope->__pyx_v_f, __pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_cur_scope->__pyx_v_start_time = __pyx_f_3_sa_monitor_cpu(); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1082 - * for f, e, count, als in extracts: - * fcount.setdefault(f, 0.0) - * fcount[f] = fcount[f] + count # <<<<<<<<<<<<<< - * fphrases.setdefault(f, {}) - * fphrases[f].setdefault(e, {}) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":936 + * flen = len(fwords) + * start_time = monitor_cpu() + * self.extract_time = 0.0 # <<<<<<<<<<<<<< + * nodes_isteps_away_buffer = {} + * hit = 0 */ - __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fcount), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = PyNumber_Add(__pyx_t_2, __pyx_cur_scope->__pyx_v_count); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (PyDict_SetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fcount), __pyx_cur_scope->__pyx_v_f, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_cur_scope->__pyx_v_self->extract_time = 0.0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1083 - * fcount.setdefault(f, 0.0) - * fcount[f] = fcount[f] + count - * fphrases.setdefault(f, {}) # <<<<<<<<<<<<<< - * fphrases[f].setdefault(e, {}) - * fphrases[f][e].setdefault(als,0.0) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":937 + * start_time = monitor_cpu() + * self.extract_time = 0.0 + * nodes_isteps_away_buffer = {} # <<<<<<<<<<<<<< + * hit = 0 + * reachable_buffer = {} */ - __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - __pyx_t_2 = __Pyx_PyDict_SetDefault(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases), __pyx_cur_scope->__pyx_v_f, ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + __pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1084 - * fcount[f] = fcount[f] + count - * fphrases.setdefault(f, {}) - * fphrases[f].setdefault(e, {}) # <<<<<<<<<<<<<< - * fphrases[f][e].setdefault(als,0.0) - * fphrases[f][e][als] = fphrases[f][e][als] + count + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":938 + * self.extract_time = 0.0 + * nodes_isteps_away_buffer = {} + * hit = 0 # <<<<<<<<<<<<<< + * reachable_buffer = {} + * */ - __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_10 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setdefault); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_e); - PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_cur_scope->__pyx_v_e); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_e); - PyTuple_SET_ITEM(__pyx_t_15, 1, ((PyObject *)__pyx_t_2)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); - __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_cur_scope->__pyx_v_hit = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1085 - * fphrases.setdefault(f, {}) - * fphrases[f].setdefault(e, {}) - * fphrases[f][e].setdefault(als,0.0) # <<<<<<<<<<<<<< - * fphrases[f][e][als] = fphrases[f][e][als] + count - * for f, elist in fphrases.iteritems(): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":939 + * nodes_isteps_away_buffer = {} + * hit = 0 + * reachable_buffer = {} # <<<<<<<<<<<<<< + * + * # Do not cache between sentences */ - __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = PyObject_GetItem(__pyx_t_2, __pyx_cur_scope->__pyx_v_e); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__setdefault); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_15 = PyFloat_FromDouble(0.0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_als); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_cur_scope->__pyx_v_als); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_als); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_t_15 = 0; - __pyx_t_15 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + __pyx_cur_scope->__pyx_v_reachable_buffer = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1086 - * fphrases[f].setdefault(e, {}) - * fphrases[f][e].setdefault(als,0.0) - * fphrases[f][e][als] = fphrases[f][e][als] + count # <<<<<<<<<<<<<< - * for f, elist in fphrases.iteritems(): - * f_margin = fcount[f] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":942 + * + * # Do not cache between sentences + * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) # <<<<<<<<<<<<<< + * + * frontier = [] */ - __pyx_t_15 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_10 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_e); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_15 = PyObject_GetItem(__pyx_t_10, __pyx_cur_scope->__pyx_v_als); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_10 = PyNumber_Add(__pyx_t_15, __pyx_cur_scope->__pyx_v_count); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_15 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_2 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_e); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (PyObject_SetItem(__pyx_t_2, __pyx_cur_scope->__pyx_v_als, __pyx_t_10) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_self->rules->root); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_self->rules->root); + __pyx_cur_scope->__pyx_v_self->rules->root = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1087 - * fphrases[f][e].setdefault(als,0.0) - * fphrases[f][e][als] = fphrases[f][e][als] + count - * for f, elist in fphrases.iteritems(): # <<<<<<<<<<<<<< - * f_margin = fcount[f] - * for e, alslist in elist.iteritems(): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":944 + * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) + * + * frontier = [] # <<<<<<<<<<<<<< + * for i in range(len(fwords)): + * for alt in range(0, len(fwords[i])): */ - __pyx_t_5 = 0; - __pyx_t_10 = __Pyx_dict_iterator(((PyObject *)__pyx_cur_scope->__pyx_v_fphrases), 1, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_21), (&__pyx_t_18)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_9); - __pyx_t_9 = __pyx_t_10; - __pyx_t_10 = 0; - while (1) { - __pyx_t_6 = __Pyx_dict_iter_next(__pyx_t_9, __pyx_t_21, &__pyx_t_5, &__pyx_t_10, &__pyx_t_2, NULL, __pyx_t_18); - if (unlikely(__pyx_t_6 == 0)) break; - if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_f); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_f); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_f = __pyx_t_10; - __pyx_t_10 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_elist); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_elist); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_elist = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_cur_scope->__pyx_v_frontier = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1088 - * fphrases[f][e][als] = fphrases[f][e][als] + count - * for f, elist in fphrases.iteritems(): - * f_margin = fcount[f] # <<<<<<<<<<<<<< - * for e, alslist in elist.iteritems(): - * alignment = None + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":945 + * + * frontier = [] + * for i in range(len(fwords)): # <<<<<<<<<<<<<< + * for alt in range(0, len(fwords[i])): + * if fwords[i][alt][0] != EPSILON: */ - __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fcount), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_f_margin); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_f_margin); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_f_margin = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) { + __pyx_cur_scope->__pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1089 - * for f, elist in fphrases.iteritems(): - * f_margin = fcount[f] - * for e, alslist in elist.iteritems(): # <<<<<<<<<<<<<< - * alignment = None - * count = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":946 + * frontier = [] + * for i in range(len(fwords)): + * for alt in range(0, len(fwords[i])): # <<<<<<<<<<<<<< + * if fwords[i][alt][0] != EPSILON: + * frontier.append((i, i, alt, 0, self.rules.root, (), False)) */ - __pyx_t_22 = 0; - if (unlikely(__pyx_cur_scope->__pyx_v_elist == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_10 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_elist, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_23), (&__pyx_t_6)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_2); - __pyx_t_2 = __pyx_t_10; - __pyx_t_10 = 0; - while (1) { - __pyx_t_4 = __Pyx_dict_iter_next(__pyx_t_2, __pyx_t_23, &__pyx_t_22, &__pyx_t_10, &__pyx_t_15, NULL, __pyx_t_6); - if (unlikely(__pyx_t_4 == 0)) break; - if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GOTREF(__pyx_t_15); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_e); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_e = __pyx_t_10; - __pyx_t_10 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_alslist); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_alslist); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_alslist = __pyx_t_15; - __pyx_t_15 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_5 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 946; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_cur_scope->__pyx_v_alt = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1090 - * f_margin = fcount[f] - * for e, alslist in elist.iteritems(): - * alignment = None # <<<<<<<<<<<<<< - * count = 0 - * for als, currcount in alslist.iteritems(): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":947 + * for i in range(len(fwords)): + * for alt in range(0, len(fwords[i])): + * if fwords[i][alt][0] != EPSILON: # <<<<<<<<<<<<<< + * frontier.append((i, i, alt, 0, self.rules.root, (), False)) + * */ - __Pyx_INCREF(Py_None); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_alignment); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_alignment); - __Pyx_GIVEREF(Py_None); - __pyx_cur_scope->__pyx_v_alignment = Py_None; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_7 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 947; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1091 - * for e, alslist in elist.iteritems(): - * alignment = None - * count = 0 # <<<<<<<<<<<<<< - * for als, currcount in alslist.iteritems(): - * if currcount > count: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":948 + * for alt in range(0, len(fwords[i])): + * if fwords[i][alt][0] != EPSILON: + * frontier.append((i, i, alt, 0, self.rules.root, (), False)) # <<<<<<<<<<<<<< + * + * xroot = None */ - __Pyx_INCREF(__pyx_int_0); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_count); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_count); - __Pyx_GIVEREF(__pyx_int_0); - __pyx_cur_scope->__pyx_v_count = __pyx_int_0; + __pyx_t_7 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + __Pyx_INCREF(__pyx_int_0); + PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_int_0); + __Pyx_GIVEREF(__pyx_int_0); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->rules->root); + PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_cur_scope->__pyx_v_self->rules->root); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->rules->root); + __Pyx_INCREF(((PyObject *)__pyx_empty_tuple)); + PyTuple_SET_ITEM(__pyx_t_10, 5, ((PyObject *)__pyx_empty_tuple)); + __Pyx_GIVEREF(((PyObject *)__pyx_empty_tuple)); + PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_7 = 0; + __pyx_t_2 = 0; + __pyx_t_3 = 0; + __pyx_t_9 = 0; + __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_frontier, ((PyObject *)__pyx_t_10)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + goto __pyx_L8; + } + __pyx_L8:; + } + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1092 - * alignment = None - * count = 0 - * for als, currcount in alslist.iteritems(): # <<<<<<<<<<<<<< - * if currcount > count: - * alignment = als + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":950 + * frontier.append((i, i, alt, 0, self.rules.root, (), False)) + * + * xroot = None # <<<<<<<<<<<<<< + * x1 = sym_setindex(self.category, 1) + * if x1 in self.rules.root.children: */ - __pyx_t_24 = 0; - if (unlikely(__pyx_cur_scope->__pyx_v_alslist == Py_None)) { - PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_t_10 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_alslist, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_25), (&__pyx_t_4)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_15); - __pyx_t_15 = __pyx_t_10; - __pyx_t_10 = 0; - while (1) { - __pyx_t_26 = __Pyx_dict_iter_next(__pyx_t_15, __pyx_t_25, &__pyx_t_24, &__pyx_t_10, &__pyx_t_14, NULL, __pyx_t_4); - if (unlikely(__pyx_t_26 == 0)) break; - if (unlikely(__pyx_t_26 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GOTREF(__pyx_t_14); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_als); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_als); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_als = __pyx_t_10; - __pyx_t_10 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_currcount); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_currcount); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_cur_scope->__pyx_v_currcount = __pyx_t_14; - __pyx_t_14 = 0; + __Pyx_INCREF(Py_None); + __Pyx_GIVEREF(Py_None); + __pyx_cur_scope->__pyx_v_xroot = Py_None; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1093 - * count = 0 - * for als, currcount in alslist.iteritems(): - * if currcount > count: # <<<<<<<<<<<<<< - * alignment = als - * count = currcount + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":951 + * + * xroot = None + * x1 = sym_setindex(self.category, 1) # <<<<<<<<<<<<<< + * if x1 in self.rules.root.children: + * xroot = self.rules.root.children[x1] */ - __pyx_t_14 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_currcount, __pyx_cur_scope->__pyx_v_count, Py_GT); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - if (__pyx_t_19) { + __pyx_cur_scope->__pyx_v_x1 = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1094 - * for als, currcount in alslist.iteritems(): - * if currcount > count: - * alignment = als # <<<<<<<<<<<<<< - * count = currcount - * scores = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":952 + * xroot = None + * x1 = sym_setindex(self.category, 1) + * if x1 in self.rules.root.children: # <<<<<<<<<<<<<< + * xroot = self.rules.root.children[x1] + * else: */ - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_als); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_alignment); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_alignment); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_als); - __pyx_cur_scope->__pyx_v_alignment = __pyx_cur_scope->__pyx_v_als; + __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_x1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_self->rules->root, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = ((PySequence_Contains(__pyx_t_9, __pyx_t_10))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1095 - * if currcount > count: - * alignment = als - * count = currcount # <<<<<<<<<<<<<< - * scores = [] - * for model in models: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":953 + * x1 = sym_setindex(self.category, 1) + * if x1 in self.rules.root.children: + * xroot = self.rules.root.children[x1] # <<<<<<<<<<<<<< + * else: + * xroot = ExtendedTrieNode(suffix_link=self.rules.root, phrase_location=PhraseLocation()) */ - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_currcount); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_count); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_count); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_currcount); - __pyx_cur_scope->__pyx_v_count = __pyx_cur_scope->__pyx_v_currcount; - goto __pyx_L56; - } - __pyx_L56:; - } - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_self->rules->root, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_x1, sizeof(int), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_xroot); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_xroot); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_xroot = __pyx_t_10; + __pyx_t_10 = 0; + goto __pyx_L9; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1096 - * alignment = als - * count = currcount - * scores = [] # <<<<<<<<<<<<<< - * for model in models: - * scores.append(model(f, e, count, fcount[f], num_samples)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":955 + * xroot = self.rules.root.children[x1] + * else: + * xroot = ExtendedTrieNode(suffix_link=self.rules.root, phrase_location=PhraseLocation()) # <<<<<<<<<<<<<< + * self.rules.root.children[x1] = xroot + * */ - __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_scores)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_scores)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_15)); - __pyx_cur_scope->__pyx_v_scores = __pyx_t_15; - __pyx_t_15 = 0; + __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_10)); + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__suffix_link), __pyx_cur_scope->__pyx_v_self->rules->root) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 955; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_xroot); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_xroot); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_cur_scope->__pyx_v_xroot = __pyx_t_9; + __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1097 - * count = currcount - * scores = [] - * for model in models: # <<<<<<<<<<<<<< - * scores.append(model(f, e, count, fcount[f], num_samples)) - * yield Rule(self.category, f, e, - */ - if (PyList_CheckExact(__pyx_cur_scope->__pyx_v_models) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_models)) { - __pyx_t_15 = __pyx_cur_scope->__pyx_v_models; __Pyx_INCREF(__pyx_t_15); __pyx_t_25 = 0; - __pyx_t_27 = NULL; - } else { - __pyx_t_25 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_models); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_27 = Py_TYPE(__pyx_t_15)->tp_iternext; - } - for (;;) { - if (!__pyx_t_27 && PyList_CheckExact(__pyx_t_15)) { - if (__pyx_t_25 >= PyList_GET_SIZE(__pyx_t_15)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_14 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_25); __Pyx_INCREF(__pyx_t_14); __pyx_t_25++; - #else - __pyx_t_14 = PySequence_ITEM(__pyx_t_15, __pyx_t_25); __pyx_t_25++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_27 && PyTuple_CheckExact(__pyx_t_15)) { - if (__pyx_t_25 >= PyTuple_GET_SIZE(__pyx_t_15)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_25); __Pyx_INCREF(__pyx_t_14); __pyx_t_25++; - #else - __pyx_t_14 = PySequence_ITEM(__pyx_t_15, __pyx_t_25); __pyx_t_25++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_14 = __pyx_t_27(__pyx_t_15); - if (unlikely(!__pyx_t_14)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1097; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_14); - } - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_model); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_model); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_cur_scope->__pyx_v_model = __pyx_t_14; - __pyx_t_14 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1098 - * scores = [] - * for model in models: - * scores.append(model(f, e, count, fcount[f], num_samples)) # <<<<<<<<<<<<<< - * yield Rule(self.category, f, e, - * scores=scores, word_alignments=alignment) - */ - __pyx_t_14 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_fcount), __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_14) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_num_samples); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_f); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_e); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_e); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_e); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_count); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_cur_scope->__pyx_v_count); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_count); - PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_14 = 0; - __pyx_t_10 = 0; - __pyx_t_10 = PyObject_Call(__pyx_cur_scope->__pyx_v_model, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_scores, __pyx_t_10); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - } - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":956 + * else: + * xroot = ExtendedTrieNode(suffix_link=self.rules.root, phrase_location=PhraseLocation()) + * self.rules.root.children[x1] = xroot # <<<<<<<<<<<<<< + * + * for i in range(self.min_gap_size, len(fwords)): + */ + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_self->rules->root, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (__Pyx_SetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_x1, __pyx_cur_scope->__pyx_v_xroot, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + } + __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1099 - * for model in models: - * scores.append(model(f, e, count, fcount[f], num_samples)) - * yield Rule(self.category, f, e, # <<<<<<<<<<<<<< - * scores=scores, word_alignments=alignment) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":958 + * self.rules.root.children[x1] = xroot * + * for i in range(self.min_gap_size, len(fwords)): # <<<<<<<<<<<<<< + * for alt in range(0, len(fwords[i])): + * if fwords[i][alt][0] != EPSILON: */ - __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->category); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_cur_scope->__pyx_v_f); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_e); - PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_cur_scope->__pyx_v_e); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_e); - __pyx_t_15 = 0; - __pyx_t_15 = PyDict_New(); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_15)); + __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 958; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + for (__pyx_t_4 = __pyx_cur_scope->__pyx_v_self->min_gap_size; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) { + __pyx_cur_scope->__pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1100 - * scores.append(model(f, e, count, fcount[f], num_samples)) - * yield Rule(self.category, f, e, - * scores=scores, word_alignments=alignment) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":959 * - * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: + * for i in range(self.min_gap_size, len(fwords)): + * for alt in range(0, len(fwords[i])): # <<<<<<<<<<<<<< + * if fwords[i][alt][0] != EPSILON: + * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) */ - if (PyDict_SetItem(__pyx_t_15, ((PyObject *)__pyx_n_s__scores), ((PyObject *)__pyx_cur_scope->__pyx_v_scores)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (PyDict_SetItem(__pyx_t_15, ((PyObject *)__pyx_n_s__word_alignments), __pyx_cur_scope->__pyx_v_alignment) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Rule)), ((PyObject *)__pyx_t_10), ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; - __Pyx_XGIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; - __pyx_cur_scope->__pyx_t_2 = __pyx_t_5; - __pyx_cur_scope->__pyx_t_3 = __pyx_t_6; - __Pyx_XGIVEREF(__pyx_t_9); - __pyx_cur_scope->__pyx_t_4 = __pyx_t_9; - __Pyx_XGIVEREF(__pyx_t_12); - __pyx_cur_scope->__pyx_t_5 = __pyx_t_12; - __pyx_cur_scope->__pyx_t_6 = __pyx_t_18; - __pyx_cur_scope->__pyx_t_7 = __pyx_t_21; - __pyx_cur_scope->__pyx_t_8 = __pyx_t_22; - __pyx_cur_scope->__pyx_t_9 = __pyx_t_23; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - /* return from generator, yielding value */ - __pyx_generator->resume_label = 1; - return __pyx_r; - __pyx_L59_resume_from_yield:; - __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; - __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - __pyx_cur_scope->__pyx_t_1 = 0; - __Pyx_XGOTREF(__pyx_t_2); - __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; - __pyx_t_6 = __pyx_cur_scope->__pyx_t_3; - __pyx_t_9 = __pyx_cur_scope->__pyx_t_4; - __pyx_cur_scope->__pyx_t_4 = 0; - __Pyx_XGOTREF(__pyx_t_9); - __pyx_t_12 = __pyx_cur_scope->__pyx_t_5; - __pyx_cur_scope->__pyx_t_5 = 0; - __Pyx_XGOTREF(__pyx_t_12); - __pyx_t_18 = __pyx_cur_scope->__pyx_t_6; - __pyx_t_21 = __pyx_cur_scope->__pyx_t_7; - __pyx_t_22 = __pyx_cur_scope->__pyx_t_8; - __pyx_t_23 = __pyx_cur_scope->__pyx_t_9; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L45; - } - __pyx_L45:; - goto __pyx_L40; - } - __pyx_L40:; - goto __pyx_L32; - } - __pyx_L32:; + __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_5 = PyObject_Length(__pyx_t_9); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_cur_scope->__pyx_v_alt = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1102 - * scores=scores, word_alignments=alignment) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":960 + * for i in range(self.min_gap_size, len(fwords)): + * for alt in range(0, len(fwords[i])): + * if fwords[i][alt][0] != EPSILON: # <<<<<<<<<<<<<< + * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) * - * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: # <<<<<<<<<<<<<< - * for alt_id in range(len(fwords[i+spanlen])): - * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) */ - __pyx_t_21 = PyObject_Length(__pyx_cur_scope->__pyx_v_phrase); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_19 = (__pyx_t_21 < __pyx_cur_scope->__pyx_v_self->max_length); - if (__pyx_t_19) { - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_2 = PyNumber_Add(__pyx_t_9, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_21 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_21); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_t_9, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_8) { - __pyx_t_3 = PyNumber_Add(__pyx_cur_scope->__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_9, Py_LE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_28 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_29 = __pyx_t_28; - } else { - __pyx_t_29 = __pyx_t_8; - } - __pyx_t_8 = __pyx_t_29; - } else { - __pyx_t_8 = __pyx_t_19; - } + __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_9, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_10, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_9, __pyx_t_10, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1103 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":961 + * for alt in range(0, len(fwords[i])): + * if fwords[i][alt][0] != EPSILON: + * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) # <<<<<<<<<<<<<< * - * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: - * for alt_id in range(len(fwords[i+spanlen])): # <<<<<<<<<<<<<< - * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) - * num_subpatterns = arity + * next_states = [] */ - __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = PyNumber_Add(__pyx_t_2, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_i - __pyx_cur_scope->__pyx_v_self->min_gap_size)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fwords, __pyx_t_9); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_21 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_21; __pyx_t_18+=1) { - __pyx_cur_scope->__pyx_v_alt_id = __pyx_t_18; + __pyx_t_7 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_x1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_7 = 0; + __pyx_t_7 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_13 = PyTuple_New(7); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_xroot); + PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_cur_scope->__pyx_v_xroot); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_xroot); + PyTuple_SET_ITEM(__pyx_t_13, 5, ((PyObject *)__pyx_t_12)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_12)); + PyTuple_SET_ITEM(__pyx_t_13, 6, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + __pyx_t_3 = 0; + __pyx_t_10 = 0; + __pyx_t_9 = 0; + __pyx_t_2 = 0; + __pyx_t_12 = 0; + __pyx_t_7 = 0; + __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_frontier, ((PyObject *)__pyx_t_13)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0; + goto __pyx_L14; + } + __pyx_L14:; + } + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1104 - * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: - * for alt_id in range(len(fwords[i+spanlen])): - * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) # <<<<<<<<<<<<<< - * num_subpatterns = arity - * if not is_shadow_path: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":963 + * frontier.append((i-self.min_gap_size, i, alt, self.min_gap_size, xroot, (x1,), True)) + * + * next_states = [] # <<<<<<<<<<<<<< + * for i in range(len(fwords)): + * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) */ - __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_k); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_3 = PyNumber_Add(__pyx_t_9, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt_id); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_15 = PyNumber_Add(__pyx_cur_scope->__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_node); - PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_cur_scope->__pyx_v_node); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_node); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_phrase); - PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_cur_scope->__pyx_v_phrase); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_phrase); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_cur_scope->__pyx_v_is_shadow_path); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - __pyx_t_2 = 0; - __pyx_t_3 = 0; - __pyx_t_9 = 0; - __pyx_t_15 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_new_frontier, ((PyObject *)__pyx_t_10)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - } + __pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __Pyx_GIVEREF(((PyObject *)__pyx_t_13)); + __pyx_cur_scope->__pyx_v_next_states = __pyx_t_13; + __pyx_t_13 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1105 - * for alt_id in range(len(fwords[i+spanlen])): - * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) - * num_subpatterns = arity # <<<<<<<<<<<<<< - * if not is_shadow_path: - * num_subpatterns = num_subpatterns + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":964 + * + * next_states = [] + * for i in range(len(fwords)): # <<<<<<<<<<<<<< + * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) + * */ - __pyx_cur_scope->__pyx_v_num_subpatterns = __pyx_cur_scope->__pyx_v_arity; + __pyx_t_1 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 964; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_1; __pyx_t_4+=1) { + __pyx_cur_scope->__pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1106 - * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) - * num_subpatterns = arity - * if not is_shadow_path: # <<<<<<<<<<<<<< - * num_subpatterns = num_subpatterns + 1 - * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":965 + * next_states = [] + * for i in range(len(fwords)): + * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) # <<<<<<<<<<<<<< + * + * while len(frontier) > 0: */ - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_19 = (!__pyx_t_8); - if (__pyx_t_19) { + __pyx_t_13 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__get_next_states); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_13); + __pyx_t_7 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_12 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_fwords); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_t_7 = 0; + __pyx_t_12 = 0; + __pyx_t_12 = PyObject_Call(__pyx_t_13, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_next_states, __pyx_t_12); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1107 - * num_subpatterns = arity - * if not is_shadow_path: - * num_subpatterns = num_subpatterns + 1 # <<<<<<<<<<<<<< - * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: - * xcat = sym_setindex(self.category, arity+1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":967 + * next_states.append(self.get_next_states(fwords,i,self.min_gap_size)) + * + * while len(frontier) > 0: # <<<<<<<<<<<<<< + * new_frontier = [] + * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: */ - __pyx_cur_scope->__pyx_v_num_subpatterns = (__pyx_cur_scope->__pyx_v_num_subpatterns + 1); - goto __pyx_L63; - } - __pyx_L63:; + while (1) { + __pyx_t_1 = PyList_GET_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_frontier)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = (__pyx_t_1 > 0); + if (!__pyx_t_8) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1108 - * if not is_shadow_path: - * num_subpatterns = num_subpatterns + 1 - * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: # <<<<<<<<<<<<<< - * xcat = sym_setindex(self.category, arity+1) - * xnode = node.children[xcat] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":968 + * + * while len(frontier) > 0: + * new_frontier = [] # <<<<<<<<<<<<<< + * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: + * word_id = fwords[i][alt][0] */ - __pyx_t_21 = PyObject_Length(__pyx_cur_scope->__pyx_v_phrase); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_19 = ((__pyx_t_21 + 1) < __pyx_cur_scope->__pyx_v_self->max_length); - if (__pyx_t_19) { - __pyx_t_8 = (__pyx_cur_scope->__pyx_v_arity < __pyx_cur_scope->__pyx_v_self->max_nonterminals); - if (__pyx_t_8) { - __pyx_t_29 = (__pyx_cur_scope->__pyx_v_num_subpatterns < __pyx_cur_scope->__pyx_v_self->max_chunks); - __pyx_t_28 = __pyx_t_29; - } else { - __pyx_t_28 = __pyx_t_8; - } - __pyx_t_8 = __pyx_t_28; - } else { - __pyx_t_8 = __pyx_t_19; - } - if (__pyx_t_8) { + __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 968; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_12)); + __pyx_cur_scope->__pyx_v_new_frontier = __pyx_t_12; + __pyx_t_12 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1109 - * num_subpatterns = num_subpatterns + 1 - * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: - * xcat = sym_setindex(self.category, arity+1) # <<<<<<<<<<<<<< - * xnode = node.children[xcat] - * # I put spanlen=1 below - */ - __pyx_cur_scope->__pyx_v_xcat = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, (__pyx_cur_scope->__pyx_v_arity + 1)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1110 - * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: - * xcat = sym_setindex(self.category, arity+1) - * xnode = node.children[xcat] # <<<<<<<<<<<<<< - * # I put spanlen=1 below - * key = tuple([self.min_gap_size, i, 1, pathlen]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":969 + * while len(frontier) > 0: + * new_frontier = [] + * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: # <<<<<<<<<<<<<< + * word_id = fwords[i][alt][0] + * spanlen = fwords[i][alt][2] */ - __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_10, __pyx_cur_scope->__pyx_v_xcat, sizeof(int), PyInt_FromLong); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_xnode); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_xnode); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_xnode = __pyx_t_15; - __pyx_t_15 = 0; + __pyx_t_12 = ((PyObject *)__pyx_cur_scope->__pyx_v_frontier); __Pyx_INCREF(__pyx_t_12); __pyx_t_1 = 0; + for (;;) { + if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_12)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_12, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; + #else + __pyx_t_2 = PySequence_ITEM(__pyx_t_12, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { + PyObject* sequence = __pyx_t_2; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 7)) { + if (size > 7) __Pyx_RaiseTooManyValuesError(7); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_13 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_10 = PyTuple_GET_ITEM(sequence, 3); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 4); + __pyx_t_14 = PyTuple_GET_ITEM(sequence, 5); + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 6); + } else { + __pyx_t_13 = PyList_GET_ITEM(sequence, 0); + __pyx_t_7 = PyList_GET_ITEM(sequence, 1); + __pyx_t_9 = PyList_GET_ITEM(sequence, 2); + __pyx_t_10 = PyList_GET_ITEM(sequence, 3); + __pyx_t_3 = PyList_GET_ITEM(sequence, 4); + __pyx_t_14 = PyList_GET_ITEM(sequence, 5); + __pyx_t_15 = PyList_GET_ITEM(sequence, 6); + } + __Pyx_INCREF(__pyx_t_13); + __Pyx_INCREF(__pyx_t_7); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(__pyx_t_3); + __Pyx_INCREF(__pyx_t_14); + __Pyx_INCREF(__pyx_t_15); + #else + Py_ssize_t i; + PyObject** temps[7] = {&__pyx_t_13,&__pyx_t_7,&__pyx_t_9,&__pyx_t_10,&__pyx_t_3,&__pyx_t_14,&__pyx_t_15}; + for (i=0; i < 7; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + *(temps[i]) = item; + } + #endif + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + } else + { + Py_ssize_t index = -1; + PyObject** temps[7] = {&__pyx_t_13,&__pyx_t_7,&__pyx_t_9,&__pyx_t_10,&__pyx_t_3,&__pyx_t_14,&__pyx_t_15}; + __pyx_t_16 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_16); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_17 = Py_TYPE(__pyx_t_16)->tp_iternext; + for (index=0; index < 7; index++) { + PyObject* item = __pyx_t_17(__pyx_t_16); if (unlikely(!item)) goto __pyx_L21_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_16), 7) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = NULL; + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + goto __pyx_L22_unpacking_done; + __pyx_L21_unpacking_failed:; + __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; + __pyx_t_17 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L22_unpacking_done:; + } + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_13); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0; + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_cur_scope->__pyx_v_k = __pyx_t_4; + __pyx_cur_scope->__pyx_v_i = __pyx_t_6; + __pyx_cur_scope->__pyx_v_alt = __pyx_t_18; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_pathlen = __pyx_t_10; + __pyx_t_10 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_node = __pyx_t_3; + __pyx_t_3 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_prefix); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_prefix); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_cur_scope->__pyx_v_prefix = __pyx_t_14; + __pyx_t_14 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_is_shadow_path = __pyx_t_15; + __pyx_t_15 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1112 - * xnode = node.children[xcat] - * # I put spanlen=1 below - * key = tuple([self.min_gap_size, i, 1, pathlen]) # <<<<<<<<<<<<<< - * frontier_nodes = [] - * if (key in nodes_isteps_away_buffer): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":970 + * new_frontier = [] + * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: + * word_id = fwords[i][alt][0] # <<<<<<<<<<<<<< + * spanlen = fwords[i][alt][2] + * # TODO get rid of k -- pathlen is replacing it */ - __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyList_New(4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __Pyx_INCREF(__pyx_int_1); - PyList_SET_ITEM(__pyx_t_9, 2, __pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); - PyList_SET_ITEM(__pyx_t_9, 3, __pyx_cur_scope->__pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); - __pyx_t_15 = 0; - __pyx_t_10 = 0; - __pyx_t_10 = ((PyObject *)PyList_AsTuple(__pyx_t_9)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_10)); - __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; - __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); - __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_10)); - __pyx_cur_scope->__pyx_v_key = __pyx_t_10; - __pyx_t_10 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_2, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_15, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_word_id); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_word_id); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_word_id = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1113 - * # I put spanlen=1 below - * key = tuple([self.min_gap_size, i, 1, pathlen]) - * frontier_nodes = [] # <<<<<<<<<<<<<< - * if (key in nodes_isteps_away_buffer): - * frontier_nodes = nodes_isteps_away_buffer[key] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":971 + * for k, i, alt, pathlen, node, prefix, is_shadow_path in frontier: + * word_id = fwords[i][alt][0] + * spanlen = fwords[i][alt][2] # <<<<<<<<<<<<<< + * # TODO get rid of k -- pathlen is replacing it + * if word_id == EPSILON: */ - __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_frontier_nodes); - __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_frontier_nodes); - __Pyx_GIVEREF(((PyObject *)__pyx_t_10)); - __pyx_cur_scope->__pyx_v_frontier_nodes = ((PyObject *)__pyx_t_10); - __pyx_t_10 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_fwords, __pyx_cur_scope->__pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_2, __pyx_cur_scope->__pyx_v_alt, sizeof(int), PyInt_FromLong); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_15, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_spanlen); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_spanlen); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_spanlen = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1114 - * key = tuple([self.min_gap_size, i, 1, pathlen]) - * frontier_nodes = [] - * if (key in nodes_isteps_away_buffer): # <<<<<<<<<<<<<< - * frontier_nodes = nodes_isteps_away_buffer[key] - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":973 + * spanlen = fwords[i][alt][2] + * # TODO get rid of k -- pathlen is replacing it + * if word_id == EPSILON: # <<<<<<<<<<<<<< + * # skipping because word_id is epsilon + * if i+spanlen >= len(fwords): */ - __pyx_t_8 = ((PyDict_Contains(((PyObject *)__pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer), ((PyObject *)__pyx_cur_scope->__pyx_v_key)))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__pyx_t_8) { + __pyx_t_2 = PyInt_FromLong(__pyx_v_3_sa_EPSILON); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_word_id, __pyx_t_2, Py_EQ); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1115 - * frontier_nodes = [] - * if (key in nodes_isteps_away_buffer): - * frontier_nodes = nodes_isteps_away_buffer[key] # <<<<<<<<<<<<<< - * else: - * frontier_nodes = self.get_all_nodes_isteps_away(self.min_gap_size, i, 1, pathlen, fwords, next_states, reachable_buffer) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":975 + * if word_id == EPSILON: + * # skipping because word_id is epsilon + * if i+spanlen >= len(fwords): # <<<<<<<<<<<<<< + * continue + * for nualt in range(0,len(fwords[i+spanlen])): */ - __pyx_t_10 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer), ((PyObject *)__pyx_cur_scope->__pyx_v_key)); if (!__pyx_t_10) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_frontier_nodes); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_frontier_nodes); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_cur_scope->__pyx_v_frontier_nodes = __pyx_t_10; - __pyx_t_10 = 0; - goto __pyx_L65; - } - /*else*/ { + __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_2 = PyNumber_Add(__pyx_t_15, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_5 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_14 = PyObject_RichCompare(__pyx_t_2, __pyx_t_15, Py_GE); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1117 - * frontier_nodes = nodes_isteps_away_buffer[key] - * else: - * frontier_nodes = self.get_all_nodes_isteps_away(self.min_gap_size, i, 1, pathlen, fwords, next_states, reachable_buffer) # <<<<<<<<<<<<<< - * nodes_isteps_away_buffer[key] = frontier_nodes - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":976 + * # skipping because word_id is epsilon + * if i+spanlen >= len(fwords): + * continue # <<<<<<<<<<<<<< + * for nualt in range(0,len(fwords[i+spanlen])): + * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) */ - __pyx_t_10 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_123); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - __Pyx_INCREF(__pyx_int_1); - PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_int_1); - __Pyx_GIVEREF(__pyx_int_1); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); - PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_cur_scope->__pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fwords); - PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_cur_scope->__pyx_v_fwords); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fwords); - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_next_states)); - PyTuple_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_cur_scope->__pyx_v_next_states)); - __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_next_states)); - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_reachable_buffer)); - PyTuple_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_cur_scope->__pyx_v_reachable_buffer)); - __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_reachable_buffer)); - __pyx_t_9 = 0; - __pyx_t_15 = 0; - __pyx_t_15 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_frontier_nodes); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_frontier_nodes); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_cur_scope->__pyx_v_frontier_nodes = __pyx_t_15; - __pyx_t_15 = 0; + goto __pyx_L19_continue; + goto __pyx_L24; + } + __pyx_L24:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1118 - * else: - * frontier_nodes = self.get_all_nodes_isteps_away(self.min_gap_size, i, 1, pathlen, fwords, next_states, reachable_buffer) - * nodes_isteps_away_buffer[key] = frontier_nodes # <<<<<<<<<<<<<< - * - * for (i, alt, pathlen) in frontier_nodes: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":977 + * if i+spanlen >= len(fwords): + * continue + * for nualt in range(0,len(fwords[i+spanlen])): # <<<<<<<<<<<<<< + * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) + * continue */ - if (PyDict_SetItem(((PyObject *)__pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer), ((PyObject *)__pyx_cur_scope->__pyx_v_key), __pyx_cur_scope->__pyx_v_frontier_nodes) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_L65:; + __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_15 = PyNumber_Add(__pyx_t_14, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_14 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fwords, __pyx_t_15); if (!__pyx_t_14) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_5 = PyObject_Length(__pyx_t_14); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_5; __pyx_t_18+=1) { + __pyx_cur_scope->__pyx_v_nualt = __pyx_t_18; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1120 - * nodes_isteps_away_buffer[key] = frontier_nodes + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":978 + * continue + * for nualt in range(0,len(fwords[i+spanlen])): + * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) # <<<<<<<<<<<<<< + * continue * - * for (i, alt, pathlen) in frontier_nodes: # <<<<<<<<<<<<<< - * new_frontier.append((k, i, alt, pathlen, xnode, phrase +(xcat,), is_shadow_path)) - * frontier = new_frontier */ - if (PyList_CheckExact(__pyx_cur_scope->__pyx_v_frontier_nodes) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_frontier_nodes)) { - __pyx_t_15 = __pyx_cur_scope->__pyx_v_frontier_nodes; __Pyx_INCREF(__pyx_t_15); __pyx_t_21 = 0; - __pyx_t_27 = NULL; - } else { - __pyx_t_21 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_frontier_nodes); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_27 = Py_TYPE(__pyx_t_15)->tp_iternext; - } - for (;;) { - if (!__pyx_t_27 && PyList_CheckExact(__pyx_t_15)) { - if (__pyx_t_21 >= PyList_GET_SIZE(__pyx_t_15)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_21); __Pyx_INCREF(__pyx_t_3); __pyx_t_21++; - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_15, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_27 && PyTuple_CheckExact(__pyx_t_15)) { - if (__pyx_t_21 >= PyTuple_GET_SIZE(__pyx_t_15)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_21); __Pyx_INCREF(__pyx_t_3); __pyx_t_21++; - #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_15, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_3 = __pyx_t_27(__pyx_t_15); - if (unlikely(!__pyx_t_3)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_3); - } - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 3)) { - if (size > 3) __Pyx_RaiseTooManyValuesError(3); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 2); - } else { - __pyx_t_10 = PyList_GET_ITEM(sequence, 0); - __pyx_t_9 = PyList_GET_ITEM(sequence, 1); - __pyx_t_2 = PyList_GET_ITEM(sequence, 2); - } - __Pyx_INCREF(__pyx_t_10); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_10 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - { - Py_ssize_t index = -1; - __pyx_t_14 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_17 = Py_TYPE(__pyx_t_14)->tp_iternext; - index = 0; __pyx_t_10 = __pyx_t_17(__pyx_t_14); if (unlikely(!__pyx_t_10)) goto __pyx_L68_unpacking_failed; - __Pyx_GOTREF(__pyx_t_10); - index = 1; __pyx_t_9 = __pyx_t_17(__pyx_t_14); if (unlikely(!__pyx_t_9)) goto __pyx_L68_unpacking_failed; - __Pyx_GOTREF(__pyx_t_9); - index = 2; __pyx_t_2 = __pyx_t_17(__pyx_t_14); if (unlikely(!__pyx_t_2)) goto __pyx_L68_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_14), 3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_17 = NULL; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - goto __pyx_L69_unpacking_done; - __pyx_L68_unpacking_failed:; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_17 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L69_unpacking_done:; - } - __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_10); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_cur_scope->__pyx_v_i = __pyx_t_18; - __pyx_cur_scope->__pyx_v_alt = __pyx_t_6; - __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_DECREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_t_2); - __pyx_cur_scope->__pyx_v_pathlen = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_k); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_2 = PyNumber_Add(__pyx_t_15, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_nualt); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_3 = PyTuple_New(7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); + PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_cur_scope->__pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_node); + PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_cur_scope->__pyx_v_node); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_prefix); + PyTuple_SET_ITEM(__pyx_t_3, 5, __pyx_cur_scope->__pyx_v_prefix); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_prefix); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + PyTuple_SET_ITEM(__pyx_t_3, 6, __pyx_cur_scope->__pyx_v_is_shadow_path); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + __pyx_t_14 = 0; + __pyx_t_2 = 0; + __pyx_t_15 = 0; + __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_frontier, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1121 - * - * for (i, alt, pathlen) in frontier_nodes: - * new_frontier.append((k, i, alt, pathlen, xnode, phrase +(xcat,), is_shadow_path)) # <<<<<<<<<<<<<< - * frontier = new_frontier + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":979 + * for nualt in range(0,len(fwords[i+spanlen])): + * frontier.append((k, i+spanlen, nualt, pathlen, node, prefix, is_shadow_path)) + * continue # <<<<<<<<<<<<<< * + * phrase = prefix + (word_id,) */ - __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_xcat); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __pyx_t_10 = 0; - __pyx_t_10 = PyNumber_Add(__pyx_cur_scope->__pyx_v_phrase, ((PyObject *)__pyx_t_14)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; - __pyx_t_14 = PyTuple_New(7); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_3); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_9); - __Pyx_GIVEREF(__pyx_t_9); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); - PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_cur_scope->__pyx_v_pathlen); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_xnode); - PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_cur_scope->__pyx_v_xnode); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_xnode); - PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - __Pyx_INCREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_cur_scope->__pyx_v_is_shadow_path); - __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_is_shadow_path); - __pyx_t_3 = 0; - __pyx_t_2 = 0; - __pyx_t_9 = 0; - __pyx_t_10 = 0; - __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_new_frontier, ((PyObject *)__pyx_t_14)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; - } - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - goto __pyx_L64; - } - __pyx_L64:; - goto __pyx_L60; + goto __pyx_L19_continue; + goto __pyx_L23; } - __pyx_L60:; - __pyx_L19_continue:; - } - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_L23:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1122 - * for (i, alt, pathlen) in frontier_nodes: - * new_frontier.append((k, i, alt, pathlen, xnode, phrase +(xcat,), is_shadow_path)) - * frontier = new_frontier # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":981 + * continue * - * stop_time = monitor_cpu() + * phrase = prefix + (word_id,) # <<<<<<<<<<<<<< + * hiero_phrase = Phrase(phrase) + * arity = hiero_phrase.arity() */ - __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); - __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_frontier)); - __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_frontier)); - __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); - __pyx_cur_scope->__pyx_v_frontier = __pyx_cur_scope->__pyx_v_new_frontier; - } + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_word_id); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_cur_scope->__pyx_v_word_id); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_word_id); + __pyx_t_15 = PyNumber_Add(__pyx_cur_scope->__pyx_v_prefix, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_phrase); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_phrase); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_phrase = __pyx_t_15; + __pyx_t_15 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1124 - * frontier = new_frontier + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":982 + * + * phrase = prefix + (word_id,) + * hiero_phrase = Phrase(phrase) # <<<<<<<<<<<<<< + * arity = hiero_phrase.arity() * - * stop_time = monitor_cpu() # <<<<<<<<<<<<<< - * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) - * gc.collect() */ - __pyx_t_12 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __Pyx_GIVEREF(__pyx_t_12); - __pyx_cur_scope->__pyx_v_stop_time = __pyx_t_12; - __pyx_t_12 = 0; + __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_phrase); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_cur_scope->__pyx_v_phrase); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_phrase); + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_hiero_phrase = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1125 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":983 + * phrase = prefix + (word_id,) + * hiero_phrase = Phrase(phrase) + * arity = hiero_phrase.arity() # <<<<<<<<<<<<<< * - * stop_time = monitor_cpu() - * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) # <<<<<<<<<<<<<< - * gc.collect() - * logger.info(" Extract time = %f seconds", self.extract_time) + * lookup_required = False */ - __pyx_t_12 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_15 = PyObject_GetAttr(__pyx_t_12, __pyx_n_s__info); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_start_time); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __pyx_t_14 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_stop_time, __pyx_t_12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_124)); - PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_kp_s_124)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_124)); - PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_t_14 = 0; - __pyx_t_14 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase), __pyx_n_s__arity); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_15 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_15); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_cur_scope->__pyx_v_arity = __pyx_t_18; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1126 - * stop_time = monitor_cpu() - * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) - * gc.collect() # <<<<<<<<<<<<<< - * logger.info(" Extract time = %f seconds", self.extract_time) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":985 + * arity = hiero_phrase.arity() * + * lookup_required = False # <<<<<<<<<<<<<< + * if word_id in node.children: + * if node.children[word_id] is None: */ - __pyx_t_14 = __Pyx_GetName(__pyx_m, __pyx_n_s__gc); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_12 = PyObject_GetAttr(__pyx_t_14, __pyx_n_s__collect); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_cur_scope->__pyx_v_lookup_required = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1127 - * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) - * gc.collect() - * logger.info(" Extract time = %f seconds", self.extract_time) # <<<<<<<<<<<<<< - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":986 * + * lookup_required = False + * if word_id in node.children: # <<<<<<<<<<<<<< + * if node.children[word_id] is None: + * # Path dead-ends at this node */ - __pyx_t_14 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_12 = PyObject_GetAttr(__pyx_t_14, __pyx_n_s__info); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_12); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_14 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->extract_time); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = PyTuple_New(2); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_125)); - PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_kp_s_125)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_125)); - PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_t_14 = 0; - __pyx_t_14 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - PyErr_SetNone(PyExc_StopIteration); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_XDECREF(__pyx_t_10); - __Pyx_XDECREF(__pyx_t_12); - __Pyx_XDECREF(__pyx_t_13); - __Pyx_XDECREF(__pyx_t_14); - __Pyx_XDECREF(__pyx_t_15); - __Pyx_XDECREF(__pyx_t_16); - __Pyx_AddTraceback("input", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_L0:; - __Pyx_XDECREF(__pyx_r); - __pyx_generator->resume_label = -1; - __Pyx_Generator_clear((PyObject*)__pyx_generator); - __Pyx_RefNannyFinishContext(); - return NULL; -} - -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1130 - * - * - * cdef int find_fixpoint(self, # <<<<<<<<<<<<<< - * int f_low, f_high, - * int* f_links_low, int* f_links_high, - */ + __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_8 = ((PySequence_Contains(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_t_8) { -static int __pyx_f_3_sa_23HieroCachingRuleFactory_find_fixpoint(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_f_low, PyObject *__pyx_v_f_high, int *__pyx_v_f_links_low, int *__pyx_v_f_links_high, int *__pyx_v_e_links_low, int *__pyx_v_e_links_high, int __pyx_v_e_in_low, int __pyx_v_e_in_high, int *__pyx_v_e_low, int *__pyx_v_e_high, int *__pyx_v_f_back_low, int *__pyx_v_f_back_high, int __pyx_v_f_sent_len, int __pyx_v_e_sent_len, int __pyx_v_max_f_len, int __pyx_v_max_e_len, int __pyx_v_min_fx_size, int __pyx_v_min_ex_size, int __pyx_v_max_new_x, int __pyx_v_allow_low_x, int __pyx_v_allow_high_x, int __pyx_v_allow_arbitrary_x, CYTHON_UNUSED int __pyx_v_write_log) { - int __pyx_v_e_low_prev; - int __pyx_v_e_high_prev; - int __pyx_v_f_low_prev; - int __pyx_v_f_high_prev; - int __pyx_v_new_x; - int __pyx_v_new_low_x; - int __pyx_v_new_high_x; - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - PyObject *__pyx_t_7 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("find_fixpoint", 0); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":987 + * lookup_required = False + * if word_id in node.children: + * if node.children[word_id] is None: # <<<<<<<<<<<<<< + * # Path dead-ends at this node + * continue + */ + __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_3 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_8 = (__pyx_t_3 == Py_None); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1145 - * cdef int e_low_prev, e_high_prev, f_low_prev, f_high_prev, new_x, new_low_x, new_high_x - * - * e_low[0] = e_in_low # <<<<<<<<<<<<<< - * e_high[0] = e_in_high - * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":989 + * if node.children[word_id] is None: + * # Path dead-ends at this node + * continue # <<<<<<<<<<<<<< + * else: + * # Path continues at this node */ - (__pyx_v_e_low[0]) = __pyx_v_e_in_low; + goto __pyx_L19_continue; + goto __pyx_L28; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1146 - * - * e_low[0] = e_in_low - * e_high[0] = e_in_high # <<<<<<<<<<<<<< - * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) - * if e_low[0] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":992 + * else: + * # Path continues at this node + * node = node.children[word_id] # <<<<<<<<<<<<<< + * else: + * if node.suffix_link is None: */ - (__pyx_v_e_high[0]) = __pyx_v_e_in_high; + __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_15 = PyObject_GetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_node = __pyx_t_15; + __pyx_t_15 = 0; + } + __pyx_L28:; + goto __pyx_L27; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1147 - * e_low[0] = e_in_low - * e_high[0] = e_in_high - * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) # <<<<<<<<<<<<<< - * if e_low[0] == -1: - * # low-priority corner case: if phrase w is unaligned, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":994 + * node = node.children[word_id] + * else: + * if node.suffix_link is None: # <<<<<<<<<<<<<< + * # Current node is root; lookup required + * lookup_required = True */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_f_high); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, __pyx_v_f_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_low, __pyx_v_e_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_8 = (__pyx_t_15 == Py_None); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1148 - * e_high[0] = e_in_high - * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) - * if e_low[0] == -1: # <<<<<<<<<<<<<< - * # low-priority corner case: if phrase w is unaligned, - * # but we don't require aligned terminals, then returning + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":996 + * if node.suffix_link is None: + * # Current node is root; lookup required + * lookup_required = True # <<<<<<<<<<<<<< + * else: + * if word_id in node.suffix_link.children: */ - __pyx_t_3 = ((__pyx_v_e_low[0]) == -1); - if (__pyx_t_3) { + __pyx_cur_scope->__pyx_v_lookup_required = 1; + goto __pyx_L29; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1154 - * # rule X -> X_1 w X_2 / X_1 X_2. This is probably - * # not worth the bother, though. - * return 0 # <<<<<<<<<<<<<< - * elif e_in_low != -1 and e_low[0] != e_in_low: - * if e_in_low - e_low[0] < min_ex_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":998 + * lookup_required = True + * else: + * if word_id in node.suffix_link.children: # <<<<<<<<<<<<<< + * if node.suffix_link.children[word_id] is None: + * # Suffix link reports path is dead end */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L3; - } + __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_8 = ((PySequence_Contains(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 998; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1155 - * # not worth the bother, though. - * return 0 - * elif e_in_low != -1 and e_low[0] != e_in_low: # <<<<<<<<<<<<<< - * if e_in_low - e_low[0] < min_ex_size: - * e_low[0] = e_in_low - min_ex_size + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":999 + * else: + * if word_id in node.suffix_link.children: + * if node.suffix_link.children[word_id] is None: # <<<<<<<<<<<<<< + * # Suffix link reports path is dead end + * node.children[word_id] = None */ - __pyx_t_3 = (__pyx_v_e_in_low != -1); - if (__pyx_t_3) { - __pyx_t_4 = ((__pyx_v_e_low[0]) != __pyx_v_e_in_low); - __pyx_t_5 = __pyx_t_4; - } else { - __pyx_t_5 = __pyx_t_3; - } - if (__pyx_t_5) { + __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_15 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_8 = (__pyx_t_3 == Py_None); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1156 - * return 0 - * elif e_in_low != -1 and e_low[0] != e_in_low: - * if e_in_low - e_low[0] < min_ex_size: # <<<<<<<<<<<<<< - * e_low[0] = e_in_low - min_ex_size - * if e_low[0] < 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1001 + * if node.suffix_link.children[word_id] is None: + * # Suffix link reports path is dead end + * node.children[word_id] = None # <<<<<<<<<<<<<< + * continue + * else: */ - __pyx_t_5 = ((__pyx_v_e_in_low - (__pyx_v_e_low[0])) < __pyx_v_min_ex_size); - if (__pyx_t_5) { + __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyObject_SetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id, Py_None) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1157 - * elif e_in_low != -1 and e_low[0] != e_in_low: - * if e_in_low - e_low[0] < min_ex_size: - * e_low[0] = e_in_low - min_ex_size # <<<<<<<<<<<<<< - * if e_low[0] < 0: - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1002 + * # Suffix link reports path is dead end + * node.children[word_id] = None + * continue # <<<<<<<<<<<<<< + * else: + * # Suffix link indicates lookup is reqired */ - (__pyx_v_e_low[0]) = (__pyx_v_e_in_low - __pyx_v_min_ex_size); + goto __pyx_L19_continue; + goto __pyx_L31; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1158 - * if e_in_low - e_low[0] < min_ex_size: - * e_low[0] = e_in_low - min_ex_size - * if e_low[0] < 0: # <<<<<<<<<<<<<< - * return 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1005 + * else: + * # Suffix link indicates lookup is reqired + * lookup_required = True # <<<<<<<<<<<<<< + * else: + * #ERROR: We never get here */ - __pyx_t_5 = ((__pyx_v_e_low[0]) < 0); - if (__pyx_t_5) { + __pyx_cur_scope->__pyx_v_lookup_required = 1; + } + __pyx_L31:; + goto __pyx_L30; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1159 - * e_low[0] = e_in_low - min_ex_size - * if e_low[0] < 0: - * return 0 # <<<<<<<<<<<<<< - * - * if e_high[0] - e_low[0] > max_e_len: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1008 + * else: + * #ERROR: We never get here + * raise Exception("Keyword trie error") # <<<<<<<<<<<<<< + * # checking whether lookup_required + * if lookup_required: */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L5; + __pyx_t_3 = PyObject_Call(__pyx_builtin_Exception, ((PyObject *)__pyx_k_tuple_124), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1008; __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[8]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L30:; + } + __pyx_L29:; } - __pyx_L5:; - goto __pyx_L4; - } - __pyx_L4:; - goto __pyx_L3; - } - __pyx_L3:; + __pyx_L27:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1161 - * return 0 - * - * if e_high[0] - e_low[0] > max_e_len: # <<<<<<<<<<<<<< - * return 0 - * elif e_in_high != -1 and e_high[0] != e_in_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1010 + * raise Exception("Keyword trie error") + * # checking whether lookup_required + * if lookup_required: # <<<<<<<<<<<<<< + * new_node = None + * if is_shadow_path: */ - __pyx_t_5 = (((__pyx_v_e_high[0]) - (__pyx_v_e_low[0])) > __pyx_v_max_e_len); - if (__pyx_t_5) { + if (__pyx_cur_scope->__pyx_v_lookup_required) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1162 - * - * if e_high[0] - e_low[0] > max_e_len: - * return 0 # <<<<<<<<<<<<<< - * elif e_in_high != -1 and e_high[0] != e_in_high: - * if e_high[0] - e_in_high < min_ex_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1011 + * # checking whether lookup_required + * if lookup_required: + * new_node = None # <<<<<<<<<<<<<< + * if is_shadow_path: + * # Extending shadow path */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L6; - } + __Pyx_INCREF(Py_None); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_GIVEREF(Py_None); + __pyx_cur_scope->__pyx_v_new_node = Py_None; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1163 - * if e_high[0] - e_low[0] > max_e_len: - * return 0 - * elif e_in_high != -1 and e_high[0] != e_in_high: # <<<<<<<<<<<<<< - * if e_high[0] - e_in_high < min_ex_size: - * e_high[0] = e_in_high + min_ex_size + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1012 + * if lookup_required: + * new_node = None + * if is_shadow_path: # <<<<<<<<<<<<<< + * # Extending shadow path + * # on the shadow path we don't do any search, we just use info from suffix link */ - __pyx_t_5 = (__pyx_v_e_in_high != -1); - if (__pyx_t_5) { - __pyx_t_3 = ((__pyx_v_e_high[0]) != __pyx_v_e_in_high); - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_5; - } - if (__pyx_t_4) { + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1012; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1164 - * return 0 - * elif e_in_high != -1 and e_high[0] != e_in_high: - * if e_high[0] - e_in_high < min_ex_size: # <<<<<<<<<<<<<< - * e_high[0] = e_in_high + min_ex_size - * if e_high[0] > e_sent_len: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1015 + * # Extending shadow path + * # on the shadow path we don't do any search, we just use info from suffix link + * new_node = ExtendedTrieNode(phrase_location=node.suffix_link.children[word_id].phrase_location, # <<<<<<<<<<<<<< + * suffix_link=node.suffix_link.children[word_id], + * phrase=hiero_phrase) */ - __pyx_t_4 = (((__pyx_v_e_high[0]) - __pyx_v_e_in_high) < __pyx_v_min_ex_size); - if (__pyx_t_4) { + __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_3)); + __pyx_t_15 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_2 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__children); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = PyObject_GetItem(__pyx_t_2, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1165 - * elif e_in_high != -1 and e_high[0] != e_in_high: - * if e_high[0] - e_in_high < min_ex_size: - * e_high[0] = e_in_high + min_ex_size # <<<<<<<<<<<<<< - * if e_high[0] > e_sent_len: - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1016 + * # on the shadow path we don't do any search, we just use info from suffix link + * new_node = ExtendedTrieNode(phrase_location=node.suffix_link.children[word_id].phrase_location, + * suffix_link=node.suffix_link.children[word_id], # <<<<<<<<<<<<<< + * phrase=hiero_phrase) + * else: */ - (__pyx_v_e_high[0]) = (__pyx_v_e_in_high + __pyx_v_min_ex_size); + __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__children); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyObject_GetItem(__pyx_t_15, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1016; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__suffix_link), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1166 - * if e_high[0] - e_in_high < min_ex_size: - * e_high[0] = e_in_high + min_ex_size - * if e_high[0] > e_sent_len: # <<<<<<<<<<<<<< - * return 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1017 + * new_node = ExtendedTrieNode(phrase_location=node.suffix_link.children[word_id].phrase_location, + * suffix_link=node.suffix_link.children[word_id], + * phrase=hiero_phrase) # <<<<<<<<<<<<<< + * else: + * if arity > 0: */ - __pyx_t_4 = ((__pyx_v_e_high[0]) > __pyx_v_e_sent_len); - if (__pyx_t_4) { + if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__phrase), ((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_new_node = __pyx_t_2; + __pyx_t_2 = 0; + goto __pyx_L33; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1167 - * e_high[0] = e_in_high + min_ex_size - * if e_high[0] > e_sent_len: - * return 0 # <<<<<<<<<<<<<< - * - * f_back_low[0] = -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1019 + * phrase=hiero_phrase) + * else: + * if arity > 0: # <<<<<<<<<<<<<< + * # Intersecting because of arity > 0 + * phrase_location = self.intersect(node, node.suffix_link.children[word_id], hiero_phrase) */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L8; - } - __pyx_L8:; - goto __pyx_L7; - } - __pyx_L7:; - goto __pyx_L6; - } - __pyx_L6:; + __pyx_t_8 = (__pyx_cur_scope->__pyx_v_arity > 0); + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1169 - * return 0 - * - * f_back_low[0] = -1 # <<<<<<<<<<<<<< - * f_back_high[0] = -1 - * f_low_prev = f_low + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1021 + * if arity > 0: + * # Intersecting because of arity > 0 + * phrase_location = self.intersect(node, node.suffix_link.children[word_id], hiero_phrase) # <<<<<<<<<<<<<< + * else: + * # Suffix array search */ - (__pyx_v_f_back_low[0]) = -1; + __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __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_GetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->intersect(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_node, __pyx_t_2, __pyx_cur_scope->__pyx_v_hiero_phrase)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); + __pyx_t_3 = 0; + goto __pyx_L34; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1170 - * - * f_back_low[0] = -1 - * f_back_high[0] = -1 # <<<<<<<<<<<<<< - * f_low_prev = f_low - * f_high_prev = f_high + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1024 + * else: + * # Suffix array search + * phrase_location = node.phrase_location # <<<<<<<<<<<<<< + * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) + * if sa_range is not None: */ - (__pyx_v_f_back_high[0]) = -1; + __pyx_t_3 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (!(likely(((__pyx_t_3) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_3_sa_PhraseLocation))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1024; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1171 - * f_back_low[0] = -1 - * f_back_high[0] = -1 - * f_low_prev = f_low # <<<<<<<<<<<<<< - * f_high_prev = f_high - * new_x = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1025 + * # Suffix array search + * phrase_location = node.phrase_location + * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) # <<<<<<<<<<<<<< + * if sa_range is not None: + * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) */ - __pyx_v_f_low_prev = __pyx_v_f_low; + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self->fsa), __pyx_n_s__lookup); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_phrase, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_2 = PyBytes_FromString(__pyx_f_3_sa_sym_tostring(__pyx_t_18)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_2)); + __pyx_t_5 = PyObject_Length(__pyx_cur_scope->__pyx_v_phrase); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_15 = PyInt_FromSsize_t((__pyx_t_5 - 1)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_phrase_location->sa_low); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_10 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_phrase_location->sa_high); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = PyTuple_New(4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_2)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); + PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_2 = 0; + __pyx_t_15 = 0; + __pyx_t_14 = 0; + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sa_range); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_sa_range); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_sa_range = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1172 - * f_back_high[0] = -1 - * f_low_prev = f_low - * f_high_prev = f_high # <<<<<<<<<<<<<< - * new_x = 0 - * new_low_x = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1026 + * phrase_location = node.phrase_location + * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) + * if sa_range is not None: # <<<<<<<<<<<<<< + * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) + * else: */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_f_high); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_f_high_prev = __pyx_t_1; + __pyx_t_8 = (__pyx_cur_scope->__pyx_v_sa_range != Py_None); + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1173 - * f_low_prev = f_low - * f_high_prev = f_high - * new_x = 0 # <<<<<<<<<<<<<< - * new_low_x = 0 - * new_high_x = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1027 + * sa_range = self.fsa.lookup(sym_tostring(phrase[-1]), len(phrase)-1, phrase_location.sa_low, phrase_location.sa_high) + * if sa_range is not None: + * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) # <<<<<<<<<<<<<< + * else: + * phrase_location = None */ - __pyx_v_new_x = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1174 - * f_high_prev = f_high - * new_x = 0 - * new_low_x = 0 # <<<<<<<<<<<<<< - * new_high_x = 0 + __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_10)); + __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_sa_range, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__sa_low), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_sa_range, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__sa_high), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_PhraseLocation)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_9); + __pyx_t_9 = 0; + goto __pyx_L35; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1029 + * phrase_location = PhraseLocation(sa_low=sa_range[0], sa_high=sa_range[1]) + * else: + * phrase_location = None # <<<<<<<<<<<<<< * + * if phrase_location is None: */ - __pyx_v_new_low_x = 0; + __Pyx_INCREF(Py_None); + __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)); + __Pyx_GIVEREF(Py_None); + __pyx_cur_scope->__pyx_v_phrase_location = ((struct __pyx_obj_3_sa_PhraseLocation *)Py_None); + } + __pyx_L35:; + } + __pyx_L34:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1175 - * new_x = 0 - * new_low_x = 0 - * new_high_x = 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1031 + * phrase_location = None * - * while True: + * if phrase_location is None: # <<<<<<<<<<<<<< + * node.children[word_id] = None + * # Search failed */ - __pyx_v_new_high_x = 0; + __pyx_t_8 = (((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location) == Py_None); + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1177 - * new_high_x = 0 - * - * while True: # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1032 * - * if f_back_low[0] == -1: + * if phrase_location is None: + * node.children[word_id] = None # <<<<<<<<<<<<<< + * # Search failed + * continue */ - while (1) { - if (!1) break; + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (PyObject_SetItem(__pyx_t_9, __pyx_cur_scope->__pyx_v_word_id, Py_None) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1179 - * while True: - * - * if f_back_low[0] == -1: # <<<<<<<<<<<<<< - * self.find_projection(e_low[0], e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1034 + * node.children[word_id] = None + * # Search failed + * continue # <<<<<<<<<<<<<< + * # Search succeeded + * suffix_link = self.rules.root */ - __pyx_t_4 = ((__pyx_v_f_back_low[0]) == -1); - if (__pyx_t_4) { + goto __pyx_L19_continue; + goto __pyx_L36; + } + __pyx_L36:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1180 - * - * if f_back_low[0] == -1: - * self.find_projection(e_low[0], e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) # <<<<<<<<<<<<<< - * else: - * self.find_projection(e_low[0], e_low_prev, e_links_low, e_links_high, f_back_low, f_back_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1036 + * continue + * # Search succeeded + * suffix_link = self.rules.root # <<<<<<<<<<<<<< + * if node.suffix_link is not None: + * suffix_link = node.suffix_link.children[word_id] */ - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, (__pyx_v_e_low[0]), (__pyx_v_e_high[0]), __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_f_back_low, __pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - goto __pyx_L11; - } - /*else*/ { + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self->rules->root); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_suffix_link); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_suffix_link); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self->rules->root); + __pyx_cur_scope->__pyx_v_suffix_link = __pyx_cur_scope->__pyx_v_self->rules->root; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1182 - * self.find_projection(e_low[0], e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) - * else: - * self.find_projection(e_low[0], e_low_prev, e_links_low, e_links_high, f_back_low, f_back_high) # <<<<<<<<<<<<<< - * self.find_projection(e_high_prev, e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1037 + * # Search succeeded + * suffix_link = self.rules.root + * if node.suffix_link is not None: # <<<<<<<<<<<<<< + * suffix_link = node.suffix_link.children[word_id] + * new_node = ExtendedTrieNode(phrase_location=phrase_location, */ - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, (__pyx_v_e_low[0]), __pyx_v_e_low_prev, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_f_back_low, __pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_8 = (__pyx_t_9 != Py_None); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1183 - * else: - * self.find_projection(e_low[0], e_low_prev, e_links_low, e_links_high, f_back_low, f_back_high) - * self.find_projection(e_high_prev, e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) # <<<<<<<<<<<<<< - * - * if f_back_low[0] > f_low: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1038 + * suffix_link = self.rules.root + * if node.suffix_link is not None: + * suffix_link = node.suffix_link.children[word_id] # <<<<<<<<<<<<<< + * new_node = ExtendedTrieNode(phrase_location=phrase_location, + * suffix_link=suffix_link, */ - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, __pyx_v_e_high_prev, (__pyx_v_e_high[0]), __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_f_back_low, __pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_L11:; + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyObject_GetItem(__pyx_t_10, __pyx_cur_scope->__pyx_v_word_id); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_suffix_link); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_suffix_link); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_cur_scope->__pyx_v_suffix_link = __pyx_t_9; + __pyx_t_9 = 0; + goto __pyx_L37; + } + __pyx_L37:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1185 - * self.find_projection(e_high_prev, e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) - * - * if f_back_low[0] > f_low: # <<<<<<<<<<<<<< - * f_back_low[0] = f_low - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1039 + * if node.suffix_link is not None: + * suffix_link = node.suffix_link.children[word_id] + * new_node = ExtendedTrieNode(phrase_location=phrase_location, # <<<<<<<<<<<<<< + * suffix_link=suffix_link, + * phrase=hiero_phrase) */ - __pyx_t_4 = ((__pyx_v_f_back_low[0]) > __pyx_v_f_low); - if (__pyx_t_4) { + __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_9)); + if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__phrase_location), ((PyObject *)__pyx_cur_scope->__pyx_v_phrase_location)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1186 - * - * if f_back_low[0] > f_low: - * f_back_low[0] = f_low # <<<<<<<<<<<<<< - * - * if f_back_high[0] < f_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1040 + * suffix_link = node.suffix_link.children[word_id] + * new_node = ExtendedTrieNode(phrase_location=phrase_location, + * suffix_link=suffix_link, # <<<<<<<<<<<<<< + * phrase=hiero_phrase) + * node.children[word_id] = new_node */ - (__pyx_v_f_back_low[0]) = __pyx_v_f_low; - goto __pyx_L12; - } - __pyx_L12:; + if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__suffix_link), __pyx_cur_scope->__pyx_v_suffix_link) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1188 - * f_back_low[0] = f_low - * - * if f_back_high[0] < f_high: # <<<<<<<<<<<<<< - * f_back_high[0] = f_high - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1041 + * new_node = ExtendedTrieNode(phrase_location=phrase_location, + * suffix_link=suffix_link, + * phrase=hiero_phrase) # <<<<<<<<<<<<<< + * node.children[word_id] = new_node + * node = new_node */ - __pyx_t_2 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_v_f_high, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_4) { + if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__phrase), ((PyObject *)__pyx_cur_scope->__pyx_v_hiero_phrase)) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1039; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_new_node = __pyx_t_10; + __pyx_t_10 = 0; + } + __pyx_L33:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1189 - * - * if f_back_high[0] < f_high: - * f_back_high[0] = f_high # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1042 + * suffix_link=suffix_link, + * phrase=hiero_phrase) + * node.children[word_id] = new_node # <<<<<<<<<<<<<< + * node = new_node * - * if f_back_low[0] == f_low_prev and f_back_high[0] == f_high_prev: */ - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_f_high); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - (__pyx_v_f_back_high[0]) = __pyx_t_1; - goto __pyx_L13; - } - __pyx_L13:; + __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + if (PyObject_SetItem(__pyx_t_10, __pyx_cur_scope->__pyx_v_word_id, __pyx_cur_scope->__pyx_v_new_node) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1191 - * f_back_high[0] = f_high - * - * if f_back_low[0] == f_low_prev and f_back_high[0] == f_high_prev: # <<<<<<<<<<<<<< - * return 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1043 + * phrase=hiero_phrase) + * node.children[word_id] = new_node + * node = new_node # <<<<<<<<<<<<<< * + * '''Automatically add a trailing X node, if allowed -- */ - __pyx_t_4 = ((__pyx_v_f_back_low[0]) == __pyx_v_f_low_prev); - if (__pyx_t_4) { - __pyx_t_5 = ((__pyx_v_f_back_high[0]) == __pyx_v_f_high_prev); - __pyx_t_3 = __pyx_t_5; - } else { - __pyx_t_3 = __pyx_t_4; - } - if (__pyx_t_3) { + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_new_node); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_new_node); + __pyx_cur_scope->__pyx_v_node = __pyx_cur_scope->__pyx_v_new_node; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1192 - * - * if f_back_low[0] == f_low_prev and f_back_high[0] == f_high_prev: - * return 1 # <<<<<<<<<<<<<< - * - * if allow_low_x == 0 and f_back_low[0] < f_low: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1048 + * This should happen before we get to extraction (so that + * the node will exist if needed)''' + * if arity < self.max_nonterminals: # <<<<<<<<<<<<<< + * xcat_index = arity+1 + * xcat = sym_setindex(self.category, xcat_index) */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L14; - } - __pyx_L14:; + __pyx_t_8 = (__pyx_cur_scope->__pyx_v_arity < __pyx_cur_scope->__pyx_v_self->max_nonterminals); + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1194 - * return 1 - * - * if allow_low_x == 0 and f_back_low[0] < f_low: # <<<<<<<<<<<<<< - * # FAIL: f phrase is not tight - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1049 + * the node will exist if needed)''' + * if arity < self.max_nonterminals: + * xcat_index = arity+1 # <<<<<<<<<<<<<< + * xcat = sym_setindex(self.category, xcat_index) + * suffix_link_xcat_index = xcat_index */ - __pyx_t_3 = (__pyx_v_allow_low_x == 0); - if (__pyx_t_3) { - __pyx_t_4 = ((__pyx_v_f_back_low[0]) < __pyx_v_f_low); - __pyx_t_5 = __pyx_t_4; - } else { - __pyx_t_5 = __pyx_t_3; - } - if (__pyx_t_5) { + __pyx_t_10 = PyInt_FromLong((__pyx_cur_scope->__pyx_v_arity + 1)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_xcat_index); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_xcat_index); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_xcat_index = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1196 - * if allow_low_x == 0 and f_back_low[0] < f_low: - * # FAIL: f phrase is not tight - * return 0 # <<<<<<<<<<<<<< - * - * if f_back_high[0] - f_back_low[0] > max_f_len: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1050 + * if arity < self.max_nonterminals: + * xcat_index = arity+1 + * xcat = sym_setindex(self.category, xcat_index) # <<<<<<<<<<<<<< + * suffix_link_xcat_index = xcat_index + * if is_shadow_path: */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L15; - } - __pyx_L15:; + __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_cur_scope->__pyx_v_xcat_index); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_cur_scope->__pyx_v_xcat = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, __pyx_t_18); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1198 - * return 0 - * - * if f_back_high[0] - f_back_low[0] > max_f_len: # <<<<<<<<<<<<<< - * # FAIL: f back projection is too wide - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1051 + * xcat_index = arity+1 + * xcat = sym_setindex(self.category, xcat_index) + * suffix_link_xcat_index = xcat_index # <<<<<<<<<<<<<< + * if is_shadow_path: + * suffix_link_xcat_index = xcat_index-1 */ - __pyx_t_5 = (((__pyx_v_f_back_high[0]) - (__pyx_v_f_back_low[0])) > __pyx_v_max_f_len); - if (__pyx_t_5) { + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_xcat_index); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_xcat_index); + __pyx_cur_scope->__pyx_v_suffix_link_xcat_index = __pyx_cur_scope->__pyx_v_xcat_index; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1200 - * if f_back_high[0] - f_back_low[0] > max_f_len: - * # FAIL: f back projection is too wide - * return 0 # <<<<<<<<<<<<<< - * - * if allow_high_x == 0 and f_back_high[0] > f_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1052 + * xcat = sym_setindex(self.category, xcat_index) + * suffix_link_xcat_index = xcat_index + * if is_shadow_path: # <<<<<<<<<<<<<< + * suffix_link_xcat_index = xcat_index-1 + * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L16; - } - __pyx_L16:; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1202 - * return 0 - * - * if allow_high_x == 0 and f_back_high[0] > f_high: # <<<<<<<<<<<<<< - * # FAIL: extension on high side not allowed - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1053 + * suffix_link_xcat_index = xcat_index + * if is_shadow_path: + * suffix_link_xcat_index = xcat_index-1 # <<<<<<<<<<<<<< + * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) + * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, */ - __pyx_t_5 = (__pyx_v_allow_high_x == 0); - if (__pyx_t_5) { - __pyx_t_6 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyObject_RichCompare(__pyx_t_6, __pyx_v_f_high, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_5; - } - if (__pyx_t_4) { + __pyx_t_10 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_xcat_index, __pyx_int_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1053; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_suffix_link_xcat_index = __pyx_t_10; + __pyx_t_10 = 0; + goto __pyx_L39; + } + __pyx_L39:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1204 - * if allow_high_x == 0 and f_back_high[0] > f_high: - * # FAIL: extension on high side not allowed - * return 0 # <<<<<<<<<<<<<< - * - * if f_low != f_back_low[0]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1054 + * if is_shadow_path: + * suffix_link_xcat_index = xcat_index-1 + * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) # <<<<<<<<<<<<<< + * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, + * suffix_link=node.suffix_link.children[suffix_link_xcat], */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L17; - } - __pyx_L17:; + __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_cur_scope->__pyx_v_suffix_link_xcat_index); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_cur_scope->__pyx_v_suffix_link_xcat = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, __pyx_t_18); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1206 - * return 0 - * - * if f_low != f_back_low[0]: # <<<<<<<<<<<<<< - * if new_low_x == 0: - * if new_x >= max_new_x: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1055 + * suffix_link_xcat_index = xcat_index-1 + * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) + * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, # <<<<<<<<<<<<<< + * suffix_link=node.suffix_link.children[suffix_link_xcat], + * phrase= Phrase(phrase + (xcat,))) */ - __pyx_t_4 = (__pyx_v_f_low != (__pyx_v_f_back_low[0])); - if (__pyx_t_4) { + __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_10)); + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__phrase_location), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1207 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1056 + * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) + * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, + * suffix_link=node.suffix_link.children[suffix_link_xcat], # <<<<<<<<<<<<<< + * phrase= Phrase(phrase + (xcat,))) * - * if f_low != f_back_low[0]: - * if new_low_x == 0: # <<<<<<<<<<<<<< - * if new_x >= max_new_x: - * # FAIL: extension required on low side violates max # of gaps */ - __pyx_t_4 = (__pyx_v_new_low_x == 0); - if (__pyx_t_4) { + __pyx_t_9 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__suffix_link); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = PyObject_GetAttr(__pyx_t_9, __pyx_n_s__children); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = __Pyx_GetItemInt(__pyx_t_3, __pyx_cur_scope->__pyx_v_suffix_link_xcat, sizeof(int), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__suffix_link), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1208 - * if f_low != f_back_low[0]: - * if new_low_x == 0: - * if new_x >= max_new_x: # <<<<<<<<<<<<<< - * # FAIL: extension required on low side violates max # of gaps - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1057 + * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, + * suffix_link=node.suffix_link.children[suffix_link_xcat], + * phrase= Phrase(phrase + (xcat,))) # <<<<<<<<<<<<<< + * + * # sample from range */ - __pyx_t_4 = (__pyx_v_new_x >= __pyx_v_max_new_x); - if (__pyx_t_4) { + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_xcat); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Add(__pyx_cur_scope->__pyx_v_phrase, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__phrase), __pyx_t_9) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_ExtendedTrieNode)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1210 - * if new_x >= max_new_x: - * # FAIL: extension required on low side violates max # of gaps - * return 0 # <<<<<<<<<<<<<< - * else: - * new_x = new_x + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1055 + * suffix_link_xcat_index = xcat_index-1 + * suffix_link_xcat = sym_setindex(self.category, suffix_link_xcat_index) + * node.children[xcat] = ExtendedTrieNode(phrase_location=node.phrase_location, # <<<<<<<<<<<<<< + * suffix_link=node.suffix_link.children[suffix_link_xcat], + * phrase= Phrase(phrase + (xcat,))) */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L20; + __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + if (__Pyx_SetItemInt(__pyx_t_10, __pyx_cur_scope->__pyx_v_xcat, __pyx_t_9, sizeof(int), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1055; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L38; } - /*else*/ { + __pyx_L38:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1212 - * return 0 - * else: - * new_x = new_x + 1 # <<<<<<<<<<<<<< - * new_low_x = 1 - * if f_low - f_back_low[0] < min_fx_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1060 + * + * # sample from range + * if not is_shadow_path: # <<<<<<<<<<<<<< + * sample = self.sampler.sample(node.phrase_location) + * num_subpatterns = ( node.phrase_location).num_subpatterns */ - __pyx_v_new_x = (__pyx_v_new_x + 1); + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = (!__pyx_t_8); + if (__pyx_t_19) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1213 - * else: - * new_x = new_x + 1 - * new_low_x = 1 # <<<<<<<<<<<<<< - * if f_low - f_back_low[0] < min_fx_size: - * f_back_low[0] = f_low - min_fx_size + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1061 + * # sample from range + * if not is_shadow_path: + * sample = self.sampler.sample(node.phrase_location) # <<<<<<<<<<<<<< + * num_subpatterns = ( node.phrase_location).num_subpatterns + * chunklen = IntList(initial_len=num_subpatterns) */ - __pyx_v_new_low_x = 1; - } - __pyx_L20:; - goto __pyx_L19; - } - __pyx_L19:; + __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self->sampler), __pyx_n_s__sample); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + if (!(likely(((__pyx_t_10) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_10, __pyx_ptype_3_sa_IntList))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_sample)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_sample)); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_sample = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_10); + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1214 - * new_x = new_x + 1 - * new_low_x = 1 - * if f_low - f_back_low[0] < min_fx_size: # <<<<<<<<<<<<<< - * f_back_low[0] = f_low - min_fx_size - * if f_back_high[0] - f_back_low[0] > max_f_len: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1062 + * if not is_shadow_path: + * sample = self.sampler.sample(node.phrase_location) + * num_subpatterns = ( node.phrase_location).num_subpatterns # <<<<<<<<<<<<<< + * chunklen = IntList(initial_len=num_subpatterns) + * for j from 0 <= j < num_subpatterns: */ - __pyx_t_4 = ((__pyx_v_f_low - (__pyx_v_f_back_low[0])) < __pyx_v_min_fx_size); - if (__pyx_t_4) { + __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__phrase_location); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_num_subpatterns = ((struct __pyx_obj_3_sa_PhraseLocation *)__pyx_t_10)->num_subpatterns; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1215 - * new_low_x = 1 - * if f_low - f_back_low[0] < min_fx_size: - * f_back_low[0] = f_low - min_fx_size # <<<<<<<<<<<<<< - * if f_back_high[0] - f_back_low[0] > max_f_len: - * # FAIL: extension required on low side violates max initial length + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1063 + * sample = self.sampler.sample(node.phrase_location) + * num_subpatterns = ( node.phrase_location).num_subpatterns + * chunklen = IntList(initial_len=num_subpatterns) # <<<<<<<<<<<<<< + * for j from 0 <= j < num_subpatterns: + * chunklen.arr[j] = hiero_phrase.chunklen(j) */ - (__pyx_v_f_back_low[0]) = (__pyx_v_f_low - __pyx_v_min_fx_size); + __pyx_t_10 = PyDict_New(); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_10)); + __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_num_subpatterns); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + if (PyDict_SetItem(__pyx_t_10, ((PyObject *)__pyx_n_s__initial_len), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_chunklen)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_chunklen)); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_chunklen = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1216 - * if f_low - f_back_low[0] < min_fx_size: - * f_back_low[0] = f_low - min_fx_size - * if f_back_high[0] - f_back_low[0] > max_f_len: # <<<<<<<<<<<<<< - * # FAIL: extension required on low side violates max initial length - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1064 + * num_subpatterns = ( node.phrase_location).num_subpatterns + * chunklen = IntList(initial_len=num_subpatterns) + * for j from 0 <= j < num_subpatterns: # <<<<<<<<<<<<<< + * chunklen.arr[j] = hiero_phrase.chunklen(j) + * extracts = [] */ - __pyx_t_4 = (((__pyx_v_f_back_high[0]) - (__pyx_v_f_back_low[0])) > __pyx_v_max_f_len); - if (__pyx_t_4) { + __pyx_t_18 = __pyx_cur_scope->__pyx_v_num_subpatterns; + for (__pyx_cur_scope->__pyx_v_j = 0; __pyx_cur_scope->__pyx_v_j < __pyx_t_18; __pyx_cur_scope->__pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1218 - * if f_back_high[0] - f_back_low[0] > max_f_len: - * # FAIL: extension required on low side violates max initial length - * return 0 # <<<<<<<<<<<<<< - * if f_back_low[0] < 0: - * # FAIL: extension required on low side violates sentence boundary + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1065 + * chunklen = IntList(initial_len=num_subpatterns) + * for j from 0 <= j < num_subpatterns: + * chunklen.arr[j] = hiero_phrase.chunklen(j) # <<<<<<<<<<<<<< + * extracts = [] + * j = 0 */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L22; - } - __pyx_L22:; + (__pyx_cur_scope->__pyx_v_chunklen->arr[__pyx_cur_scope->__pyx_v_j]) = ((struct __pyx_vtabstruct_3_sa_Phrase *)__pyx_cur_scope->__pyx_v_hiero_phrase->__pyx_vtab)->chunklen(__pyx_cur_scope->__pyx_v_hiero_phrase, __pyx_cur_scope->__pyx_v_j); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1219 - * # FAIL: extension required on low side violates max initial length - * return 0 - * if f_back_low[0] < 0: # <<<<<<<<<<<<<< - * # FAIL: extension required on low side violates sentence boundary - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1066 + * for j from 0 <= j < num_subpatterns: + * chunklen.arr[j] = hiero_phrase.chunklen(j) + * extracts = [] # <<<<<<<<<<<<<< + * j = 0 + * extract_start = monitor_cpu() */ - __pyx_t_4 = ((__pyx_v_f_back_low[0]) < 0); - if (__pyx_t_4) { + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_extracts)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_extracts)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_cur_scope->__pyx_v_extracts = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1221 - * if f_back_low[0] < 0: - * # FAIL: extension required on low side violates sentence boundary - * return 0 # <<<<<<<<<<<<<< - * - * if f_high != f_back_high[0]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1067 + * chunklen.arr[j] = hiero_phrase.chunklen(j) + * extracts = [] + * j = 0 # <<<<<<<<<<<<<< + * extract_start = monitor_cpu() + * while j < sample.len: */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L23; - } - __pyx_L23:; - goto __pyx_L21; - } - __pyx_L21:; - goto __pyx_L18; - } - __pyx_L18:; + __pyx_cur_scope->__pyx_v_j = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1223 - * return 0 - * - * if f_high != f_back_high[0]: # <<<<<<<<<<<<<< - * if new_high_x == 0: - * if new_x >= max_new_x: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1068 + * extracts = [] + * j = 0 + * extract_start = monitor_cpu() # <<<<<<<<<<<<<< + * while j < sample.len: + * extract = [] */ - __pyx_t_2 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyObject_RichCompare(__pyx_v_f_high, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1223; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - if (__pyx_t_4) { + __pyx_t_3 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_extract_start); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_extract_start); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_extract_start = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1224 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1069 + * j = 0 + * extract_start = monitor_cpu() + * while j < sample.len: # <<<<<<<<<<<<<< + * extract = [] * - * if f_high != f_back_high[0]: - * if new_high_x == 0: # <<<<<<<<<<<<<< - * if new_x >= max_new_x: - * # FAIL: extension required on high side violates max # of gaps - */ - __pyx_t_4 = (__pyx_v_new_high_x == 0); - if (__pyx_t_4) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1225 - * if f_high != f_back_high[0]: - * if new_high_x == 0: - * if new_x >= max_new_x: # <<<<<<<<<<<<<< - * # FAIL: extension required on high side violates max # of gaps - * return 0 - */ - __pyx_t_4 = (__pyx_v_new_x >= __pyx_v_max_new_x); - if (__pyx_t_4) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1227 - * if new_x >= max_new_x: - * # FAIL: extension required on high side violates max # of gaps - * return 0 # <<<<<<<<<<<<<< - * else: - * new_x = new_x + 1 - */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L26; - } - /*else*/ { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1229 - * return 0 - * else: - * new_x = new_x + 1 # <<<<<<<<<<<<<< - * new_high_x = 1 - * if f_back_high[0] - f_high < min_fx_size: - */ - __pyx_v_new_x = (__pyx_v_new_x + 1); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1230 - * else: - * new_x = new_x + 1 - * new_high_x = 1 # <<<<<<<<<<<<<< - * if f_back_high[0] - f_high < min_fx_size: - * f_back_high[0] = f_high + min_fx_size - */ - __pyx_v_new_high_x = 1; - } - __pyx_L26:; - goto __pyx_L25; - } - __pyx_L25:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1231 - * new_x = new_x + 1 - * new_high_x = 1 - * if f_back_high[0] - f_high < min_fx_size: # <<<<<<<<<<<<<< - * f_back_high[0] = f_high + min_fx_size - * if f_back_high[0] - f_back_low[0] > max_f_len: - */ - __pyx_t_6 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_2 = PyNumber_Subtract(__pyx_t_6, __pyx_v_f_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyInt_FromLong(__pyx_v_min_fx_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1231; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if (__pyx_t_4) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1232 - * new_high_x = 1 - * if f_back_high[0] - f_high < min_fx_size: - * f_back_high[0] = f_high + min_fx_size # <<<<<<<<<<<<<< - * if f_back_high[0] - f_back_low[0] > max_f_len: - * # FAIL: extension required on high side violates max initial length - */ - __pyx_t_7 = PyInt_FromLong(__pyx_v_min_fx_size); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6 = PyNumber_Add(__pyx_v_f_high, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - (__pyx_v_f_back_high[0]) = __pyx_t_1; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1233 - * if f_back_high[0] - f_high < min_fx_size: - * f_back_high[0] = f_high + min_fx_size - * if f_back_high[0] - f_back_low[0] > max_f_len: # <<<<<<<<<<<<<< - * # FAIL: extension required on high side violates max initial length - * return 0 */ - __pyx_t_4 = (((__pyx_v_f_back_high[0]) - (__pyx_v_f_back_low[0])) > __pyx_v_max_f_len); - if (__pyx_t_4) { + while (1) { + __pyx_t_19 = (__pyx_cur_scope->__pyx_v_j < __pyx_cur_scope->__pyx_v_sample->len); + if (!__pyx_t_19) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1235 - * if f_back_high[0] - f_back_low[0] > max_f_len: - * # FAIL: extension required on high side violates max initial length - * return 0 # <<<<<<<<<<<<<< - * if f_back_high[0] > f_sent_len: - * # FAIL: extension required on high side violates sentence boundary + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1070 + * extract_start = monitor_cpu() + * while j < sample.len: + * extract = [] # <<<<<<<<<<<<<< + * + * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L28; - } - __pyx_L28:; + __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_extract); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_extract); + __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_cur_scope->__pyx_v_extract = ((PyObject *)__pyx_t_3); + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1236 - * # FAIL: extension required on high side violates max initial length - * return 0 - * if f_back_high[0] > f_sent_len: # <<<<<<<<<<<<<< - * # FAIL: extension required on high side violates sentence boundary - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1072 + * extract = [] + * + * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) # <<<<<<<<<<<<<< + * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) + * extracts.extend(extract) */ - __pyx_t_4 = ((__pyx_v_f_back_high[0]) > __pyx_v_f_sent_len); - if (__pyx_t_4) { + __pyx_f_3_sa_assign_matching((&__pyx_cur_scope->__pyx_v_matching), __pyx_cur_scope->__pyx_v_sample->arr, __pyx_cur_scope->__pyx_v_j, __pyx_cur_scope->__pyx_v_num_subpatterns, __pyx_cur_scope->__pyx_v_self->fda->sent_id->arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1238 - * if f_back_high[0] > f_sent_len: - * # FAIL: extension required on high side violates sentence boundary - * return 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1073 * - * e_low_prev = e_low[0] + * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) + * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) # <<<<<<<<<<<<<< + * extracts.extend(extract) + * j = j + num_subpatterns */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L29; - } - __pyx_L29:; - goto __pyx_L27; - } - __pyx_L27:; - goto __pyx_L24; - } - __pyx_L24:; + __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->extract(__pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_hiero_phrase, (&__pyx_cur_scope->__pyx_v_matching), __pyx_cur_scope->__pyx_v_chunklen->arr, __pyx_cur_scope->__pyx_v_num_subpatterns); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_extract); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_extract); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_extract = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1240 - * return 0 - * - * e_low_prev = e_low[0] # <<<<<<<<<<<<<< - * e_high_prev = e_high[0] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1074 + * assign_matching(&matching, sample.arr, j, num_subpatterns, self.fda.sent_id.arr) + * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) + * extracts.extend(extract) # <<<<<<<<<<<<<< + * j = j + num_subpatterns * */ - __pyx_v_e_low_prev = (__pyx_v_e_low[0]); + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_extracts), __pyx_n_s__extend); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_extract); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_cur_scope->__pyx_v_extract); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_extract); + __pyx_t_9 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1241 - * - * e_low_prev = e_low[0] - * e_high_prev = e_high[0] # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1075 + * extract = self.extract(hiero_phrase, &matching, chunklen.arr, num_subpatterns) + * extracts.extend(extract) + * j = j + num_subpatterns # <<<<<<<<<<<<<< * - * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) + * num_samples = sample.len/num_subpatterns */ - __pyx_v_e_high_prev = (__pyx_v_e_high[0]); + __pyx_cur_scope->__pyx_v_j = (__pyx_cur_scope->__pyx_v_j + __pyx_cur_scope->__pyx_v_num_subpatterns); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1243 - * e_high_prev = e_high[0] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1077 + * j = j + num_subpatterns * - * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) # <<<<<<<<<<<<<< - * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) - * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: + * num_samples = sample.len/num_subpatterns # <<<<<<<<<<<<<< + * extract_stop = monitor_cpu() + * self.extract_time = self.extract_time + extract_stop - extract_start */ - __pyx_t_6 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, (__pyx_v_f_back_low[0]), __pyx_v_f_low_prev, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_low, __pyx_v_e_high); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (unlikely(__pyx_cur_scope->__pyx_v_num_subpatterns == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + else if (sizeof(int) == sizeof(long) && unlikely(__pyx_cur_scope->__pyx_v_num_subpatterns == -1) && unlikely(UNARY_NEG_WOULD_OVERFLOW(__pyx_cur_scope->__pyx_v_sample->len))) { + PyErr_Format(PyExc_OverflowError, "value too large to perform division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1077; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_cur_scope->__pyx_v_num_samples = __Pyx_div_int(__pyx_cur_scope->__pyx_v_sample->len, __pyx_cur_scope->__pyx_v_num_subpatterns); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1244 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1078 * - * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) - * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) # <<<<<<<<<<<<<< - * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: - * return 1 + * num_samples = sample.len/num_subpatterns + * extract_stop = monitor_cpu() # <<<<<<<<<<<<<< + * self.extract_time = self.extract_time + extract_stop - extract_start + * if len(extracts) > 0: */ - __pyx_t_6 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, __pyx_v_f_high_prev, (__pyx_v_f_back_high[0]), __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_low, __pyx_v_e_high); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_9 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_extract_stop); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_extract_stop); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_cur_scope->__pyx_v_extract_stop = __pyx_t_9; + __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1245 - * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) - * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) - * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: # <<<<<<<<<<<<<< - * return 1 - * if allow_arbitrary_x == 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1079 + * num_samples = sample.len/num_subpatterns + * extract_stop = monitor_cpu() + * self.extract_time = self.extract_time + extract_stop - extract_start # <<<<<<<<<<<<<< + * if len(extracts) > 0: + * fcount = Counter() */ - __pyx_t_4 = ((__pyx_v_e_low[0]) == __pyx_v_e_low_prev); - if (__pyx_t_4) { - __pyx_t_5 = ((__pyx_v_e_high[0]) == __pyx_v_e_high_prev); - __pyx_t_3 = __pyx_t_5; - } else { - __pyx_t_3 = __pyx_t_4; - } - if (__pyx_t_3) { + __pyx_t_9 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->extract_time); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyNumber_Add(__pyx_t_9, __pyx_cur_scope->__pyx_v_extract_stop); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyNumber_Subtract(__pyx_t_10, __pyx_cur_scope->__pyx_v_extract_start); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_20 = __pyx_PyFloat_AsFloat(__pyx_t_9); if (unlikely((__pyx_t_20 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_cur_scope->__pyx_v_self->extract_time = __pyx_t_20; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1246 - * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) - * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: - * return 1 # <<<<<<<<<<<<<< - * if allow_arbitrary_x == 0: - * # FAIL: arbitrary expansion not permitted + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1080 + * extract_stop = monitor_cpu() + * self.extract_time = self.extract_time + extract_stop - extract_start + * if len(extracts) > 0: # <<<<<<<<<<<<<< + * fcount = Counter() + * fphrases = defaultdict(lambda: defaultdict(Counter)) */ - __pyx_r = 1; - goto __pyx_L0; - goto __pyx_L30; - } - __pyx_L30:; + __pyx_t_5 = PyList_GET_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_extracts)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1080; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = (__pyx_t_5 > 0); + if (__pyx_t_19) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1247 - * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: - * return 1 - * if allow_arbitrary_x == 0: # <<<<<<<<<<<<<< - * # FAIL: arbitrary expansion not permitted - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1081 + * self.extract_time = self.extract_time + extract_stop - extract_start + * if len(extracts) > 0: + * fcount = Counter() # <<<<<<<<<<<<<< + * fphrases = defaultdict(lambda: defaultdict(Counter)) + * for f, e, count, als in extracts: */ - __pyx_t_3 = (__pyx_v_allow_arbitrary_x == 0); - if (__pyx_t_3) { + __pyx_t_9 = __Pyx_GetName(__pyx_m, __pyx_n_s__Counter); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_10 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1081; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_fcount); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_fcount); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_fcount = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1249 - * if allow_arbitrary_x == 0: - * # FAIL: arbitrary expansion not permitted - * return 0 # <<<<<<<<<<<<<< - * if e_high[0] - e_low[0] > max_e_len: - * # FAIL: re-projection violates sentence max phrase length + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1082 + * if len(extracts) > 0: + * fcount = Counter() + * fphrases = defaultdict(lambda: defaultdict(Counter)) # <<<<<<<<<<<<<< + * for f, e, count, als in extracts: + * fcount[f] += count */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L31; - } - __pyx_L31:; + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_9 = __Pyx_CyFunction_NewEx(&__pyx_mdef_3_sa_23HieroCachingRuleFactory_5input_lambda1, 0, NULL, __pyx_n_s___sa, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_t_9 = 0; + __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_fphrases); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_fphrases); + __Pyx_GIVEREF(__pyx_t_9); + __pyx_cur_scope->__pyx_v_fphrases = __pyx_t_9; + __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1250 - * # FAIL: arbitrary expansion not permitted - * return 0 - * if e_high[0] - e_low[0] > max_e_len: # <<<<<<<<<<<<<< - * # FAIL: re-projection violates sentence max phrase length - * return 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1083 + * fcount = Counter() + * fphrases = defaultdict(lambda: defaultdict(Counter)) + * for f, e, count, als in extracts: # <<<<<<<<<<<<<< + * fcount[f] += count + * fphrases[f][e][als] += count */ - __pyx_t_3 = (((__pyx_v_e_high[0]) - (__pyx_v_e_low[0])) > __pyx_v_max_e_len); - if (__pyx_t_3) { + __pyx_t_9 = ((PyObject *)__pyx_cur_scope->__pyx_v_extracts); __Pyx_INCREF(__pyx_t_9); __pyx_t_5 = 0; + for (;;) { + if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_9)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; + #else + __pyx_t_3 = PySequence_ITEM(__pyx_t_9, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { + PyObject* sequence = __pyx_t_3; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 4)) { + if (size > 4) __Pyx_RaiseTooManyValuesError(4); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 2); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 3); + } else { + __pyx_t_10 = PyList_GET_ITEM(sequence, 0); + __pyx_t_14 = PyList_GET_ITEM(sequence, 1); + __pyx_t_15 = PyList_GET_ITEM(sequence, 2); + __pyx_t_2 = PyList_GET_ITEM(sequence, 3); + } + __Pyx_INCREF(__pyx_t_10); + __Pyx_INCREF(__pyx_t_14); + __Pyx_INCREF(__pyx_t_15); + __Pyx_INCREF(__pyx_t_2); + #else + Py_ssize_t i; + PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_14,&__pyx_t_15,&__pyx_t_2}; + for (i=0; i < 4; i++) { + PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + *(temps[i]) = item; + } + #endif + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } else + { + Py_ssize_t index = -1; + PyObject** temps[4] = {&__pyx_t_10,&__pyx_t_14,&__pyx_t_15,&__pyx_t_2}; + __pyx_t_7 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_17 = Py_TYPE(__pyx_t_7)->tp_iternext; + for (index=0; index < 4; index++) { + PyObject* item = __pyx_t_17(__pyx_t_7); if (unlikely(!item)) goto __pyx_L48_unpacking_failed; + __Pyx_GOTREF(item); + *(temps[index]) = item; + } + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_7), 4) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = NULL; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + goto __pyx_L49_unpacking_done; + __pyx_L48_unpacking_failed:; + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_17 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L49_unpacking_done:; + } + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_f); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_f); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_cur_scope->__pyx_v_f = __pyx_t_10; + __pyx_t_10 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_e); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_cur_scope->__pyx_v_e = __pyx_t_14; + __pyx_t_14 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_count); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_count); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_count = __pyx_t_15; + __pyx_t_15 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_als); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_als); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_als = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1252 - * if e_high[0] - e_low[0] > max_e_len: - * # FAIL: re-projection violates sentence max phrase length - * return 0 # <<<<<<<<<<<<<< - * f_low_prev = f_back_low[0] - * f_high_prev = f_back_high[0] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1084 + * fphrases = defaultdict(lambda: defaultdict(Counter)) + * for f, e, count, als in extracts: + * fcount[f] += count # <<<<<<<<<<<<<< + * fphrases[f][e][als] += count + * for f, elist in fphrases.iteritems(): */ - __pyx_r = 0; - goto __pyx_L0; - goto __pyx_L32; - } - __pyx_L32:; + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f); + __pyx_t_3 = __pyx_cur_scope->__pyx_v_f; + __pyx_t_2 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fcount, __pyx_t_3); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_cur_scope->__pyx_v_count); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyObject_SetItem(__pyx_cur_scope->__pyx_v_fcount, __pyx_t_3, __pyx_t_15) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1253 - * # FAIL: re-projection violates sentence max phrase length - * return 0 - * f_low_prev = f_back_low[0] # <<<<<<<<<<<<<< - * f_high_prev = f_back_high[0] - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1085 + * for f, e, count, als in extracts: + * fcount[f] += count + * fphrases[f][e][als] += count # <<<<<<<<<<<<<< + * for f, elist in fphrases.iteritems(): + * for e, alslist in elist.iteritems(): */ - __pyx_v_f_low_prev = (__pyx_v_f_back_low[0]); + __pyx_t_3 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fphrases, __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_15 = PyObject_GetItem(__pyx_t_3, __pyx_cur_scope->__pyx_v_e); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_als); + __pyx_t_3 = __pyx_cur_scope->__pyx_v_als; + __pyx_t_2 = PyObject_GetItem(__pyx_t_15, __pyx_t_3); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_14 = PyNumber_InPlaceAdd(__pyx_t_2, __pyx_cur_scope->__pyx_v_count); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (PyObject_SetItem(__pyx_t_15, __pyx_t_3, __pyx_t_14) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1254 - * return 0 - * f_low_prev = f_back_low[0] - * f_high_prev = f_back_high[0] # <<<<<<<<<<<<<< - * - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1086 + * fcount[f] += count + * fphrases[f][e][als] += count + * for f, elist in fphrases.iteritems(): # <<<<<<<<<<<<<< + * for e, alslist in elist.iteritems(): + * alignment = None */ - __pyx_v_f_high_prev = (__pyx_v_f_back_high[0]); - } + __pyx_t_5 = 0; + if (unlikely(__pyx_cur_scope->__pyx_v_fphrases == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_fphrases, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_21), (&__pyx_t_18)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_9); + __pyx_t_9 = __pyx_t_15; + __pyx_t_15 = 0; + while (1) { + __pyx_t_6 = __Pyx_dict_iter_next(__pyx_t_9, __pyx_t_21, &__pyx_t_5, &__pyx_t_15, &__pyx_t_3, NULL, __pyx_t_18); + if (unlikely(__pyx_t_6 == 0)) break; + if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1086; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_GOTREF(__pyx_t_3); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_f); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_f); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_f = __pyx_t_15; + __pyx_t_15 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_elist); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_elist); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_elist = __pyx_t_3; + __pyx_t_3 = 0; - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_WriteUnraisable("_sa.HieroCachingRuleFactory.find_fixpoint", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1087 + * fphrases[f][e][als] += count + * for f, elist in fphrases.iteritems(): + * for e, alslist in elist.iteritems(): # <<<<<<<<<<<<<< + * alignment = None + * count = 0 + */ + __pyx_t_22 = 0; + if (unlikely(__pyx_cur_scope->__pyx_v_elist == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_elist, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_23), (&__pyx_t_6)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_3); + __pyx_t_3 = __pyx_t_15; + __pyx_t_15 = 0; + while (1) { + __pyx_t_4 = __Pyx_dict_iter_next(__pyx_t_3, __pyx_t_23, &__pyx_t_22, &__pyx_t_15, &__pyx_t_14, NULL, __pyx_t_6); + if (unlikely(__pyx_t_4 == 0)) break; + if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_GOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_e); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_e = __pyx_t_15; + __pyx_t_15 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_alslist); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_alslist); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_cur_scope->__pyx_v_alslist = __pyx_t_14; + __pyx_t_14 = 0; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1257 - * - * - * cdef find_projection(self, int in_low, int in_high, int* in_links_low, int* in_links_high, # <<<<<<<<<<<<<< - * int* out_low, int* out_high): - * cdef int i + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1088 + * for f, elist in fphrases.iteritems(): + * for e, alslist in elist.iteritems(): + * alignment = None # <<<<<<<<<<<<<< + * count = 0 + * for als, currcount in alslist.iteritems(): */ + __Pyx_INCREF(Py_None); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_alignment); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_alignment); + __Pyx_GIVEREF(Py_None); + __pyx_cur_scope->__pyx_v_alignment = Py_None; -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_find_projection(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_in_low, int __pyx_v_in_high, int *__pyx_v_in_links_low, int *__pyx_v_in_links_high, int *__pyx_v_out_low, int *__pyx_v_out_high) { - int __pyx_v_i; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - __Pyx_RefNannySetupContext("find_projection", 0); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1089 + * for e, alslist in elist.iteritems(): + * alignment = None + * count = 0 # <<<<<<<<<<<<<< + * for als, currcount in alslist.iteritems(): + * if currcount > count: + */ + __Pyx_INCREF(__pyx_int_0); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_count); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_count); + __Pyx_GIVEREF(__pyx_int_0); + __pyx_cur_scope->__pyx_v_count = __pyx_int_0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1260 - * int* out_low, int* out_high): - * cdef int i - * for i from in_low <= i < in_high: # <<<<<<<<<<<<<< - * if in_links_low[i] != -1: - * if out_low[0] == -1 or in_links_low[i] < out_low[0]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1090 + * alignment = None + * count = 0 + * for als, currcount in alslist.iteritems(): # <<<<<<<<<<<<<< + * if currcount > count: + * alignment = als */ - __pyx_t_1 = __pyx_v_in_high; - for (__pyx_v_i = __pyx_v_in_low; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { + __pyx_t_24 = 0; + if (unlikely(__pyx_cur_scope->__pyx_v_alslist == Py_None)) { + PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "iteritems"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_t_15 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_alslist, 0, ((PyObject *)__pyx_n_s__iteritems), (&__pyx_t_25), (&__pyx_t_4)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_14); + __pyx_t_14 = __pyx_t_15; + __pyx_t_15 = 0; + while (1) { + __pyx_t_26 = __Pyx_dict_iter_next(__pyx_t_14, __pyx_t_25, &__pyx_t_24, &__pyx_t_15, &__pyx_t_2, NULL, __pyx_t_4); + if (unlikely(__pyx_t_26 == 0)) break; + if (unlikely(__pyx_t_26 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1090; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_als); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_als); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_als = __pyx_t_15; + __pyx_t_15 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_currcount); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_currcount); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_currcount = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1261 - * cdef int i - * for i from in_low <= i < in_high: - * if in_links_low[i] != -1: # <<<<<<<<<<<<<< - * if out_low[0] == -1 or in_links_low[i] < out_low[0]: - * out_low[0] = in_links_low[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1091 + * count = 0 + * for als, currcount in alslist.iteritems(): + * if currcount > count: # <<<<<<<<<<<<<< + * alignment = als + * count = currcount */ - __pyx_t_2 = ((__pyx_v_in_links_low[__pyx_v_i]) != -1); - if (__pyx_t_2) { + __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_currcount, __pyx_cur_scope->__pyx_v_count, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (__pyx_t_19) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1262 - * for i from in_low <= i < in_high: - * if in_links_low[i] != -1: - * if out_low[0] == -1 or in_links_low[i] < out_low[0]: # <<<<<<<<<<<<<< - * out_low[0] = in_links_low[i] - * if out_high[0] == -1 or in_links_high[i] > out_high[0]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1092 + * for als, currcount in alslist.iteritems(): + * if currcount > count: + * alignment = als # <<<<<<<<<<<<<< + * count = currcount + * scores = self.scorer.score(f, e, count, */ - __pyx_t_2 = ((__pyx_v_out_low[0]) == -1); - if (!__pyx_t_2) { - __pyx_t_3 = ((__pyx_v_in_links_low[__pyx_v_i]) < (__pyx_v_out_low[0])); - __pyx_t_4 = __pyx_t_3; - } else { - __pyx_t_4 = __pyx_t_2; - } - if (__pyx_t_4) { + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_als); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_alignment); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_alignment); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_als); + __pyx_cur_scope->__pyx_v_alignment = __pyx_cur_scope->__pyx_v_als; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1263 - * if in_links_low[i] != -1: - * if out_low[0] == -1 or in_links_low[i] < out_low[0]: - * out_low[0] = in_links_low[i] # <<<<<<<<<<<<<< - * if out_high[0] == -1 or in_links_high[i] > out_high[0]: - * out_high[0] = in_links_high[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1093 + * if currcount > count: + * alignment = als + * count = currcount # <<<<<<<<<<<<<< + * scores = self.scorer.score(f, e, count, + * fcount[f], num_samples) */ - (__pyx_v_out_low[0]) = (__pyx_v_in_links_low[__pyx_v_i]); - goto __pyx_L6; + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_currcount); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_count); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_count); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_currcount); + __pyx_cur_scope->__pyx_v_count = __pyx_cur_scope->__pyx_v_currcount; + goto __pyx_L56; + } + __pyx_L56:; + } + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1094 + * alignment = als + * count = currcount + * scores = self.scorer.score(f, e, count, # <<<<<<<<<<<<<< + * fcount[f], num_samples) + * yield Rule(self.category, f, e, scores, alignment) + */ + if (!(likely(((__pyx_cur_scope->__pyx_v_f) == Py_None) || likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_f, __pyx_ptype_3_sa_Phrase))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = __pyx_cur_scope->__pyx_v_f; + __Pyx_INCREF(__pyx_t_14); + if (!(likely(((__pyx_cur_scope->__pyx_v_e) == Py_None) || likely(__Pyx_TypeTest(__pyx_cur_scope->__pyx_v_e, __pyx_ptype_3_sa_Phrase))))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_cur_scope->__pyx_v_e; + __Pyx_INCREF(__pyx_t_2); + __pyx_t_27 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_count); if (unlikely((__pyx_t_27 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1095 + * count = currcount + * scores = self.scorer.score(f, e, count, + * fcount[f], num_samples) # <<<<<<<<<<<<<< + * yield Rule(self.category, f, e, scores, alignment) + * + */ + __pyx_t_15 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fcount, __pyx_cur_scope->__pyx_v_f); if (!__pyx_t_15) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_28 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_15); if (unlikely((__pyx_t_28 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_15 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_Scorer *)__pyx_cur_scope->__pyx_v_self->scorer->__pyx_vtab)->score(__pyx_cur_scope->__pyx_v_self->scorer, ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_14), ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_2), __pyx_t_27, __pyx_t_28, __pyx_cur_scope->__pyx_v_num_samples)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_scores)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_scores)); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_cur_scope->__pyx_v_scores = ((struct __pyx_obj_3_sa_FeatureVector *)__pyx_t_15); + __pyx_t_15 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1096 + * scores = self.scorer.score(f, e, count, + * fcount[f], num_samples) + * yield Rule(self.category, f, e, scores, alignment) # <<<<<<<<<<<<<< + * + * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: + */ + __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->category); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_2 = PyTuple_New(5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_f); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_cur_scope->__pyx_v_f); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_f); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_e); + PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_cur_scope->__pyx_v_e); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_e); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_scores)); + PyTuple_SET_ITEM(__pyx_t_2, 3, ((PyObject *)__pyx_cur_scope->__pyx_v_scores)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_scores)); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_alignment); + PyTuple_SET_ITEM(__pyx_t_2, 4, __pyx_cur_scope->__pyx_v_alignment); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_alignment); + __pyx_t_15 = 0; + __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Rule)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_r = __pyx_t_15; + __pyx_t_15 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; + __Pyx_XGIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_t_1 = __pyx_t_3; + __pyx_cur_scope->__pyx_t_2 = __pyx_t_5; + __pyx_cur_scope->__pyx_t_3 = __pyx_t_6; + __Pyx_XGIVEREF(__pyx_t_9); + __pyx_cur_scope->__pyx_t_4 = __pyx_t_9; + __Pyx_XGIVEREF(__pyx_t_12); + __pyx_cur_scope->__pyx_t_5 = __pyx_t_12; + __pyx_cur_scope->__pyx_t_6 = __pyx_t_18; + __pyx_cur_scope->__pyx_t_7 = __pyx_t_21; + __pyx_cur_scope->__pyx_t_8 = __pyx_t_22; + __pyx_cur_scope->__pyx_t_9 = __pyx_t_23; + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + /* return from generator, yielding value */ + __pyx_generator->resume_label = 1; + return __pyx_r; + __pyx_L57_resume_from_yield:; + __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; + __pyx_cur_scope->__pyx_t_1 = 0; + __Pyx_XGOTREF(__pyx_t_3); + __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; + __pyx_t_6 = __pyx_cur_scope->__pyx_t_3; + __pyx_t_9 = __pyx_cur_scope->__pyx_t_4; + __pyx_cur_scope->__pyx_t_4 = 0; + __Pyx_XGOTREF(__pyx_t_9); + __pyx_t_12 = __pyx_cur_scope->__pyx_t_5; + __pyx_cur_scope->__pyx_t_5 = 0; + __Pyx_XGOTREF(__pyx_t_12); + __pyx_t_18 = __pyx_cur_scope->__pyx_t_6; + __pyx_t_21 = __pyx_cur_scope->__pyx_t_7; + __pyx_t_22 = __pyx_cur_scope->__pyx_t_8; + __pyx_t_23 = __pyx_cur_scope->__pyx_t_9; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + } + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + goto __pyx_L45; + } + __pyx_L45:; + goto __pyx_L40; + } + __pyx_L40:; + goto __pyx_L32; } - __pyx_L6:; + __pyx_L32:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1264 - * if out_low[0] == -1 or in_links_low[i] < out_low[0]: - * out_low[0] = in_links_low[i] - * if out_high[0] == -1 or in_links_high[i] > out_high[0]: # <<<<<<<<<<<<<< - * out_high[0] = in_links_high[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1098 + * yield Rule(self.category, f, e, scores, alignment) * + * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: # <<<<<<<<<<<<<< + * for alt_id in range(len(fwords[i+spanlen])): + * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) */ - __pyx_t_4 = ((__pyx_v_out_high[0]) == -1); - if (!__pyx_t_4) { - __pyx_t_2 = ((__pyx_v_in_links_high[__pyx_v_i]) > (__pyx_v_out_high[0])); - __pyx_t_3 = __pyx_t_2; + __pyx_t_21 = PyObject_Length(__pyx_cur_scope->__pyx_v_phrase); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = (__pyx_t_21 < __pyx_cur_scope->__pyx_v_self->max_length); + if (__pyx_t_19) { + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = PyNumber_Add(__pyx_t_9, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_21 = PyObject_Length(__pyx_cur_scope->__pyx_v_fwords); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyInt_FromSsize_t(__pyx_t_21); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_15 = PyObject_RichCompare(__pyx_t_3, __pyx_t_9, Py_LT); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_t_8) { + __pyx_t_15 = PyNumber_Add(__pyx_cur_scope->__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->max_initial_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_3 = PyObject_RichCompare(__pyx_t_15, __pyx_t_9, Py_LE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_29 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_30 = __pyx_t_29; + } else { + __pyx_t_30 = __pyx_t_8; + } + __pyx_t_8 = __pyx_t_30; } else { - __pyx_t_3 = __pyx_t_4; + __pyx_t_8 = __pyx_t_19; } - if (__pyx_t_3) { + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1265 - * out_low[0] = in_links_low[i] - * if out_high[0] == -1 or in_links_high[i] > out_high[0]: - * out_high[0] = in_links_high[i] # <<<<<<<<<<<<<< - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1099 * + * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: + * for alt_id in range(len(fwords[i+spanlen])): # <<<<<<<<<<<<<< + * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) + * num_subpatterns = arity */ - (__pyx_v_out_high[0]) = (__pyx_v_in_links_high[__pyx_v_i]); - goto __pyx_L7; - } - __pyx_L7:; - goto __pyx_L5; - } - __pyx_L5:; - } + __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyNumber_Add(__pyx_t_3, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_t_3 = PyObject_GetItem(__pyx_cur_scope->__pyx_v_fwords, __pyx_t_9); if (!__pyx_t_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_21 = PyObject_Length(__pyx_t_3); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + for (__pyx_t_18 = 0; __pyx_t_18 < __pyx_t_21; __pyx_t_18+=1) { + __pyx_cur_scope->__pyx_v_alt_id = __pyx_t_18; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1100 + * if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: + * for alt_id in range(len(fwords[i+spanlen])): + * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) # <<<<<<<<<<<<<< + * num_subpatterns = arity + * if not is_shadow_path: + */ + __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_k); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_15 = PyNumber_Add(__pyx_t_9, __pyx_cur_scope->__pyx_v_spanlen); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt_id); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PyNumber_Add(__pyx_cur_scope->__pyx_v_pathlen, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_14 = PyTuple_New(7); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_node); + PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_cur_scope->__pyx_v_node); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_node); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_phrase); + PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_cur_scope->__pyx_v_phrase); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_phrase); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_cur_scope->__pyx_v_is_shadow_path); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + __pyx_t_3 = 0; + __pyx_t_15 = 0; + __pyx_t_9 = 0; + __pyx_t_2 = 0; + __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_new_frontier, ((PyObject *)__pyx_t_14)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; + } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1268 - * - * - * cdef int* int_arr_extend(self, int* arr, int* arr_len, int* data, int data_len): # <<<<<<<<<<<<<< - * cdef int new_len - * new_len = arr_len[0] + data_len + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1101 + * for alt_id in range(len(fwords[i+spanlen])): + * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) + * num_subpatterns = arity # <<<<<<<<<<<<<< + * if not is_shadow_path: + * num_subpatterns = num_subpatterns + 1 */ + __pyx_cur_scope->__pyx_v_num_subpatterns = __pyx_cur_scope->__pyx_v_arity; -static int *__pyx_f_3_sa_23HieroCachingRuleFactory_int_arr_extend(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int *__pyx_v_arr, int *__pyx_v_arr_len, int *__pyx_v_data, int __pyx_v_data_len) { - int __pyx_v_new_len; - int *__pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("int_arr_extend", 0); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1102 + * new_frontier.append((k, i+spanlen, alt_id, pathlen + 1, node, phrase, is_shadow_path)) + * num_subpatterns = arity + * if not is_shadow_path: # <<<<<<<<<<<<<< + * num_subpatterns = num_subpatterns + 1 + * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: + */ + __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_shadow_path); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = (!__pyx_t_8); + if (__pyx_t_19) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1270 - * cdef int* int_arr_extend(self, int* arr, int* arr_len, int* data, int data_len): - * cdef int new_len - * new_len = arr_len[0] + data_len # <<<<<<<<<<<<<< - * arr = realloc(arr, new_len*sizeof(int)) - * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1103 + * num_subpatterns = arity + * if not is_shadow_path: + * num_subpatterns = num_subpatterns + 1 # <<<<<<<<<<<<<< + * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: + * xcat = sym_setindex(self.category, arity+1) */ - __pyx_v_new_len = ((__pyx_v_arr_len[0]) + __pyx_v_data_len); + __pyx_cur_scope->__pyx_v_num_subpatterns = (__pyx_cur_scope->__pyx_v_num_subpatterns + 1); + goto __pyx_L61; + } + __pyx_L61:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1271 - * cdef int new_len - * new_len = arr_len[0] + data_len - * arr = realloc(arr, new_len*sizeof(int)) # <<<<<<<<<<<<<< - * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) - * arr_len[0] = new_len + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1104 + * if not is_shadow_path: + * num_subpatterns = num_subpatterns + 1 + * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: # <<<<<<<<<<<<<< + * xcat = sym_setindex(self.category, arity+1) + * xnode = node.children[xcat] */ - __pyx_v_arr = ((int *)realloc(__pyx_v_arr, (__pyx_v_new_len * (sizeof(int))))); + __pyx_t_21 = PyObject_Length(__pyx_cur_scope->__pyx_v_phrase); if (unlikely(__pyx_t_21 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_19 = ((__pyx_t_21 + 1) < __pyx_cur_scope->__pyx_v_self->max_length); + if (__pyx_t_19) { + __pyx_t_8 = (__pyx_cur_scope->__pyx_v_arity < __pyx_cur_scope->__pyx_v_self->max_nonterminals); + if (__pyx_t_8) { + __pyx_t_30 = (__pyx_cur_scope->__pyx_v_num_subpatterns < __pyx_cur_scope->__pyx_v_self->max_chunks); + __pyx_t_29 = __pyx_t_30; + } else { + __pyx_t_29 = __pyx_t_8; + } + __pyx_t_8 = __pyx_t_29; + } else { + __pyx_t_8 = __pyx_t_19; + } + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1272 - * new_len = arr_len[0] + data_len - * arr = realloc(arr, new_len*sizeof(int)) - * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) # <<<<<<<<<<<<<< - * arr_len[0] = new_len - * return arr + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1105 + * num_subpatterns = num_subpatterns + 1 + * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: + * xcat = sym_setindex(self.category, arity+1) # <<<<<<<<<<<<<< + * xnode = node.children[xcat] + * # I put spanlen=1 below */ - memcpy((__pyx_v_arr + (__pyx_v_arr_len[0])), __pyx_v_data, (__pyx_v_data_len * (sizeof(int)))); + __pyx_cur_scope->__pyx_v_xcat = __pyx_f_3_sa_sym_setindex(__pyx_cur_scope->__pyx_v_self->category, (__pyx_cur_scope->__pyx_v_arity + 1)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1273 - * arr = realloc(arr, new_len*sizeof(int)) - * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) - * arr_len[0] = new_len # <<<<<<<<<<<<<< - * return arr - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1106 + * if len(phrase)+1 < self.max_length and arity < self.max_nonterminals and num_subpatterns < self.max_chunks: + * xcat = sym_setindex(self.category, arity+1) + * xnode = node.children[xcat] # <<<<<<<<<<<<<< + * # I put spanlen=1 below + * key = tuple([self.min_gap_size, i, 1, pathlen]) */ - (__pyx_v_arr_len[0]) = __pyx_v_new_len; + __pyx_t_14 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_node, __pyx_n_s__children); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_14, __pyx_cur_scope->__pyx_v_xcat, sizeof(int), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_xnode); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_xnode); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_xnode = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1274 - * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) - * arr_len[0] = new_len - * return arr # <<<<<<<<<<<<<< - * - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1108 + * xnode = node.children[xcat] + * # I put spanlen=1 below + * key = tuple([self.min_gap_size, i, 1, pathlen]) # <<<<<<<<<<<<<< + * frontier_nodes = [] + * if (key in nodes_isteps_away_buffer): */ - __pyx_r = __pyx_v_arr; - goto __pyx_L0; + __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_9 = PyList_New(4); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + PyList_SET_ITEM(__pyx_t_9, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyList_SET_ITEM(__pyx_t_9, 1, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + __Pyx_INCREF(__pyx_int_1); + PyList_SET_ITEM(__pyx_t_9, 2, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); + PyList_SET_ITEM(__pyx_t_9, 3, __pyx_cur_scope->__pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); + __pyx_t_2 = 0; + __pyx_t_14 = 0; + __pyx_t_14 = ((PyObject *)PyList_AsTuple(__pyx_t_9)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_14)); + __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0; + __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); + __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_key)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_14)); + __pyx_cur_scope->__pyx_v_key = __pyx_t_14; + __pyx_t_14 = 0; - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1109 + * # I put spanlen=1 below + * key = tuple([self.min_gap_size, i, 1, pathlen]) + * frontier_nodes = [] # <<<<<<<<<<<<<< + * if (key in nodes_isteps_away_buffer): + * frontier_nodes = nodes_isteps_away_buffer[key] + */ + __pyx_t_14 = PyList_New(0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_frontier_nodes); + __Pyx_XDECREF(__pyx_cur_scope->__pyx_v_frontier_nodes); + __Pyx_GIVEREF(((PyObject *)__pyx_t_14)); + __pyx_cur_scope->__pyx_v_frontier_nodes = ((PyObject *)__pyx_t_14); + __pyx_t_14 = 0; -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1277 - * - * - * cdef extract_phrases(self, int e_low, int e_high, int* e_gap_low, int* e_gap_high, int* e_links_low, int num_gaps, # <<<<<<<<<<<<<< - * int f_low, int f_high, int* f_gap_low, int* f_gap_high, int* f_links_low, - * int sent_id, int e_sent_len, int e_sent_start): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1110 + * key = tuple([self.min_gap_size, i, 1, pathlen]) + * frontier_nodes = [] + * if (key in nodes_isteps_away_buffer): # <<<<<<<<<<<<<< + * frontier_nodes = nodes_isteps_away_buffer[key] + * else: */ + __pyx_t_8 = ((PyDict_Contains(((PyObject *)__pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer), ((PyObject *)__pyx_cur_scope->__pyx_v_key)))); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__pyx_t_8) { -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract_phrases(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_e_low, int __pyx_v_e_high, int *__pyx_v_e_gap_low, int *__pyx_v_e_gap_high, int *__pyx_v_e_links_low, int __pyx_v_num_gaps, CYTHON_UNUSED int __pyx_v_f_low, CYTHON_UNUSED int __pyx_v_f_high, CYTHON_UNUSED int *__pyx_v_f_gap_low, CYTHON_UNUSED int *__pyx_v_f_gap_high, CYTHON_UNUSED int *__pyx_v_f_links_low, CYTHON_UNUSED int __pyx_v_sent_id, int __pyx_v_e_sent_len, int __pyx_v_e_sent_start) { - int __pyx_v_i; - int __pyx_v_j; - int __pyx_v_k; - int __pyx_v_m; - int __pyx_v_n; - int *__pyx_v_e_gap_order; - int __pyx_v_e_x_low; - int __pyx_v_e_x_high; - int __pyx_v_e_x_gap_low; - int __pyx_v_e_x_gap_high; - int *__pyx_v_e_gaps1; - int *__pyx_v_e_gaps2; - int __pyx_v_len1; - int __pyx_v_len2; - int __pyx_v_step; - int __pyx_v_num_chunks; - struct __pyx_obj_3_sa_IntList *__pyx_v_ephr_arr = 0; - PyObject *__pyx_v_result = 0; - PyObject *__pyx_v_indexes = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - int __pyx_t_4; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - long __pyx_t_9; - int __pyx_t_10; - PyObject *__pyx_t_11 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("extract_phrases", 0); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1111 + * frontier_nodes = [] + * if (key in nodes_isteps_away_buffer): + * frontier_nodes = nodes_isteps_away_buffer[key] # <<<<<<<<<<<<<< + * else: + * frontier_nodes = self.get_all_nodes_isteps_away(self.min_gap_size, i, 1, pathlen, fwords, next_states, reachable_buffer) + */ + __pyx_t_14 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer), ((PyObject *)__pyx_cur_scope->__pyx_v_key)); if (!__pyx_t_14) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_frontier_nodes); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_frontier_nodes); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_cur_scope->__pyx_v_frontier_nodes = __pyx_t_14; + __pyx_t_14 = 0; + goto __pyx_L63; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1285 - * cdef result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1113 + * frontier_nodes = nodes_isteps_away_buffer[key] + * else: + * frontier_nodes = self.get_all_nodes_isteps_away(self.min_gap_size, i, 1, pathlen, fwords, next_states, reachable_buffer) # <<<<<<<<<<<<<< + * nodes_isteps_away_buffer[key] = frontier_nodes * - * result = [] # <<<<<<<<<<<<<< - * len1 = 0 - * e_gaps1 = malloc(0) */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_result = ((PyObject *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s_125); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_self->min_gap_size); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_2 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyTuple_New(7); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + __Pyx_INCREF(__pyx_int_1); + PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_int_1); + __Pyx_GIVEREF(__pyx_int_1); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); + PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_cur_scope->__pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_fwords); + PyTuple_SET_ITEM(__pyx_t_15, 4, __pyx_cur_scope->__pyx_v_fwords); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_fwords); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_next_states)); + PyTuple_SET_ITEM(__pyx_t_15, 5, ((PyObject *)__pyx_cur_scope->__pyx_v_next_states)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_next_states)); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_reachable_buffer)); + PyTuple_SET_ITEM(__pyx_t_15, 6, ((PyObject *)__pyx_cur_scope->__pyx_v_reachable_buffer)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_reachable_buffer)); + __pyx_t_9 = 0; + __pyx_t_2 = 0; + __pyx_t_2 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_frontier_nodes); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_frontier_nodes); + __Pyx_GIVEREF(__pyx_t_2); + __pyx_cur_scope->__pyx_v_frontier_nodes = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1286 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1114 + * else: + * frontier_nodes = self.get_all_nodes_isteps_away(self.min_gap_size, i, 1, pathlen, fwords, next_states, reachable_buffer) + * nodes_isteps_away_buffer[key] = frontier_nodes # <<<<<<<<<<<<<< * - * result = [] - * len1 = 0 # <<<<<<<<<<<<<< - * e_gaps1 = malloc(0) - * ephr_arr = IntList() + * for (i, alt, pathlen) in frontier_nodes: */ - __pyx_v_len1 = 0; + if (PyDict_SetItem(((PyObject *)__pyx_cur_scope->__pyx_v_nodes_isteps_away_buffer), ((PyObject *)__pyx_cur_scope->__pyx_v_key), __pyx_cur_scope->__pyx_v_frontier_nodes) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_L63:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1287 - * result = [] - * len1 = 0 - * e_gaps1 = malloc(0) # <<<<<<<<<<<<<< - * ephr_arr = IntList() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1116 + * nodes_isteps_away_buffer[key] = frontier_nodes * + * for (i, alt, pathlen) in frontier_nodes: # <<<<<<<<<<<<<< + * new_frontier.append((k, i, alt, pathlen, xnode, phrase +(xcat,), is_shadow_path)) + * frontier = new_frontier */ - __pyx_v_e_gaps1 = ((int *)malloc(0)); + if (PyList_CheckExact(__pyx_cur_scope->__pyx_v_frontier_nodes) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_frontier_nodes)) { + __pyx_t_2 = __pyx_cur_scope->__pyx_v_frontier_nodes; __Pyx_INCREF(__pyx_t_2); __pyx_t_21 = 0; + __pyx_t_31 = NULL; + } else { + __pyx_t_21 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_frontier_nodes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_31 = Py_TYPE(__pyx_t_2)->tp_iternext; + } + for (;;) { + if (!__pyx_t_31 && PyList_CheckExact(__pyx_t_2)) { + if (__pyx_t_21 >= PyList_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_15 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_21); __Pyx_INCREF(__pyx_t_15); __pyx_t_21++; + #else + __pyx_t_15 = PySequence_ITEM(__pyx_t_2, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_31 && PyTuple_CheckExact(__pyx_t_2)) { + if (__pyx_t_21 >= PyTuple_GET_SIZE(__pyx_t_2)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_21); __Pyx_INCREF(__pyx_t_15); __pyx_t_21++; + #else + __pyx_t_15 = PySequence_ITEM(__pyx_t_2, __pyx_t_21); __pyx_t_21++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_15 = __pyx_t_31(__pyx_t_2); + if (unlikely(!__pyx_t_15)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_15); + } + if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) { + PyObject* sequence = __pyx_t_15; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 3)) { + if (size > 3) __Pyx_RaiseTooManyValuesError(3); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_9 = PyTuple_GET_ITEM(sequence, 1); + __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2); + } else { + __pyx_t_14 = PyList_GET_ITEM(sequence, 0); + __pyx_t_9 = PyList_GET_ITEM(sequence, 1); + __pyx_t_3 = PyList_GET_ITEM(sequence, 2); + } + __Pyx_INCREF(__pyx_t_14); + __Pyx_INCREF(__pyx_t_9); + __Pyx_INCREF(__pyx_t_3); + #else + __pyx_t_14 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_10 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; + index = 0; __pyx_t_14 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_14)) goto __pyx_L66_unpacking_failed; + __Pyx_GOTREF(__pyx_t_14); + index = 1; __pyx_t_9 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L66_unpacking_failed; + __Pyx_GOTREF(__pyx_t_9); + index = 2; __pyx_t_3 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L66_unpacking_failed; + __Pyx_GOTREF(__pyx_t_3); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 3) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = NULL; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L67_unpacking_done; + __pyx_L66_unpacking_failed:; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_17 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L67_unpacking_done:; + } + __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_t_14); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; + __pyx_cur_scope->__pyx_v_i = __pyx_t_18; + __pyx_cur_scope->__pyx_v_alt = __pyx_t_6; + __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_DECREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_t_3); + __pyx_cur_scope->__pyx_v_pathlen = __pyx_t_3; + __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1288 - * len1 = 0 - * e_gaps1 = malloc(0) - * ephr_arr = IntList() # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1117 + * + * for (i, alt, pathlen) in frontier_nodes: + * new_frontier.append((k, i, alt, pathlen, xnode, phrase +(xcat,), is_shadow_path)) # <<<<<<<<<<<<<< + * frontier = new_frontier * - * e_gap_order = malloc(num_gaps*sizeof(int)) */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_ephr_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_15 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_k); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_3 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_9 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_alt); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_9); + __pyx_t_14 = PyInt_FromLong(__pyx_cur_scope->__pyx_v_xcat); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_t_14 = 0; + __pyx_t_14 = PyNumber_Add(__pyx_cur_scope->__pyx_v_phrase, ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3); + __Pyx_GIVEREF(__pyx_t_3); + PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_9); + __Pyx_GIVEREF(__pyx_t_9); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pathlen); + PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_cur_scope->__pyx_v_pathlen); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pathlen); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_xnode); + PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_cur_scope->__pyx_v_xnode); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_xnode); + PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + __Pyx_INCREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_cur_scope->__pyx_v_is_shadow_path); + __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_is_shadow_path); + __pyx_t_15 = 0; + __pyx_t_3 = 0; + __pyx_t_9 = 0; + __pyx_t_14 = 0; + __pyx_t_11 = PyList_Append(__pyx_cur_scope->__pyx_v_new_frontier, ((PyObject *)__pyx_t_10)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; + } + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L62; + } + __pyx_L62:; + goto __pyx_L58; + } + __pyx_L58:; + __pyx_L19_continue:; + } + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1290 - * ephr_arr = IntList() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1118 + * for (i, alt, pathlen) in frontier_nodes: + * new_frontier.append((k, i, alt, pathlen, xnode, phrase +(xcat,), is_shadow_path)) + * frontier = new_frontier # <<<<<<<<<<<<<< * - * e_gap_order = malloc(num_gaps*sizeof(int)) # <<<<<<<<<<<<<< - * if num_gaps > 0: - * e_gap_order[0] = 0 + * stop_time = monitor_cpu() */ - __pyx_v_e_gap_order = ((int *)malloc((__pyx_v_num_gaps * (sizeof(int))))); + __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); + __Pyx_GOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_frontier)); + __Pyx_DECREF(((PyObject *)__pyx_cur_scope->__pyx_v_frontier)); + __Pyx_GIVEREF(((PyObject *)__pyx_cur_scope->__pyx_v_new_frontier)); + __pyx_cur_scope->__pyx_v_frontier = __pyx_cur_scope->__pyx_v_new_frontier; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1291 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1120 + * frontier = new_frontier * - * e_gap_order = malloc(num_gaps*sizeof(int)) - * if num_gaps > 0: # <<<<<<<<<<<<<< - * e_gap_order[0] = 0 - * for i from 1 <= i < num_gaps: + * stop_time = monitor_cpu() # <<<<<<<<<<<<<< + * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) + * gc.collect() */ - __pyx_t_2 = (__pyx_v_num_gaps > 0); - if (__pyx_t_2) { + __pyx_t_12 = PyFloat_FromDouble(__pyx_f_3_sa_monitor_cpu()); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_GIVEREF(__pyx_t_12); + __pyx_cur_scope->__pyx_v_stop_time = __pyx_t_12; + __pyx_t_12 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1292 - * e_gap_order = malloc(num_gaps*sizeof(int)) - * if num_gaps > 0: - * e_gap_order[0] = 0 # <<<<<<<<<<<<<< - * for i from 1 <= i < num_gaps: - * for j from 0 <= j < i: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1121 + * + * stop_time = monitor_cpu() + * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) # <<<<<<<<<<<<<< + * gc.collect() + * logger.info(" Extract time = %f seconds", self.extract_time) */ - (__pyx_v_e_gap_order[0]) = 0; + __pyx_t_12 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_2 = PyObject_GetAttr(__pyx_t_12, __pyx_n_s__info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_start_time); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __pyx_t_10 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_stop_time, __pyx_t_12); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_126)); + PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)__pyx_kp_s_126)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_126)); + PyTuple_SET_ITEM(__pyx_t_12, 1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1293 - * if num_gaps > 0: - * e_gap_order[0] = 0 - * for i from 1 <= i < num_gaps: # <<<<<<<<<<<<<< - * for j from 0 <= j < i: - * if e_gap_low[i] < e_gap_low[j]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1122 + * stop_time = monitor_cpu() + * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) + * gc.collect() # <<<<<<<<<<<<<< + * logger.info(" Extract time = %f seconds", self.extract_time) + * */ - __pyx_t_3 = __pyx_v_num_gaps; - for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__gc); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_12 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__collect); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1294 - * e_gap_order[0] = 0 - * for i from 1 <= i < num_gaps: - * for j from 0 <= j < i: # <<<<<<<<<<<<<< - * if e_gap_low[i] < e_gap_low[j]: - * for k from j <= k < i: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1123 + * logger.info("Total time for rule lookup, extraction, and scoring = %f seconds", (stop_time - start_time)) + * gc.collect() + * logger.info(" Extract time = %f seconds", self.extract_time) # <<<<<<<<<<<<<< + * + * */ - __pyx_t_4 = __pyx_v_i; - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_4; __pyx_v_j++) { + __pyx_t_10 = __Pyx_GetName(__pyx_m, __pyx_n_s__logger); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_12 = PyObject_GetAttr(__pyx_t_10, __pyx_n_s__info); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_12); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_10 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_self->extract_time); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_127)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_127)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_127)); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + __pyx_t_10 = 0; + __pyx_t_10 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + PyErr_SetNone(PyExc_StopIteration); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_3); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_9); + __Pyx_XDECREF(__pyx_t_10); + __Pyx_XDECREF(__pyx_t_12); + __Pyx_XDECREF(__pyx_t_13); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_XDECREF(__pyx_t_16); + __Pyx_AddTraceback("input", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_XDECREF(__pyx_r); + __pyx_generator->resume_label = -1; + __Pyx_Generator_clear((PyObject*)__pyx_generator); + __Pyx_RefNannyFinishContext(); + return NULL; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1295 - * for i from 1 <= i < num_gaps: - * for j from 0 <= j < i: - * if e_gap_low[i] < e_gap_low[j]: # <<<<<<<<<<<<<< - * for k from j <= k < i: - * e_gap_order[k+1] = e_gap_order[k] +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1126 + * + * + * cdef int find_fixpoint(self, # <<<<<<<<<<<<<< + * int f_low, f_high, + * int* f_links_low, int* f_links_high, */ - __pyx_t_2 = ((__pyx_v_e_gap_low[__pyx_v_i]) < (__pyx_v_e_gap_low[__pyx_v_j])); - if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1296 - * for j from 0 <= j < i: - * if e_gap_low[i] < e_gap_low[j]: - * for k from j <= k < i: # <<<<<<<<<<<<<< - * e_gap_order[k+1] = e_gap_order[k] - * e_gap_order[j] = i +static int __pyx_f_3_sa_23HieroCachingRuleFactory_find_fixpoint(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_f_low, PyObject *__pyx_v_f_high, int *__pyx_v_f_links_low, int *__pyx_v_f_links_high, int *__pyx_v_e_links_low, int *__pyx_v_e_links_high, int __pyx_v_e_in_low, int __pyx_v_e_in_high, int *__pyx_v_e_low, int *__pyx_v_e_high, int *__pyx_v_f_back_low, int *__pyx_v_f_back_high, int __pyx_v_f_sent_len, int __pyx_v_e_sent_len, int __pyx_v_max_f_len, int __pyx_v_max_e_len, int __pyx_v_min_fx_size, int __pyx_v_min_ex_size, int __pyx_v_max_new_x, int __pyx_v_allow_low_x, int __pyx_v_allow_high_x, int __pyx_v_allow_arbitrary_x, CYTHON_UNUSED int __pyx_v_write_log) { + int __pyx_v_e_low_prev; + int __pyx_v_e_high_prev; + int __pyx_v_f_low_prev; + int __pyx_v_f_high_prev; + int __pyx_v_new_x; + int __pyx_v_new_low_x; + int __pyx_v_new_high_x; + int __pyx_r; + __Pyx_RefNannyDeclarations + int __pyx_t_1; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + PyObject *__pyx_t_6 = NULL; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("find_fixpoint", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1141 + * cdef int e_low_prev, e_high_prev, f_low_prev, f_high_prev, new_x, new_low_x, new_high_x + * + * e_low[0] = e_in_low # <<<<<<<<<<<<<< + * e_high[0] = e_in_high + * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) */ - __pyx_t_5 = __pyx_v_i; - for (__pyx_v_k = __pyx_v_j; __pyx_v_k < __pyx_t_5; __pyx_v_k++) { + (__pyx_v_e_low[0]) = __pyx_v_e_in_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1297 - * if e_gap_low[i] < e_gap_low[j]: - * for k from j <= k < i: - * e_gap_order[k+1] = e_gap_order[k] # <<<<<<<<<<<<<< - * e_gap_order[j] = i - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1142 + * + * e_low[0] = e_in_low + * e_high[0] = e_in_high # <<<<<<<<<<<<<< + * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) + * if e_low[0] == -1: */ - (__pyx_v_e_gap_order[(__pyx_v_k + 1)]) = (__pyx_v_e_gap_order[__pyx_v_k]); - } + (__pyx_v_e_high[0]) = __pyx_v_e_in_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1298 - * for k from j <= k < i: - * e_gap_order[k+1] = e_gap_order[k] - * e_gap_order[j] = i # <<<<<<<<<<<<<< - * break - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1143 + * e_low[0] = e_in_low + * e_high[0] = e_in_high + * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) # <<<<<<<<<<<<<< + * if e_low[0] == -1: + * # low-priority corner case: if phrase w is unaligned, */ - (__pyx_v_e_gap_order[__pyx_v_j]) = __pyx_v_i; + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_f_high); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, __pyx_v_f_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_low, __pyx_v_e_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1299 - * e_gap_order[k+1] = e_gap_order[k] - * e_gap_order[j] = i - * break # <<<<<<<<<<<<<< - * else: - * e_gap_order[i] = i + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1144 + * e_high[0] = e_in_high + * self.find_projection(f_low, f_high, f_links_low, f_links_high, e_low, e_high) + * if e_low[0] == -1: # <<<<<<<<<<<<<< + * # low-priority corner case: if phrase w is unaligned, + * # but we don't require aligned terminals, then returning */ - goto __pyx_L7_break; - goto __pyx_L8; - } - __pyx_L8:; - } - /*else*/ { + __pyx_t_3 = ((__pyx_v_e_low[0]) == -1); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1301 - * break - * else: - * e_gap_order[i] = i # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1150 + * # rule X -> X_1 w X_2 / X_1 X_2. This is probably + * # not worth the bother, though. + * return 0 # <<<<<<<<<<<<<< + * elif e_in_low != -1 and e_low[0] != e_in_low: + * if e_in_low - e_low[0] < min_ex_size: + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L3; + } + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1151 + * # not worth the bother, though. + * return 0 + * elif e_in_low != -1 and e_low[0] != e_in_low: # <<<<<<<<<<<<<< + * if e_in_low - e_low[0] < min_ex_size: + * e_low[0] = e_in_low - min_ex_size + */ + __pyx_t_3 = (__pyx_v_e_in_low != -1); + if (__pyx_t_3) { + __pyx_t_4 = ((__pyx_v_e_low[0]) != __pyx_v_e_in_low); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_3; + } + if (__pyx_t_5) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1152 + * return 0 + * elif e_in_low != -1 and e_low[0] != e_in_low: + * if e_in_low - e_low[0] < min_ex_size: # <<<<<<<<<<<<<< + * e_low[0] = e_in_low - min_ex_size + * if e_low[0] < 0: + */ + __pyx_t_5 = ((__pyx_v_e_in_low - (__pyx_v_e_low[0])) < __pyx_v_min_ex_size); + if (__pyx_t_5) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1153 + * elif e_in_low != -1 and e_low[0] != e_in_low: + * if e_in_low - e_low[0] < min_ex_size: + * e_low[0] = e_in_low - min_ex_size # <<<<<<<<<<<<<< + * if e_low[0] < 0: + * return 0 + */ + (__pyx_v_e_low[0]) = (__pyx_v_e_in_low - __pyx_v_min_ex_size); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1154 + * if e_in_low - e_low[0] < min_ex_size: + * e_low[0] = e_in_low - min_ex_size + * if e_low[0] < 0: # <<<<<<<<<<<<<< + * return 0 * - * e_x_low = e_low */ - (__pyx_v_e_gap_order[__pyx_v_i]) = __pyx_v_i; + __pyx_t_5 = ((__pyx_v_e_low[0]) < 0); + if (__pyx_t_5) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1155 + * e_low[0] = e_in_low - min_ex_size + * if e_low[0] < 0: + * return 0 # <<<<<<<<<<<<<< + * + * if e_high[0] - e_low[0] > max_e_len: + */ + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L5; } - __pyx_L7_break:; + __pyx_L5:; + goto __pyx_L4; } + __pyx_L4:; goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1303 - * e_gap_order[i] = i + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1157 + * return 0 * - * e_x_low = e_low # <<<<<<<<<<<<<< - * e_x_high = e_high - * if self.tight_phrases == 0: + * if e_high[0] - e_low[0] > max_e_len: # <<<<<<<<<<<<<< + * return 0 + * elif e_in_high != -1 and e_high[0] != e_in_high: */ - __pyx_v_e_x_low = __pyx_v_e_low; + __pyx_t_5 = (((__pyx_v_e_high[0]) - (__pyx_v_e_low[0])) > __pyx_v_max_e_len); + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1304 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1158 * - * e_x_low = e_low - * e_x_high = e_high # <<<<<<<<<<<<<< - * if self.tight_phrases == 0: - * while e_x_low > 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: + * if e_high[0] - e_low[0] > max_e_len: + * return 0 # <<<<<<<<<<<<<< + * elif e_in_high != -1 and e_high[0] != e_in_high: + * if e_high[0] - e_in_high < min_ex_size: */ - __pyx_v_e_x_high = __pyx_v_e_high; + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L6; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1305 - * e_x_low = e_low - * e_x_high = e_high - * if self.tight_phrases == 0: # <<<<<<<<<<<<<< - * while e_x_low > 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: - * e_x_low = e_x_low - 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1159 + * if e_high[0] - e_low[0] > max_e_len: + * return 0 + * elif e_in_high != -1 and e_high[0] != e_in_high: # <<<<<<<<<<<<<< + * if e_high[0] - e_in_high < min_ex_size: + * e_high[0] = e_in_high + min_ex_size */ - __pyx_t_2 = (__pyx_v_self->tight_phrases == 0); - if (__pyx_t_2) { + __pyx_t_5 = (__pyx_v_e_in_high != -1); + if (__pyx_t_5) { + __pyx_t_3 = ((__pyx_v_e_high[0]) != __pyx_v_e_in_high); + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_5; + } + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1306 - * e_x_high = e_high - * if self.tight_phrases == 0: - * while e_x_low > 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: # <<<<<<<<<<<<<< - * e_x_low = e_x_low - 1 - * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1160 + * return 0 + * elif e_in_high != -1 and e_high[0] != e_in_high: + * if e_high[0] - e_in_high < min_ex_size: # <<<<<<<<<<<<<< + * e_high[0] = e_in_high + min_ex_size + * if e_high[0] > e_sent_len: */ - while (1) { - __pyx_t_2 = (__pyx_v_e_x_low > 0); - if (__pyx_t_2) { - __pyx_t_6 = ((__pyx_v_e_high - __pyx_v_e_x_low) < __pyx_v_self->train_max_initial_size); - if (__pyx_t_6) { - __pyx_t_7 = ((__pyx_v_e_links_low[(__pyx_v_e_x_low - 1)]) == -1); - __pyx_t_8 = __pyx_t_7; - } else { - __pyx_t_8 = __pyx_t_6; - } - __pyx_t_6 = __pyx_t_8; - } else { - __pyx_t_6 = __pyx_t_2; - } - if (!__pyx_t_6) break; + __pyx_t_4 = (((__pyx_v_e_high[0]) - __pyx_v_e_in_high) < __pyx_v_min_ex_size); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1307 - * if self.tight_phrases == 0: - * while e_x_low > 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: - * e_x_low = e_x_low - 1 # <<<<<<<<<<<<<< - * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: - * e_x_high = e_x_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1161 + * elif e_in_high != -1 and e_high[0] != e_in_high: + * if e_high[0] - e_in_high < min_ex_size: + * e_high[0] = e_in_high + min_ex_size # <<<<<<<<<<<<<< + * if e_high[0] > e_sent_len: + * return 0 */ - __pyx_v_e_x_low = (__pyx_v_e_x_low - 1); - } + (__pyx_v_e_high[0]) = (__pyx_v_e_in_high + __pyx_v_min_ex_size); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1308 - * while e_x_low > 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: - * e_x_low = e_x_low - 1 - * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: # <<<<<<<<<<<<<< - * e_x_high = e_x_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1162 + * if e_high[0] - e_in_high < min_ex_size: + * e_high[0] = e_in_high + min_ex_size + * if e_high[0] > e_sent_len: # <<<<<<<<<<<<<< + * return 0 * */ - while (1) { - __pyx_t_6 = (__pyx_v_e_x_high < __pyx_v_e_sent_len); - if (__pyx_t_6) { - __pyx_t_2 = ((__pyx_v_e_x_high - __pyx_v_e_low) < __pyx_v_self->train_max_initial_size); - if (__pyx_t_2) { - __pyx_t_8 = ((__pyx_v_e_links_low[__pyx_v_e_x_high]) == -1); - __pyx_t_7 = __pyx_t_8; - } else { - __pyx_t_7 = __pyx_t_2; - } - __pyx_t_2 = __pyx_t_7; - } else { - __pyx_t_2 = __pyx_t_6; - } - if (!__pyx_t_2) break; + __pyx_t_4 = ((__pyx_v_e_high[0]) > __pyx_v_e_sent_len); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1309 - * e_x_low = e_x_low - 1 - * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: - * e_x_high = e_x_high + 1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1163 + * e_high[0] = e_in_high + min_ex_size + * if e_high[0] > e_sent_len: + * return 0 # <<<<<<<<<<<<<< * - * for i from e_x_low <= i <= e_low: + * f_back_low[0] = -1 */ - __pyx_v_e_x_high = (__pyx_v_e_x_high + 1); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L8; + } + __pyx_L8:; + goto __pyx_L7; } - goto __pyx_L11; + __pyx_L7:; + goto __pyx_L6; } - __pyx_L11:; + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1311 - * e_x_high = e_x_high + 1 - * - * for i from e_x_low <= i <= e_low: # <<<<<<<<<<<<<< - * e_gaps1 = self.int_arr_extend(e_gaps1, &len1, &i, 1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1165 + * return 0 * + * f_back_low[0] = -1 # <<<<<<<<<<<<<< + * f_back_high[0] = -1 + * f_low_prev = f_low */ - __pyx_t_3 = __pyx_v_e_low; - for (__pyx_v_i = __pyx_v_e_x_low; __pyx_v_i <= __pyx_t_3; __pyx_v_i++) { + (__pyx_v_f_back_low[0]) = -1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1312 - * - * for i from e_x_low <= i <= e_low: - * e_gaps1 = self.int_arr_extend(e_gaps1, &len1, &i, 1) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1166 * - * for i from 0 <= i < num_gaps: + * f_back_low[0] = -1 + * f_back_high[0] = -1 # <<<<<<<<<<<<<< + * f_low_prev = f_low + * f_high_prev = f_high */ - __pyx_v_e_gaps1 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps1, (&__pyx_v_len1), (&__pyx_v_i), 1); - } + (__pyx_v_f_back_high[0]) = -1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1314 - * e_gaps1 = self.int_arr_extend(e_gaps1, &len1, &i, 1) - * - * for i from 0 <= i < num_gaps: # <<<<<<<<<<<<<< - * e_gaps2 = malloc(0) - * len2 = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1167 + * f_back_low[0] = -1 + * f_back_high[0] = -1 + * f_low_prev = f_low # <<<<<<<<<<<<<< + * f_high_prev = f_high + * new_x = 0 */ - __pyx_t_3 = __pyx_v_num_gaps; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + __pyx_v_f_low_prev = __pyx_v_f_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1315 - * - * for i from 0 <= i < num_gaps: - * e_gaps2 = malloc(0) # <<<<<<<<<<<<<< - * len2 = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1168 + * f_back_high[0] = -1 + * f_low_prev = f_low + * f_high_prev = f_high # <<<<<<<<<<<<<< + * new_x = 0 + * new_low_x = 0 */ - __pyx_v_e_gaps2 = ((int *)malloc(0)); + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_f_high); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_f_high_prev = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1316 - * for i from 0 <= i < num_gaps: - * e_gaps2 = malloc(0) - * len2 = 0 # <<<<<<<<<<<<<< - * - * j = e_gap_order[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1169 + * f_low_prev = f_low + * f_high_prev = f_high + * new_x = 0 # <<<<<<<<<<<<<< + * new_low_x = 0 + * new_high_x = 0 */ - __pyx_v_len2 = 0; + __pyx_v_new_x = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1318 - * len2 = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1170 + * f_high_prev = f_high + * new_x = 0 + * new_low_x = 0 # <<<<<<<<<<<<<< + * new_high_x = 0 * - * j = e_gap_order[i] # <<<<<<<<<<<<<< - * e_x_gap_low = e_gap_low[j] - * e_x_gap_high = e_gap_high[j] */ - __pyx_v_j = (__pyx_v_e_gap_order[__pyx_v_i]); + __pyx_v_new_low_x = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1319 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1171 + * new_x = 0 + * new_low_x = 0 + * new_high_x = 0 # <<<<<<<<<<<<<< * - * j = e_gap_order[i] - * e_x_gap_low = e_gap_low[j] # <<<<<<<<<<<<<< - * e_x_gap_high = e_gap_high[j] - * if self.tight_phrases == 0: - */ - __pyx_v_e_x_gap_low = (__pyx_v_e_gap_low[__pyx_v_j]); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1320 - * j = e_gap_order[i] - * e_x_gap_low = e_gap_low[j] - * e_x_gap_high = e_gap_high[j] # <<<<<<<<<<<<<< - * if self.tight_phrases == 0: - * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: + * while True: */ - __pyx_v_e_x_gap_high = (__pyx_v_e_gap_high[__pyx_v_j]); + __pyx_v_new_high_x = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1321 - * e_x_gap_low = e_gap_low[j] - * e_x_gap_high = e_gap_high[j] - * if self.tight_phrases == 0: # <<<<<<<<<<<<<< - * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: - * e_x_gap_low = e_x_gap_low - 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1173 + * new_high_x = 0 + * + * while True: # <<<<<<<<<<<<<< + * + * if f_back_low[0] == -1: */ - __pyx_t_2 = (__pyx_v_self->tight_phrases == 0); - if (__pyx_t_2) { + while (1) { + if (!1) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1322 - * e_x_gap_high = e_gap_high[j] - * if self.tight_phrases == 0: - * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: # <<<<<<<<<<<<<< - * e_x_gap_low = e_x_gap_low - 1 - * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1175 + * while True: + * + * if f_back_low[0] == -1: # <<<<<<<<<<<<<< + * self.find_projection(e_low[0], e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) + * else: */ - while (1) { - __pyx_t_2 = (__pyx_v_e_x_gap_low > __pyx_v_e_x_low); - if (__pyx_t_2) { - __pyx_t_6 = ((__pyx_v_e_links_low[(__pyx_v_e_x_gap_low - 1)]) == -1); - __pyx_t_7 = __pyx_t_6; - } else { - __pyx_t_7 = __pyx_t_2; - } - if (!__pyx_t_7) break; + __pyx_t_4 = ((__pyx_v_f_back_low[0]) == -1); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1323 - * if self.tight_phrases == 0: - * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: - * e_x_gap_low = e_x_gap_low - 1 # <<<<<<<<<<<<<< - * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: - * e_x_gap_high = e_x_gap_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1176 + * + * if f_back_low[0] == -1: + * self.find_projection(e_low[0], e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) # <<<<<<<<<<<<<< + * else: + * self.find_projection(e_low[0], e_low_prev, e_links_low, e_links_high, f_back_low, f_back_high) */ - __pyx_v_e_x_gap_low = (__pyx_v_e_x_gap_low - 1); - } + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, (__pyx_v_e_low[0]), (__pyx_v_e_high[0]), __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_f_back_low, __pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L11; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1324 - * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: - * e_x_gap_low = e_x_gap_low - 1 - * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: # <<<<<<<<<<<<<< - * e_x_gap_high = e_x_gap_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1178 + * self.find_projection(e_low[0], e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) + * else: + * self.find_projection(e_low[0], e_low_prev, e_links_low, e_links_high, f_back_low, f_back_high) # <<<<<<<<<<<<<< + * self.find_projection(e_high_prev, e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) * */ - while (1) { - __pyx_t_7 = (__pyx_v_e_x_gap_high < __pyx_v_e_x_high); - if (__pyx_t_7) { - __pyx_t_2 = ((__pyx_v_e_links_low[__pyx_v_e_x_gap_high]) == -1); - __pyx_t_6 = __pyx_t_2; - } else { - __pyx_t_6 = __pyx_t_7; - } - if (!__pyx_t_6) break; + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, (__pyx_v_e_low[0]), __pyx_v_e_low_prev, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_f_back_low, __pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1325 - * e_x_gap_low = e_x_gap_low - 1 - * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: - * e_x_gap_high = e_x_gap_high + 1 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1179 + * else: + * self.find_projection(e_low[0], e_low_prev, e_links_low, e_links_high, f_back_low, f_back_high) + * self.find_projection(e_high_prev, e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) # <<<<<<<<<<<<<< * - * k = 0 + * if f_back_low[0] > f_low: */ - __pyx_v_e_x_gap_high = (__pyx_v_e_x_gap_high + 1); - } - goto __pyx_L20; + __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, __pyx_v_e_high_prev, (__pyx_v_e_high[0]), __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_f_back_low, __pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } - __pyx_L20:; + __pyx_L11:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1327 - * e_x_gap_high = e_x_gap_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1181 + * self.find_projection(e_high_prev, e_high[0], e_links_low, e_links_high, f_back_low, f_back_high) + * + * if f_back_low[0] > f_low: # <<<<<<<<<<<<<< + * f_back_low[0] = f_low * - * k = 0 # <<<<<<<<<<<<<< - * step = 1+(i*2) - * while k < len1: */ - __pyx_v_k = 0; + __pyx_t_4 = ((__pyx_v_f_back_low[0]) > __pyx_v_f_low); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1328 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1182 * - * k = 0 - * step = 1+(i*2) # <<<<<<<<<<<<<< - * while k < len1: - * for m from e_x_gap_low <= m <= e_gap_low[j]: + * if f_back_low[0] > f_low: + * f_back_low[0] = f_low # <<<<<<<<<<<<<< + * + * if f_back_high[0] < f_high: */ - __pyx_v_step = (1 + (__pyx_v_i * 2)); + (__pyx_v_f_back_low[0]) = __pyx_v_f_low; + goto __pyx_L12; + } + __pyx_L12:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1329 - * k = 0 - * step = 1+(i*2) - * while k < len1: # <<<<<<<<<<<<<< - * for m from e_x_gap_low <= m <= e_gap_low[j]: - * if m >= e_gaps1[k+step-1]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1184 + * f_back_low[0] = f_low + * + * if f_back_high[0] < f_high: # <<<<<<<<<<<<<< + * f_back_high[0] = f_high + * */ - while (1) { - __pyx_t_6 = (__pyx_v_k < __pyx_v_len1); - if (!__pyx_t_6) break; + __pyx_t_2 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = PyObject_RichCompare(__pyx_t_2, __pyx_v_f_high, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1330 - * step = 1+(i*2) - * while k < len1: - * for m from e_x_gap_low <= m <= e_gap_low[j]: # <<<<<<<<<<<<<< - * if m >= e_gaps1[k+step-1]: - * for n from e_gap_high[j] <= n <= e_x_gap_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1185 + * + * if f_back_high[0] < f_high: + * f_back_high[0] = f_high # <<<<<<<<<<<<<< + * + * if f_back_low[0] == f_low_prev and f_back_high[0] == f_high_prev: */ - __pyx_t_4 = (__pyx_v_e_gap_low[__pyx_v_j]); - for (__pyx_v_m = __pyx_v_e_x_gap_low; __pyx_v_m <= __pyx_t_4; __pyx_v_m++) { + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_f_high); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + (__pyx_v_f_back_high[0]) = __pyx_t_1; + goto __pyx_L13; + } + __pyx_L13:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1331 - * while k < len1: - * for m from e_x_gap_low <= m <= e_gap_low[j]: - * if m >= e_gaps1[k+step-1]: # <<<<<<<<<<<<<< - * for n from e_gap_high[j] <= n <= e_x_gap_high: - * if n-m >= 1: # extractor.py doesn't restrict target-side gap length + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1187 + * f_back_high[0] = f_high + * + * if f_back_low[0] == f_low_prev and f_back_high[0] == f_high_prev: # <<<<<<<<<<<<<< + * return 1 + * */ - __pyx_t_6 = (__pyx_v_m >= (__pyx_v_e_gaps1[((__pyx_v_k + __pyx_v_step) - 1)])); - if (__pyx_t_6) { + __pyx_t_4 = ((__pyx_v_f_back_low[0]) == __pyx_v_f_low_prev); + if (__pyx_t_4) { + __pyx_t_5 = ((__pyx_v_f_back_high[0]) == __pyx_v_f_high_prev); + __pyx_t_3 = __pyx_t_5; + } else { + __pyx_t_3 = __pyx_t_4; + } + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1332 - * for m from e_x_gap_low <= m <= e_gap_low[j]: - * if m >= e_gaps1[k+step-1]: - * for n from e_gap_high[j] <= n <= e_x_gap_high: # <<<<<<<<<<<<<< - * if n-m >= 1: # extractor.py doesn't restrict target-side gap length - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1188 + * + * if f_back_low[0] == f_low_prev and f_back_high[0] == f_high_prev: + * return 1 # <<<<<<<<<<<<<< + * + * if allow_low_x == 0 and f_back_low[0] < f_low: */ - __pyx_t_5 = __pyx_v_e_x_gap_high; - for (__pyx_v_n = (__pyx_v_e_gap_high[__pyx_v_j]); __pyx_v_n <= __pyx_t_5; __pyx_v_n++) { + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L14; + } + __pyx_L14:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1333 - * if m >= e_gaps1[k+step-1]: - * for n from e_gap_high[j] <= n <= e_x_gap_high: - * if n-m >= 1: # extractor.py doesn't restrict target-side gap length # <<<<<<<<<<<<<< - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1190 + * return 1 + * + * if allow_low_x == 0 and f_back_low[0] < f_low: # <<<<<<<<<<<<<< + * # FAIL: f phrase is not tight + * return 0 */ - __pyx_t_6 = ((__pyx_v_n - __pyx_v_m) >= 1); - if (__pyx_t_6) { + __pyx_t_3 = (__pyx_v_allow_low_x == 0); + if (__pyx_t_3) { + __pyx_t_4 = ((__pyx_v_f_back_low[0]) < __pyx_v_f_low); + __pyx_t_5 = __pyx_t_4; + } else { + __pyx_t_5 = __pyx_t_3; + } + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1334 - * for n from e_gap_high[j] <= n <= e_x_gap_high: - * if n-m >= 1: # extractor.py doesn't restrict target-side gap length - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) # <<<<<<<<<<<<<< - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1192 + * if allow_low_x == 0 and f_back_low[0] < f_low: + * # FAIL: f phrase is not tight + * return 0 # <<<<<<<<<<<<<< + * + * if f_back_high[0] - f_back_low[0] > max_f_len: */ - __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (__pyx_v_e_gaps1 + __pyx_v_k), __pyx_v_step); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L15; + } + __pyx_L15:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1335 - * if n-m >= 1: # extractor.py doesn't restrict target-side gap length - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) # <<<<<<<<<<<<<< - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) - * k = k + step + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1194 + * return 0 + * + * if f_back_high[0] - f_back_low[0] > max_f_len: # <<<<<<<<<<<<<< + * # FAIL: f back projection is too wide + * return 0 */ - __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (&__pyx_v_m), 1); + __pyx_t_5 = (((__pyx_v_f_back_high[0]) - (__pyx_v_f_back_low[0])) > __pyx_v_max_f_len); + if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1336 - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) # <<<<<<<<<<<<<< - * k = k + step - * free(e_gaps1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1196 + * if f_back_high[0] - f_back_low[0] > max_f_len: + * # FAIL: f back projection is too wide + * return 0 # <<<<<<<<<<<<<< + * + * if allow_high_x == 0 and f_back_high[0] > f_high: */ - __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (&__pyx_v_n), 1); - goto __pyx_L32; - } - __pyx_L32:; - } - goto __pyx_L29; - } - __pyx_L29:; - } + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L16; + } + __pyx_L16:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1337 - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) - * k = k + step # <<<<<<<<<<<<<< - * free(e_gaps1) - * e_gaps1 = e_gaps2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1198 + * return 0 + * + * if allow_high_x == 0 and f_back_high[0] > f_high: # <<<<<<<<<<<<<< + * # FAIL: extension on high side not allowed + * return 0 */ - __pyx_v_k = (__pyx_v_k + __pyx_v_step); + __pyx_t_5 = (__pyx_v_allow_high_x == 0); + if (__pyx_t_5) { + __pyx_t_6 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_2 = PyObject_RichCompare(__pyx_t_6, __pyx_v_f_high, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_5; } + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1338 - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) - * k = k + step - * free(e_gaps1) # <<<<<<<<<<<<<< - * e_gaps1 = e_gaps2 - * len1 = len2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1200 + * if allow_high_x == 0 and f_back_high[0] > f_high: + * # FAIL: extension on high side not allowed + * return 0 # <<<<<<<<<<<<<< + * + * if f_low != f_back_low[0]: */ - free(__pyx_v_e_gaps1); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L17; + } + __pyx_L17:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1339 - * k = k + step - * free(e_gaps1) - * e_gaps1 = e_gaps2 # <<<<<<<<<<<<<< - * len1 = len2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1202 + * return 0 * + * if f_low != f_back_low[0]: # <<<<<<<<<<<<<< + * if new_low_x == 0: + * if new_x >= max_new_x: */ - __pyx_v_e_gaps1 = __pyx_v_e_gaps2; + __pyx_t_4 = (__pyx_v_f_low != (__pyx_v_f_back_low[0])); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1340 - * free(e_gaps1) - * e_gaps1 = e_gaps2 - * len1 = len2 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1203 * - * step = 1+(num_gaps*2) + * if f_low != f_back_low[0]: + * if new_low_x == 0: # <<<<<<<<<<<<<< + * if new_x >= max_new_x: + * # FAIL: extension required on low side violates max # of gaps */ - __pyx_v_len1 = __pyx_v_len2; - } + __pyx_t_4 = (__pyx_v_new_low_x == 0); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1342 - * len1 = len2 - * - * step = 1+(num_gaps*2) # <<<<<<<<<<<<<< - * e_gaps2 = malloc(0) - * len2 = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1204 + * if f_low != f_back_low[0]: + * if new_low_x == 0: + * if new_x >= max_new_x: # <<<<<<<<<<<<<< + * # FAIL: extension required on low side violates max # of gaps + * return 0 */ - __pyx_v_step = (1 + (__pyx_v_num_gaps * 2)); + __pyx_t_4 = (__pyx_v_new_x >= __pyx_v_max_new_x); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1343 - * - * step = 1+(num_gaps*2) - * e_gaps2 = malloc(0) # <<<<<<<<<<<<<< - * len2 = 0 - * for i from e_high <= i <= e_x_high: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1206 + * if new_x >= max_new_x: + * # FAIL: extension required on low side violates max # of gaps + * return 0 # <<<<<<<<<<<<<< + * else: + * new_x = new_x + 1 */ - __pyx_v_e_gaps2 = ((int *)malloc(0)); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L20; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1344 - * step = 1+(num_gaps*2) - * e_gaps2 = malloc(0) - * len2 = 0 # <<<<<<<<<<<<<< - * for i from e_high <= i <= e_x_high: - * j = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1208 + * return 0 + * else: + * new_x = new_x + 1 # <<<<<<<<<<<<<< + * new_low_x = 1 + * if f_low - f_back_low[0] < min_fx_size: */ - __pyx_v_len2 = 0; + __pyx_v_new_x = (__pyx_v_new_x + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1345 - * e_gaps2 = malloc(0) - * len2 = 0 - * for i from e_high <= i <= e_x_high: # <<<<<<<<<<<<<< - * j = 0 - * while j < len1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1209 + * else: + * new_x = new_x + 1 + * new_low_x = 1 # <<<<<<<<<<<<<< + * if f_low - f_back_low[0] < min_fx_size: + * f_back_low[0] = f_low - min_fx_size */ - __pyx_t_3 = __pyx_v_e_x_high; - for (__pyx_v_i = __pyx_v_e_high; __pyx_v_i <= __pyx_t_3; __pyx_v_i++) { + __pyx_v_new_low_x = 1; + } + __pyx_L20:; + goto __pyx_L19; + } + __pyx_L19:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1346 - * len2 = 0 - * for i from e_high <= i <= e_x_high: - * j = 0 # <<<<<<<<<<<<<< - * while j < len1: - * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1210 + * new_x = new_x + 1 + * new_low_x = 1 + * if f_low - f_back_low[0] < min_fx_size: # <<<<<<<<<<<<<< + * f_back_low[0] = f_low - min_fx_size + * if f_back_high[0] - f_back_low[0] > max_f_len: */ - __pyx_v_j = 0; + __pyx_t_4 = ((__pyx_v_f_low - (__pyx_v_f_back_low[0])) < __pyx_v_min_fx_size); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1347 - * for i from e_high <= i <= e_x_high: - * j = 0 - * while j < len1: # <<<<<<<<<<<<<< - * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1211 + * new_low_x = 1 + * if f_low - f_back_low[0] < min_fx_size: + * f_back_low[0] = f_low - min_fx_size # <<<<<<<<<<<<<< + * if f_back_high[0] - f_back_low[0] > max_f_len: + * # FAIL: extension required on low side violates max initial length */ - while (1) { - __pyx_t_6 = (__pyx_v_j < __pyx_v_len1); - if (!__pyx_t_6) break; + (__pyx_v_f_back_low[0]) = (__pyx_v_f_low - __pyx_v_min_fx_size); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1348 - * j = 0 - * while j < len1: - * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: # <<<<<<<<<<<<<< - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1212 + * if f_low - f_back_low[0] < min_fx_size: + * f_back_low[0] = f_low - min_fx_size + * if f_back_high[0] - f_back_low[0] > max_f_len: # <<<<<<<<<<<<<< + * # FAIL: extension required on low side violates max initial length + * return 0 */ - __pyx_t_6 = ((__pyx_v_i - (__pyx_v_e_gaps1[__pyx_v_j])) <= __pyx_v_self->train_max_initial_size); - if (__pyx_t_6) { - __pyx_t_7 = (__pyx_v_i >= (__pyx_v_e_gaps1[((__pyx_v_j + __pyx_v_step) - 1)])); - __pyx_t_2 = __pyx_t_7; - } else { - __pyx_t_2 = __pyx_t_6; - } - if (__pyx_t_2) { + __pyx_t_4 = (((__pyx_v_f_back_high[0]) - (__pyx_v_f_back_low[0])) > __pyx_v_max_f_len); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1349 - * while j < len1: - * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) # <<<<<<<<<<<<<< - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) - * j = j + step + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1214 + * if f_back_high[0] - f_back_low[0] > max_f_len: + * # FAIL: extension required on low side violates max initial length + * return 0 # <<<<<<<<<<<<<< + * if f_back_low[0] < 0: + * # FAIL: extension required on low side violates sentence boundary */ - __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (__pyx_v_e_gaps1 + __pyx_v_j), __pyx_v_step); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L22; + } + __pyx_L22:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1350 - * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) # <<<<<<<<<<<<<< - * j = j + step - * free(e_gaps1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1215 + * # FAIL: extension required on low side violates max initial length + * return 0 + * if f_back_low[0] < 0: # <<<<<<<<<<<<<< + * # FAIL: extension required on low side violates sentence boundary + * return 0 */ - __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (&__pyx_v_i), 1); - goto __pyx_L37; - } - __pyx_L37:; + __pyx_t_4 = ((__pyx_v_f_back_low[0]) < 0); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1351 - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) - * j = j + step # <<<<<<<<<<<<<< - * free(e_gaps1) - * e_gaps1 = e_gaps2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1217 + * if f_back_low[0] < 0: + * # FAIL: extension required on low side violates sentence boundary + * return 0 # <<<<<<<<<<<<<< + * + * if f_high != f_back_high[0]: */ - __pyx_v_j = (__pyx_v_j + __pyx_v_step); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L23; + } + __pyx_L23:; + goto __pyx_L21; + } + __pyx_L21:; + goto __pyx_L18; } - } + __pyx_L18:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1352 - * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) - * j = j + step - * free(e_gaps1) # <<<<<<<<<<<<<< - * e_gaps1 = e_gaps2 - * len1 = len2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1219 + * return 0 + * + * if f_high != f_back_high[0]: # <<<<<<<<<<<<<< + * if new_high_x == 0: + * if new_x >= max_new_x: */ - free(__pyx_v_e_gaps1); + __pyx_t_2 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_6 = PyObject_RichCompare(__pyx_v_f_high, __pyx_t_2, Py_NE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1353 - * j = j + step - * free(e_gaps1) - * e_gaps1 = e_gaps2 # <<<<<<<<<<<<<< - * len1 = len2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1220 * + * if f_high != f_back_high[0]: + * if new_high_x == 0: # <<<<<<<<<<<<<< + * if new_x >= max_new_x: + * # FAIL: extension required on high side violates max # of gaps */ - __pyx_v_e_gaps1 = __pyx_v_e_gaps2; + __pyx_t_4 = (__pyx_v_new_high_x == 0); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1354 - * free(e_gaps1) - * e_gaps1 = e_gaps2 - * len1 = len2 # <<<<<<<<<<<<<< - * - * step = (num_gaps+1)*2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1221 + * if f_high != f_back_high[0]: + * if new_high_x == 0: + * if new_x >= max_new_x: # <<<<<<<<<<<<<< + * # FAIL: extension required on high side violates max # of gaps + * return 0 */ - __pyx_v_len1 = __pyx_v_len2; + __pyx_t_4 = (__pyx_v_new_x >= __pyx_v_max_new_x); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1356 - * len1 = len2 - * - * step = (num_gaps+1)*2 # <<<<<<<<<<<<<< - * i = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1223 + * if new_x >= max_new_x: + * # FAIL: extension required on high side violates max # of gaps + * return 0 # <<<<<<<<<<<<<< + * else: + * new_x = new_x + 1 */ - __pyx_v_step = ((__pyx_v_num_gaps + 1) * 2); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L26; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1357 - * - * step = (num_gaps+1)*2 - * i = 0 # <<<<<<<<<<<<<< - * - * while i < len1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1225 + * return 0 + * else: + * new_x = new_x + 1 # <<<<<<<<<<<<<< + * new_high_x = 1 + * if f_back_high[0] - f_high < min_fx_size: */ - __pyx_v_i = 0; + __pyx_v_new_x = (__pyx_v_new_x + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1359 - * i = 0 - * - * while i < len1: # <<<<<<<<<<<<<< - * ephr_arr._clear() - * num_chunks = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1226 + * else: + * new_x = new_x + 1 + * new_high_x = 1 # <<<<<<<<<<<<<< + * if f_back_high[0] - f_high < min_fx_size: + * f_back_high[0] = f_high + min_fx_size */ - while (1) { - __pyx_t_2 = (__pyx_v_i < __pyx_v_len1); - if (!__pyx_t_2) break; + __pyx_v_new_high_x = 1; + } + __pyx_L26:; + goto __pyx_L25; + } + __pyx_L25:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1360 - * - * while i < len1: - * ephr_arr._clear() # <<<<<<<<<<<<<< - * num_chunks = 0 - * indexes = [] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1227 + * new_x = new_x + 1 + * new_high_x = 1 + * if f_back_high[0] - f_high < min_fx_size: # <<<<<<<<<<<<<< + * f_back_high[0] = f_high + min_fx_size + * if f_back_high[0] - f_back_low[0] > max_f_len: */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_ephr_arr->__pyx_vtab)->_clear(__pyx_v_ephr_arr); + __pyx_t_6 = PyInt_FromLong((__pyx_v_f_back_high[0])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_2 = PyNumber_Subtract(__pyx_t_6, __pyx_v_f_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = PyInt_FromLong(__pyx_v_min_fx_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __pyx_t_7 = PyObject_RichCompare(__pyx_t_2, __pyx_t_6, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1361 - * while i < len1: - * ephr_arr._clear() - * num_chunks = 0 # <<<<<<<<<<<<<< - * indexes = [] - * for j from 0 <= j < num_gaps+1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1228 + * new_high_x = 1 + * if f_back_high[0] - f_high < min_fx_size: + * f_back_high[0] = f_high + min_fx_size # <<<<<<<<<<<<<< + * if f_back_high[0] - f_back_low[0] > max_f_len: + * # FAIL: extension required on high side violates max initial length */ - __pyx_v_num_chunks = 0; + __pyx_t_7 = PyInt_FromLong(__pyx_v_min_fx_size); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_6 = PyNumber_Add(__pyx_v_f_high, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + (__pyx_v_f_back_high[0]) = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1362 - * ephr_arr._clear() - * num_chunks = 0 - * indexes = [] # <<<<<<<<<<<<<< - * for j from 0 <= j < num_gaps+1: - * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1229 + * if f_back_high[0] - f_high < min_fx_size: + * f_back_high[0] = f_high + min_fx_size + * if f_back_high[0] - f_back_low[0] > max_f_len: # <<<<<<<<<<<<<< + * # FAIL: extension required on high side violates max initial length + * return 0 */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(((PyObject *)__pyx_v_indexes)); - __pyx_v_indexes = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_4 = (((__pyx_v_f_back_high[0]) - (__pyx_v_f_back_low[0])) > __pyx_v_max_f_len); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1363 - * num_chunks = 0 - * indexes = [] - * for j from 0 <= j < num_gaps+1: # <<<<<<<<<<<<<< - * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: - * num_chunks = num_chunks + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1231 + * if f_back_high[0] - f_back_low[0] > max_f_len: + * # FAIL: extension required on high side violates max initial length + * return 0 # <<<<<<<<<<<<<< + * if f_back_high[0] > f_sent_len: + * # FAIL: extension required on high side violates sentence boundary */ - __pyx_t_9 = (__pyx_v_num_gaps + 1); - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_9; __pyx_v_j++) { + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L28; + } + __pyx_L28:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1364 - * indexes = [] - * for j from 0 <= j < num_gaps+1: - * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: # <<<<<<<<<<<<<< - * num_chunks = num_chunks + 1 - * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1232 + * # FAIL: extension required on high side violates max initial length + * return 0 + * if f_back_high[0] > f_sent_len: # <<<<<<<<<<<<<< + * # FAIL: extension required on high side violates sentence boundary + * return 0 */ - __pyx_t_2 = ((__pyx_v_e_gaps1[(__pyx_v_i + (2 * __pyx_v_j))]) < (__pyx_v_e_gaps1[((__pyx_v_i + (2 * __pyx_v_j)) + 1)])); - if (__pyx_t_2) { + __pyx_t_4 = ((__pyx_v_f_back_high[0]) > __pyx_v_f_sent_len); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1365 - * for j from 0 <= j < num_gaps+1: - * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: - * num_chunks = num_chunks + 1 # <<<<<<<<<<<<<< - * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: - * indexes.append(k) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1234 + * if f_back_high[0] > f_sent_len: + * # FAIL: extension required on high side violates sentence boundary + * return 0 # <<<<<<<<<<<<<< + * + * e_low_prev = e_low[0] */ - __pyx_v_num_chunks = (__pyx_v_num_chunks + 1); - goto __pyx_L42; + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L29; + } + __pyx_L29:; + goto __pyx_L27; } - __pyx_L42:; + __pyx_L27:; + goto __pyx_L24; + } + __pyx_L24:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1366 - * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: - * num_chunks = num_chunks + 1 - * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: # <<<<<<<<<<<<<< - * indexes.append(k) - * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1236 + * return 0 + * + * e_low_prev = e_low[0] # <<<<<<<<<<<<<< + * e_high_prev = e_high[0] + * */ - __pyx_t_3 = (__pyx_v_e_gaps1[((__pyx_v_i + (2 * __pyx_v_j)) + 1)]); - for (__pyx_v_k = (__pyx_v_e_gaps1[(__pyx_v_i + (2 * __pyx_v_j))]); __pyx_v_k < __pyx_t_3; __pyx_v_k++) { + __pyx_v_e_low_prev = (__pyx_v_e_low[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1367 - * num_chunks = num_chunks + 1 - * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: - * indexes.append(k) # <<<<<<<<<<<<<< - * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) - * if j < num_gaps: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1237 + * + * e_low_prev = e_low[0] + * e_high_prev = e_high[0] # <<<<<<<<<<<<<< + * + * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyList_Append(__pyx_v_indexes, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_e_high_prev = (__pyx_v_e_high[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1368 - * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: - * indexes.append(k) - * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) # <<<<<<<<<<<<<< - * if j < num_gaps: - * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1239 + * e_high_prev = e_high[0] + * + * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) # <<<<<<<<<<<<<< + * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) + * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: */ - __pyx_t_4 = (__pyx_v_self->eda->data->arr[(__pyx_v_e_sent_start + __pyx_v_k)]); - __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->eid2symid), __pyx_t_4, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_ephr_arr->__pyx_vtab)->_append(__pyx_v_ephr_arr, __pyx_t_4); - } + __pyx_t_6 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, (__pyx_v_f_back_low[0]), __pyx_v_f_low_prev, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_low, __pyx_v_e_high); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1369 - * indexes.append(k) - * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) - * if j < num_gaps: # <<<<<<<<<<<<<< - * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) - * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1240 + * + * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) + * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) # <<<<<<<<<<<<<< + * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: + * return 1 */ - __pyx_t_2 = (__pyx_v_j < __pyx_v_num_gaps); - if (__pyx_t_2) { + __pyx_t_6 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_projection(__pyx_v_self, __pyx_v_f_high_prev, (__pyx_v_f_back_high[0]), __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_low, __pyx_v_e_high); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1370 - * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) - * if j < num_gaps: - * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) # <<<<<<<<<<<<<< - * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) - * i = i + step + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1241 + * self.find_projection(f_back_low[0], f_low_prev, f_links_low, f_links_high, e_low, e_high) + * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) + * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: # <<<<<<<<<<<<<< + * return 1 + * if allow_arbitrary_x == 0: */ - __pyx_t_1 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, ((__pyx_v_e_gap_order[__pyx_v_j]) + 1))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyList_Append(__pyx_v_indexes, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = ((__pyx_v_e_low[0]) == __pyx_v_e_low_prev); + if (__pyx_t_4) { + __pyx_t_5 = ((__pyx_v_e_high[0]) == __pyx_v_e_high_prev); + __pyx_t_3 = __pyx_t_5; + } else { + __pyx_t_3 = __pyx_t_4; + } + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1371 - * if j < num_gaps: - * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) - * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) # <<<<<<<<<<<<<< - * i = i + step - * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1242 + * self.find_projection(f_high_prev, f_back_high[0], f_links_low, f_links_high, e_low, e_high) + * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: + * return 1 # <<<<<<<<<<<<<< + * if allow_arbitrary_x == 0: + * # FAIL: arbitrary expansion not permitted */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_ephr_arr->__pyx_vtab)->_append(__pyx_v_ephr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, ((__pyx_v_e_gap_order[__pyx_v_j]) + 1))); - goto __pyx_L45; - } - __pyx_L45:; + __pyx_r = 1; + goto __pyx_L0; + goto __pyx_L30; } + __pyx_L30:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1372 - * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) - * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) - * i = i + step # <<<<<<<<<<<<<< - * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: - * result.append((Phrase(ephr_arr),indexes)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1243 + * if e_low[0] == e_low_prev and e_high[0] == e_high_prev: + * return 1 + * if allow_arbitrary_x == 0: # <<<<<<<<<<<<<< + * # FAIL: arbitrary expansion not permitted + * return 0 */ - __pyx_v_i = (__pyx_v_i + __pyx_v_step); + __pyx_t_3 = (__pyx_v_allow_arbitrary_x == 0); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1373 - * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) - * i = i + step - * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: # <<<<<<<<<<<<<< - * result.append((Phrase(ephr_arr),indexes)) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1245 + * if allow_arbitrary_x == 0: + * # FAIL: arbitrary expansion not permitted + * return 0 # <<<<<<<<<<<<<< + * if e_high[0] - e_low[0] > max_e_len: + * # FAIL: re-projection violates sentence max phrase length */ - __pyx_t_2 = (__pyx_v_ephr_arr->len <= __pyx_v_self->max_target_length); - if (__pyx_t_2) { - __pyx_t_6 = (__pyx_v_num_chunks <= __pyx_v_self->max_target_chunks); - __pyx_t_7 = __pyx_t_6; - } else { - __pyx_t_7 = __pyx_t_2; + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L31; } - if (__pyx_t_7) { + __pyx_L31:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1374 - * i = i + step - * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: - * result.append((Phrase(ephr_arr),indexes)) # <<<<<<<<<<<<<< - * - * free(e_gaps1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1246 + * # FAIL: arbitrary expansion not permitted + * return 0 + * if e_high[0] - e_low[0] > max_e_len: # <<<<<<<<<<<<<< + * # FAIL: re-projection violates sentence max phrase length + * return 0 */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_ephr_arr)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_ephr_arr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_ephr_arr)); - __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); - __Pyx_GIVEREF(__pyx_t_11); - __Pyx_INCREF(((PyObject *)__pyx_v_indexes)); - PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_indexes)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_indexes)); - __pyx_t_11 = 0; - __pyx_t_11 = __Pyx_PyObject_Append(__pyx_v_result, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1374; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_11); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; - goto __pyx_L46; - } - __pyx_L46:; - } + __pyx_t_3 = (((__pyx_v_e_high[0]) - (__pyx_v_e_low[0])) > __pyx_v_max_e_len); + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1376 - * result.append((Phrase(ephr_arr),indexes)) - * - * free(e_gaps1) # <<<<<<<<<<<<<< - * free(e_gap_order) - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1248 + * if e_high[0] - e_low[0] > max_e_len: + * # FAIL: re-projection violates sentence max phrase length + * return 0 # <<<<<<<<<<<<<< + * f_low_prev = f_back_low[0] + * f_high_prev = f_back_high[0] */ - free(__pyx_v_e_gaps1); + __pyx_r = 0; + goto __pyx_L0; + goto __pyx_L32; + } + __pyx_L32:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1377 - * - * free(e_gaps1) - * free(e_gap_order) # <<<<<<<<<<<<<< - * return result + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1249 + * # FAIL: re-projection violates sentence max phrase length + * return 0 + * f_low_prev = f_back_low[0] # <<<<<<<<<<<<<< + * f_high_prev = f_back_high[0] * */ - free(__pyx_v_e_gap_order); + __pyx_v_f_low_prev = (__pyx_v_f_back_low[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1378 - * free(e_gaps1) - * free(e_gap_order) - * return result # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1250 + * return 0 + * f_low_prev = f_back_low[0] + * f_high_prev = f_back_high[0] # <<<<<<<<<<<<<< + * * - * cdef create_alignments(self, int* sent_links, int num_links, findexes, eindexes): */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_result); - __pyx_r = __pyx_v_result; - goto __pyx_L0; + __pyx_v_f_high_prev = (__pyx_v_f_back_high[0]); + } - __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_11); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.extract_phrases", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_XDECREF(__pyx_t_2); + __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_WriteUnraisable("_sa.HieroCachingRuleFactory.find_fixpoint", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_ephr_arr); - __Pyx_XDECREF(__pyx_v_result); - __Pyx_XDECREF(__pyx_v_indexes); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1380 - * return result +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1253 * - * cdef create_alignments(self, int* sent_links, int num_links, findexes, eindexes): # <<<<<<<<<<<<<< - * cdef unsigned i - * ret = IntList() + * + * cdef find_projection(self, int in_low, int in_high, int* in_links_low, int* in_links_high, # <<<<<<<<<<<<<< + * int* out_low, int* out_high): + * cdef int i */ -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_create_alignments(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int *__pyx_v_sent_links, int __pyx_v_num_links, PyObject *__pyx_v_findexes, PyObject *__pyx_v_eindexes) { - unsigned int __pyx_v_i; - struct __pyx_obj_3_sa_IntList *__pyx_v_ret = NULL; - PyObject *__pyx_v_s = NULL; - PyObject *__pyx_v_idx = NULL; - PyObject *__pyx_v_j = NULL; +static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_find_projection(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_in_low, int __pyx_v_in_high, int *__pyx_v_in_links_low, int *__pyx_v_in_links_high, int *__pyx_v_out_low, int *__pyx_v_out_high) { + int __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - unsigned int __pyx_t_3; + int __pyx_t_1; + int __pyx_t_2; + int __pyx_t_3; int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - Py_ssize_t __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - int __pyx_lineno = 0; - const char *__pyx_filename = NULL; - int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("create_alignments", 0); + __Pyx_RefNannySetupContext("find_projection", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1382 - * cdef create_alignments(self, int* sent_links, int num_links, findexes, eindexes): - * cdef unsigned i - * ret = IntList() # <<<<<<<<<<<<<< - * for i in range(len(findexes)): - * s = findexes[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1256 + * int* out_low, int* out_high): + * cdef int i + * for i from in_low <= i < in_high: # <<<<<<<<<<<<<< + * if in_links_low[i] != -1: + * if out_low[0] == -1 or in_links_low[i] < out_low[0]: */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_ret = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_t_1 = __pyx_v_in_high; + for (__pyx_v_i = __pyx_v_in_low; __pyx_v_i < __pyx_t_1; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1383 - * cdef unsigned i - * ret = IntList() - * for i in range(len(findexes)): # <<<<<<<<<<<<<< - * s = findexes[i] - * if (s<0): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1257 + * cdef int i + * for i from in_low <= i < in_high: + * if in_links_low[i] != -1: # <<<<<<<<<<<<<< + * if out_low[0] == -1 or in_links_low[i] < out_low[0]: + * out_low[0] = in_links_low[i] */ - __pyx_t_2 = PyObject_Length(__pyx_v_findexes); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { - __pyx_v_i = __pyx_t_3; + __pyx_t_2 = ((__pyx_v_in_links_low[__pyx_v_i]) != -1); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1384 - * ret = IntList() - * for i in range(len(findexes)): - * s = findexes[i] # <<<<<<<<<<<<<< - * if (s<0): - * continue + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1258 + * for i from in_low <= i < in_high: + * if in_links_low[i] != -1: + * if out_low[0] == -1 or in_links_low[i] < out_low[0]: # <<<<<<<<<<<<<< + * out_low[0] = in_links_low[i] + * if out_high[0] == -1 or in_links_high[i] > out_high[0]: */ - __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_findexes, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_v_s); - __pyx_v_s = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_2 = ((__pyx_v_out_low[0]) == -1); + if (!__pyx_t_2) { + __pyx_t_3 = ((__pyx_v_in_links_low[__pyx_v_i]) < (__pyx_v_out_low[0])); + __pyx_t_4 = __pyx_t_3; + } else { + __pyx_t_4 = __pyx_t_2; + } + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1385 - * for i in range(len(findexes)): - * s = findexes[i] - * if (s<0): # <<<<<<<<<<<<<< - * continue - * idx = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1259 + * if in_links_low[i] != -1: + * if out_low[0] == -1 or in_links_low[i] < out_low[0]: + * out_low[0] = in_links_low[i] # <<<<<<<<<<<<<< + * if out_high[0] == -1 or in_links_high[i] > out_high[0]: + * out_high[0] = in_links_high[i] */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_s, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_4) { + (__pyx_v_out_low[0]) = (__pyx_v_in_links_low[__pyx_v_i]); + goto __pyx_L6; + } + __pyx_L6:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1386 - * s = findexes[i] - * if (s<0): - * continue # <<<<<<<<<<<<<< - * idx = 0 - * while (idx < num_links*2): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1260 + * if out_low[0] == -1 or in_links_low[i] < out_low[0]: + * out_low[0] = in_links_low[i] + * if out_high[0] == -1 or in_links_high[i] > out_high[0]: # <<<<<<<<<<<<<< + * out_high[0] = in_links_high[i] + * */ - goto __pyx_L3_continue; + __pyx_t_4 = ((__pyx_v_out_high[0]) == -1); + if (!__pyx_t_4) { + __pyx_t_2 = ((__pyx_v_in_links_high[__pyx_v_i]) > (__pyx_v_out_high[0])); + __pyx_t_3 = __pyx_t_2; + } else { + __pyx_t_3 = __pyx_t_4; + } + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1261 + * out_low[0] = in_links_low[i] + * if out_high[0] == -1 or in_links_high[i] > out_high[0]: + * out_high[0] = in_links_high[i] # <<<<<<<<<<<<<< + * + * + */ + (__pyx_v_out_high[0]) = (__pyx_v_in_links_high[__pyx_v_i]); + goto __pyx_L7; + } + __pyx_L7:; goto __pyx_L5; } __pyx_L5:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1387 - * if (s<0): - * continue - * idx = 0 # <<<<<<<<<<<<<< - * while (idx < num_links*2): - * if (sent_links[idx] == s): - */ - __Pyx_INCREF(__pyx_int_0); - __Pyx_XDECREF(__pyx_v_idx); - __pyx_v_idx = __pyx_int_0; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1388 - * continue - * idx = 0 - * while (idx < num_links*2): # <<<<<<<<<<<<<< - * if (sent_links[idx] == s): - * j = eindexes.index(sent_links[idx+1]) +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1264 + * + * + * cdef int* int_arr_extend(self, int* arr, int* arr_len, int* data, int data_len): # <<<<<<<<<<<<<< + * cdef int new_len + * new_len = arr_len[0] + data_len */ - while (1) { - __pyx_t_1 = PyInt_FromLong((__pyx_v_num_links * 2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyObject_RichCompare(__pyx_v_idx, __pyx_t_1, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (!__pyx_t_4) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1389 - * idx = 0 - * while (idx < num_links*2): - * if (sent_links[idx] == s): # <<<<<<<<<<<<<< - * j = eindexes.index(sent_links[idx+1]) - * ret.append(i*65536+j) +static int *__pyx_f_3_sa_23HieroCachingRuleFactory_int_arr_extend(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int *__pyx_v_arr, int *__pyx_v_arr_len, int *__pyx_v_data, int __pyx_v_data_len) { + int __pyx_v_new_len; + int *__pyx_r; + __Pyx_RefNannyDeclarations + __Pyx_RefNannySetupContext("int_arr_extend", 0); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1266 + * cdef int* int_arr_extend(self, int* arr, int* arr_len, int* data, int data_len): + * cdef int new_len + * new_len = arr_len[0] + data_len # <<<<<<<<<<<<<< + * arr = realloc(arr, new_len*sizeof(int)) + * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) */ - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PyInt_FromLong((__pyx_v_sent_links[__pyx_t_6])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_v_s, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_4) { + __pyx_v_new_len = ((__pyx_v_arr_len[0]) + __pyx_v_data_len); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1390 - * while (idx < num_links*2): - * if (sent_links[idx] == s): - * j = eindexes.index(sent_links[idx+1]) # <<<<<<<<<<<<<< - * ret.append(i*65536+j) - * idx += 2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1267 + * cdef int new_len + * new_len = arr_len[0] + data_len + * arr = realloc(arr, new_len*sizeof(int)) # <<<<<<<<<<<<<< + * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) + * arr_len[0] = new_len */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_eindexes, __pyx_n_s__index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyNumber_Add(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = PyInt_FromLong((__pyx_v_sent_links[__pyx_t_6])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); - __Pyx_GIVEREF(__pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1390; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; - __Pyx_XDECREF(__pyx_v_j); - __pyx_v_j = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_v_arr = ((int *)realloc(__pyx_v_arr, (__pyx_v_new_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1391 - * if (sent_links[idx] == s): - * j = eindexes.index(sent_links[idx+1]) - * ret.append(i*65536+j) # <<<<<<<<<<<<<< - * idx += 2 - * return ret + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1268 + * new_len = arr_len[0] + data_len + * arr = realloc(arr, new_len*sizeof(int)) + * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) # <<<<<<<<<<<<<< + * arr_len[0] = new_len + * return arr */ - __pyx_t_5 = PyInt_FromLong((__pyx_v_i * 65536)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_ret), __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L8; - } - __pyx_L8:; + memcpy((__pyx_v_arr + (__pyx_v_arr_len[0])), __pyx_v_data, (__pyx_v_data_len * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1392 - * j = eindexes.index(sent_links[idx+1]) - * ret.append(i*65536+j) - * idx += 2 # <<<<<<<<<<<<<< - * return ret + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1269 + * arr = realloc(arr, new_len*sizeof(int)) + * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) + * arr_len[0] = new_len # <<<<<<<<<<<<<< + * return arr * */ - __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_v_idx); - __pyx_v_idx = __pyx_t_5; - __pyx_t_5 = 0; - } - __pyx_L3_continue:; - } + (__pyx_v_arr_len[0]) = __pyx_v_new_len; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1393 - * ret.append(i*65536+j) - * idx += 2 - * return ret # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1270 + * memcpy(arr+arr_len[0], data, data_len*sizeof(int)) + * arr_len[0] = new_len + * return arr # <<<<<<<<<<<<<< + * * - * cdef extract(self, Phrase phrase, Matching* matching, int* chunklen, int num_chunks): */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = ((PyObject *)__pyx_v_ret); + __pyx_r = __pyx_v_arr; goto __pyx_L0; - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.create_alignments", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; - __Pyx_XDECREF((PyObject *)__pyx_v_ret); - __Pyx_XDECREF(__pyx_v_s); - __Pyx_XDECREF(__pyx_v_idx); - __Pyx_XDECREF(__pyx_v_j); - __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1395 - * return ret +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1273 * - * cdef extract(self, Phrase phrase, Matching* matching, int* chunklen, int num_chunks): # <<<<<<<<<<<<<< - * cdef int* sent_links, *e_links_low, *e_links_high, *f_links_low, *f_links_high - * cdef int *f_gap_low, *f_gap_high, *e_gap_low, *e_gap_high, num_gaps, gap_start + * + * cdef extract_phrases(self, int e_low, int e_high, int* e_gap_low, int* e_gap_high, int* e_links_low, int num_gaps, # <<<<<<<<<<<<<< + * int f_low, int f_high, int* f_gap_low, int* f_gap_high, int* f_links_low, + * int sent_id, int e_sent_len, int e_sent_start): */ -static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_phrase, struct __pyx_t_3_sa_Matching *__pyx_v_matching, int *__pyx_v_chunklen, int __pyx_v_num_chunks) { - int *__pyx_v_sent_links; - int *__pyx_v_e_links_low; - int *__pyx_v_e_links_high; - int *__pyx_v_f_links_low; - int *__pyx_v_f_links_high; - int *__pyx_v_f_gap_low; - int *__pyx_v_f_gap_high; - int *__pyx_v_e_gap_low; - int *__pyx_v_e_gap_high; - int __pyx_v_num_gaps; - int __pyx_v_gap_start; +static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract_phrases(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int __pyx_v_e_low, int __pyx_v_e_high, int *__pyx_v_e_gap_low, int *__pyx_v_e_gap_high, int *__pyx_v_e_links_low, int __pyx_v_num_gaps, CYTHON_UNUSED int __pyx_v_f_low, CYTHON_UNUSED int __pyx_v_f_high, CYTHON_UNUSED int *__pyx_v_f_gap_low, CYTHON_UNUSED int *__pyx_v_f_gap_high, CYTHON_UNUSED int *__pyx_v_f_links_low, CYTHON_UNUSED int __pyx_v_sent_id, int __pyx_v_e_sent_len, int __pyx_v_e_sent_start) { int __pyx_v_i; int __pyx_v_j; - int __pyx_v_e_i; - int __pyx_v_f_i; - int __pyx_v_num_links; - int __pyx_v_num_aligned_chunks; - int __pyx_v_met_constraints; - int __pyx_v_x; - int __pyx_v_f_low; - int __pyx_v_f_high; - int __pyx_v_e_low; - int __pyx_v_e_high; - int __pyx_v_f_back_low; - int __pyx_v_f_back_high; - int __pyx_v_e_sent_start; - int __pyx_v_e_sent_end; - int __pyx_v_f_sent_start; - int __pyx_v_f_sent_end; - int __pyx_v_e_sent_len; - int __pyx_v_f_sent_len; - CYTHON_UNUSED int __pyx_v_e_word_count; - int __pyx_v_f_x_low; - int __pyx_v_f_x_high; + int __pyx_v_k; + int __pyx_v_m; + int __pyx_v_n; + int *__pyx_v_e_gap_order; int __pyx_v_e_x_low; int __pyx_v_e_x_high; - int __pyx_v_phrase_len; - float __pyx_v_pair_count; - PyObject *__pyx_v_extracts = 0; - PyObject *__pyx_v_phrase_list = 0; - struct __pyx_obj_3_sa_IntList *__pyx_v_fphr_arr = 0; - struct __pyx_obj_3_sa_Phrase *__pyx_v_fphr = 0; - CYTHON_UNUSED PyObject *__pyx_v_reason_for_failure = 0; - PyObject *__pyx_v_sofar = NULL; - PyObject *__pyx_v_als = NULL; - PyObject *__pyx_v_al = NULL; - long __pyx_v_gap_error; - PyObject *__pyx_v_phrase2 = NULL; - PyObject *__pyx_v_eindexes = NULL; - PyObject *__pyx_v_als1 = NULL; - PyObject *__pyx_v_als2 = NULL; - PyObject *__pyx_v_als3 = NULL; - PyObject *__pyx_v_als4 = NULL; + int __pyx_v_e_x_gap_low; + int __pyx_v_e_x_gap_high; + int *__pyx_v_e_gaps1; + int *__pyx_v_e_gaps2; + int __pyx_v_len1; + int __pyx_v_len2; + int __pyx_v_step; + int __pyx_v_num_chunks; + struct __pyx_obj_3_sa_IntList *__pyx_v_ephr_arr = 0; + PyObject *__pyx_v_result = 0; + PyObject *__pyx_v_indexes = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; + int __pyx_t_2; int __pyx_t_3; int __pyx_t_4; int __pyx_t_5; int __pyx_t_6; int __pyx_t_7; int __pyx_t_8; - int __pyx_t_9; - PyObject *__pyx_t_10 = NULL; - int __pyx_t_11; - long __pyx_t_12; - Py_ssize_t __pyx_t_13; - PyObject *__pyx_t_14 = NULL; - PyObject *__pyx_t_15 = NULL; - PyObject *(*__pyx_t_16)(PyObject *); - PyObject *(*__pyx_t_17)(PyObject *); - int __pyx_t_18; - int __pyx_t_19; - int __pyx_t_20; - int __pyx_t_21; - int __pyx_t_22; - int __pyx_t_23; - int __pyx_t_24; - int __pyx_t_25; + long __pyx_t_9; + int __pyx_t_10; + PyObject *__pyx_t_11 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("extract", 0); + __Pyx_RefNannySetupContext("extract_phrases", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1408 - * cdef reason_for_failure + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1281 + * cdef result * - * fphr_arr = IntList() # <<<<<<<<<<<<<< - * phrase_len = phrase.n - * extracts = [] + * result = [] # <<<<<<<<<<<<<< + * len1 = 0 + * e_gaps1 = malloc(0) */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_v_fphr_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_v_result = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1409 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1282 * - * fphr_arr = IntList() - * phrase_len = phrase.n # <<<<<<<<<<<<<< - * extracts = [] - * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) + * result = [] + * len1 = 0 # <<<<<<<<<<<<<< + * e_gaps1 = malloc(0) + * ephr_arr = IntList() */ - __pyx_v_phrase_len = __pyx_v_phrase->n; + __pyx_v_len1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1410 - * fphr_arr = IntList() - * phrase_len = phrase.n - * extracts = [] # <<<<<<<<<<<<<< - * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1283 + * result = [] + * len1 = 0 + * e_gaps1 = malloc(0) # <<<<<<<<<<<<<< + * ephr_arr = IntList() * */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_extracts = ((PyObject *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_v_e_gaps1 = ((int *)malloc(0)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1411 - * phrase_len = phrase.n - * extracts = [] - * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1284 + * len1 = 0 + * e_gaps1 = malloc(0) + * ephr_arr = IntList() # <<<<<<<<<<<<<< * - * e_sent_start = self.eda.sent_index.arr[matching.sent_id] + * e_gap_order = malloc(num_gaps*sizeof(int)) */ - __pyx_v_sent_links = ((struct __pyx_vtabstruct_3_sa_Alignment *)__pyx_v_self->alignment->__pyx_vtab)->_get_sent_links(__pyx_v_self->alignment, __pyx_v_matching->sent_id, (&__pyx_v_num_links)); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_ephr_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1413 - * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1286 + * ephr_arr = IntList() * - * e_sent_start = self.eda.sent_index.arr[matching.sent_id] # <<<<<<<<<<<<<< - * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] - * e_sent_len = e_sent_end - e_sent_start - 1 + * e_gap_order = malloc(num_gaps*sizeof(int)) # <<<<<<<<<<<<<< + * if num_gaps > 0: + * e_gap_order[0] = 0 */ - __pyx_v_e_sent_start = (__pyx_v_self->eda->sent_index->arr[__pyx_v_matching->sent_id]); + __pyx_v_e_gap_order = ((int *)malloc((__pyx_v_num_gaps * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1414 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1287 * - * e_sent_start = self.eda.sent_index.arr[matching.sent_id] - * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] # <<<<<<<<<<<<<< - * e_sent_len = e_sent_end - e_sent_start - 1 - * f_sent_start = self.fda.sent_index.arr[matching.sent_id] + * e_gap_order = malloc(num_gaps*sizeof(int)) + * if num_gaps > 0: # <<<<<<<<<<<<<< + * e_gap_order[0] = 0 + * for i from 1 <= i < num_gaps: */ - __pyx_v_e_sent_end = (__pyx_v_self->eda->sent_index->arr[(__pyx_v_matching->sent_id + 1)]); + __pyx_t_2 = (__pyx_v_num_gaps > 0); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1415 - * e_sent_start = self.eda.sent_index.arr[matching.sent_id] - * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] - * e_sent_len = e_sent_end - e_sent_start - 1 # <<<<<<<<<<<<<< - * f_sent_start = self.fda.sent_index.arr[matching.sent_id] - * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1288 + * e_gap_order = malloc(num_gaps*sizeof(int)) + * if num_gaps > 0: + * e_gap_order[0] = 0 # <<<<<<<<<<<<<< + * for i from 1 <= i < num_gaps: + * for j from 0 <= j < i: */ - __pyx_v_e_sent_len = ((__pyx_v_e_sent_end - __pyx_v_e_sent_start) - 1); + (__pyx_v_e_gap_order[0]) = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1416 - * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] - * e_sent_len = e_sent_end - e_sent_start - 1 - * f_sent_start = self.fda.sent_index.arr[matching.sent_id] # <<<<<<<<<<<<<< - * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] - * f_sent_len = f_sent_end - f_sent_start - 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1289 + * if num_gaps > 0: + * e_gap_order[0] = 0 + * for i from 1 <= i < num_gaps: # <<<<<<<<<<<<<< + * for j from 0 <= j < i: + * if e_gap_low[i] < e_gap_low[j]: */ - __pyx_v_f_sent_start = (__pyx_v_self->fda->sent_index->arr[__pyx_v_matching->sent_id]); + __pyx_t_3 = __pyx_v_num_gaps; + for (__pyx_v_i = 1; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1417 - * e_sent_len = e_sent_end - e_sent_start - 1 - * f_sent_start = self.fda.sent_index.arr[matching.sent_id] - * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] # <<<<<<<<<<<<<< - * f_sent_len = f_sent_end - f_sent_start - 1 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1290 + * e_gap_order[0] = 0 + * for i from 1 <= i < num_gaps: + * for j from 0 <= j < i: # <<<<<<<<<<<<<< + * if e_gap_low[i] < e_gap_low[j]: + * for k from j <= k < i: */ - __pyx_v_f_sent_end = (__pyx_v_self->fda->sent_index->arr[(__pyx_v_matching->sent_id + 1)]); + __pyx_t_4 = __pyx_v_i; + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_4; __pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1418 - * f_sent_start = self.fda.sent_index.arr[matching.sent_id] - * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] - * f_sent_len = f_sent_end - f_sent_start - 1 # <<<<<<<<<<<<<< - * - * self.findexes1.reset() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1291 + * for i from 1 <= i < num_gaps: + * for j from 0 <= j < i: + * if e_gap_low[i] < e_gap_low[j]: # <<<<<<<<<<<<<< + * for k from j <= k < i: + * e_gap_order[k+1] = e_gap_order[k] */ - __pyx_v_f_sent_len = ((__pyx_v_f_sent_end - __pyx_v_f_sent_start) - 1); + __pyx_t_2 = ((__pyx_v_e_gap_low[__pyx_v_i]) < (__pyx_v_e_gap_low[__pyx_v_j])); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1420 - * f_sent_len = f_sent_end - f_sent_start - 1 - * - * self.findexes1.reset() # <<<<<<<<<<<<<< - * sofar = 0 - * for i in range(num_chunks): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1292 + * for j from 0 <= j < i: + * if e_gap_low[i] < e_gap_low[j]: + * for k from j <= k < i: # <<<<<<<<<<<<<< + * e_gap_order[k+1] = e_gap_order[k] + * e_gap_order[j] = i */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes1), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1420; __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[8]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_5 = __pyx_v_i; + for (__pyx_v_k = __pyx_v_j; __pyx_v_k < __pyx_t_5; __pyx_v_k++) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1293 + * if e_gap_low[i] < e_gap_low[j]: + * for k from j <= k < i: + * e_gap_order[k+1] = e_gap_order[k] # <<<<<<<<<<<<<< + * e_gap_order[j] = i + * break + */ + (__pyx_v_e_gap_order[(__pyx_v_k + 1)]) = (__pyx_v_e_gap_order[__pyx_v_k]); + } + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1294 + * for k from j <= k < i: + * e_gap_order[k+1] = e_gap_order[k] + * e_gap_order[j] = i # <<<<<<<<<<<<<< + * break + * else: + */ + (__pyx_v_e_gap_order[__pyx_v_j]) = __pyx_v_i; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1295 + * e_gap_order[k+1] = e_gap_order[k] + * e_gap_order[j] = i + * break # <<<<<<<<<<<<<< + * else: + * e_gap_order[i] = i + */ + goto __pyx_L7_break; + goto __pyx_L8; + } + __pyx_L8:; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1421 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1297 + * break + * else: + * e_gap_order[i] = i # <<<<<<<<<<<<<< * - * self.findexes1.reset() - * sofar = 0 # <<<<<<<<<<<<<< - * for i in range(num_chunks): - * for j in range(chunklen[i]): + * e_x_low = e_low */ - __Pyx_INCREF(__pyx_int_0); - __pyx_v_sofar = __pyx_int_0; + (__pyx_v_e_gap_order[__pyx_v_i]) = __pyx_v_i; + } + __pyx_L7_break:; + } + goto __pyx_L3; + } + __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1422 - * self.findexes1.reset() - * sofar = 0 - * for i in range(num_chunks): # <<<<<<<<<<<<<< - * for j in range(chunklen[i]): - * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1299 + * e_gap_order[i] = i + * + * e_x_low = e_low # <<<<<<<<<<<<<< + * e_x_high = e_high + * if self.tight_phrases == 0: */ - __pyx_t_3 = __pyx_v_num_chunks; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_i = __pyx_t_4; + __pyx_v_e_x_low = __pyx_v_e_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1423 - * sofar = 0 - * for i in range(num_chunks): - * for j in range(chunklen[i]): # <<<<<<<<<<<<<< - * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); - * sofar += 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1300 + * + * e_x_low = e_low + * e_x_high = e_high # <<<<<<<<<<<<<< + * if self.tight_phrases == 0: + * while e_x_low > 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: */ - __pyx_t_5 = (__pyx_v_chunklen[__pyx_v_i]); - for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { - __pyx_v_j = __pyx_t_6; + __pyx_v_e_x_high = __pyx_v_e_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1424 - * for i in range(num_chunks): - * for j in range(chunklen[i]): - * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); # <<<<<<<<<<<<<< - * sofar += 1 - * if (i+1 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: + * e_x_low = e_x_low - 1 */ - __pyx_t_2 = PyInt_FromLong((((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + __pyx_v_j) - __pyx_v_f_sent_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes1), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_2 = (__pyx_v_self->tight_phrases == 0); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1425 - * for j in range(chunklen[i]): - * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); - * sofar += 1 # <<<<<<<<<<<<<< - * if (i+1 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: # <<<<<<<<<<<<<< + * e_x_low = e_x_low - 1 + * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: */ - __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_sofar, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_v_sofar); - __pyx_v_sofar = __pyx_t_1; - __pyx_t_1 = 0; - } + while (1) { + __pyx_t_2 = (__pyx_v_e_x_low > 0); + if (__pyx_t_2) { + __pyx_t_6 = ((__pyx_v_e_high - __pyx_v_e_x_low) < __pyx_v_self->train_max_initial_size); + if (__pyx_t_6) { + __pyx_t_7 = ((__pyx_v_e_links_low[(__pyx_v_e_x_low - 1)]) == -1); + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_6; + } + __pyx_t_6 = __pyx_t_8; + } else { + __pyx_t_6 = __pyx_t_2; + } + if (!__pyx_t_6) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1426 - * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); - * sofar += 1 - * if (i+1 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: + * e_x_low = e_x_low - 1 # <<<<<<<<<<<<<< + * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: + * e_x_high = e_x_high + 1 */ - __pyx_t_7 = ((__pyx_v_i + 1) < __pyx_v_num_chunks); - if (__pyx_t_7) { + __pyx_v_e_x_low = (__pyx_v_e_x_low - 1); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1427 - * sofar += 1 - * if (i+1 0 and e_high - e_x_low < self.train_max_initial_size and e_links_low[e_x_low-1] == -1: + * e_x_low = e_x_low - 1 + * while e_x_high < e_sent_len and e_x_high - e_low < self.train_max_initial_size and e_links_low[e_x_high] == -1: # <<<<<<<<<<<<<< + * e_x_high = e_x_high + 1 * */ - __pyx_t_1 = PyObject_GetItem(((PyObject *)__pyx_v_phrase), __pyx_v_sofar); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes1), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1427; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + while (1) { + __pyx_t_6 = (__pyx_v_e_x_high < __pyx_v_e_sent_len); + if (__pyx_t_6) { + __pyx_t_2 = ((__pyx_v_e_x_high - __pyx_v_e_low) < __pyx_v_self->train_max_initial_size); + if (__pyx_t_2) { + __pyx_t_8 = ((__pyx_v_e_links_low[__pyx_v_e_x_high]) == -1); + __pyx_t_7 = __pyx_t_8; + } else { + __pyx_t_7 = __pyx_t_2; + } + __pyx_t_2 = __pyx_t_7; + } else { + __pyx_t_2 = __pyx_t_6; + } + if (!__pyx_t_2) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1428 - * if (i+1 malloc(e_sent_len*sizeof(int)) # <<<<<<<<<<<<<< - * e_links_high = malloc(e_sent_len*sizeof(int)) - * f_links_low = malloc(f_sent_len*sizeof(int)) */ - __pyx_v_e_links_low = ((int *)malloc((__pyx_v_e_sent_len * (sizeof(int))))); + __pyx_t_3 = __pyx_v_e_low; + for (__pyx_v_i = __pyx_v_e_x_low; __pyx_v_i <= __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1432 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1308 * - * e_links_low = malloc(e_sent_len*sizeof(int)) - * e_links_high = malloc(e_sent_len*sizeof(int)) # <<<<<<<<<<<<<< - * f_links_low = malloc(f_sent_len*sizeof(int)) - * f_links_high = malloc(f_sent_len*sizeof(int)) + * for i from e_x_low <= i <= e_low: + * e_gaps1 = self.int_arr_extend(e_gaps1, &len1, &i, 1) # <<<<<<<<<<<<<< + * + * for i from 0 <= i < num_gaps: */ - __pyx_v_e_links_high = ((int *)malloc((__pyx_v_e_sent_len * (sizeof(int))))); + __pyx_v_e_gaps1 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps1, (&__pyx_v_len1), (&__pyx_v_i), 1); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1433 - * e_links_low = malloc(e_sent_len*sizeof(int)) - * e_links_high = malloc(e_sent_len*sizeof(int)) - * f_links_low = malloc(f_sent_len*sizeof(int)) # <<<<<<<<<<<<<< - * f_links_high = malloc(f_sent_len*sizeof(int)) - * f_gap_low = malloc((num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1310 + * e_gaps1 = self.int_arr_extend(e_gaps1, &len1, &i, 1) + * + * for i from 0 <= i < num_gaps: # <<<<<<<<<<<<<< + * e_gaps2 = malloc(0) + * len2 = 0 */ - __pyx_v_f_links_low = ((int *)malloc((__pyx_v_f_sent_len * (sizeof(int))))); + __pyx_t_3 = __pyx_v_num_gaps; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1434 - * e_links_high = malloc(e_sent_len*sizeof(int)) - * f_links_low = malloc(f_sent_len*sizeof(int)) - * f_links_high = malloc(f_sent_len*sizeof(int)) # <<<<<<<<<<<<<< - * f_gap_low = malloc((num_chunks+1)*sizeof(int)) - * f_gap_high = malloc((num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1311 + * + * for i from 0 <= i < num_gaps: + * e_gaps2 = malloc(0) # <<<<<<<<<<<<<< + * len2 = 0 + * */ - __pyx_v_f_links_high = ((int *)malloc((__pyx_v_f_sent_len * (sizeof(int))))); + __pyx_v_e_gaps2 = ((int *)malloc(0)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1435 - * f_links_low = malloc(f_sent_len*sizeof(int)) - * f_links_high = malloc(f_sent_len*sizeof(int)) - * f_gap_low = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * f_gap_high = malloc((num_chunks+1)*sizeof(int)) - * e_gap_low = malloc((num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1312 + * for i from 0 <= i < num_gaps: + * e_gaps2 = malloc(0) + * len2 = 0 # <<<<<<<<<<<<<< + * + * j = e_gap_order[i] */ - __pyx_v_f_gap_low = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); + __pyx_v_len2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1436 - * f_links_high = malloc(f_sent_len*sizeof(int)) - * f_gap_low = malloc((num_chunks+1)*sizeof(int)) - * f_gap_high = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * e_gap_low = malloc((num_chunks+1)*sizeof(int)) - * e_gap_high = malloc((num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1314 + * len2 = 0 + * + * j = e_gap_order[i] # <<<<<<<<<<<<<< + * e_x_gap_low = e_gap_low[j] + * e_x_gap_high = e_gap_high[j] */ - __pyx_v_f_gap_high = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); + __pyx_v_j = (__pyx_v_e_gap_order[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1437 - * f_gap_low = malloc((num_chunks+1)*sizeof(int)) - * f_gap_high = malloc((num_chunks+1)*sizeof(int)) - * e_gap_low = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * e_gap_high = malloc((num_chunks+1)*sizeof(int)) - * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1315 + * + * j = e_gap_order[i] + * e_x_gap_low = e_gap_low[j] # <<<<<<<<<<<<<< + * e_x_gap_high = e_gap_high[j] + * if self.tight_phrases == 0: */ - __pyx_v_e_gap_low = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); + __pyx_v_e_x_gap_low = (__pyx_v_e_gap_low[__pyx_v_j]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1438 - * f_gap_high = malloc((num_chunks+1)*sizeof(int)) - * e_gap_low = malloc((num_chunks+1)*sizeof(int)) - * e_gap_high = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) - * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1316 + * j = e_gap_order[i] + * e_x_gap_low = e_gap_low[j] + * e_x_gap_high = e_gap_high[j] # <<<<<<<<<<<<<< + * if self.tight_phrases == 0: + * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: */ - __pyx_v_e_gap_high = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); + __pyx_v_e_x_gap_high = (__pyx_v_e_gap_high[__pyx_v_j]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1439 - * e_gap_low = malloc((num_chunks+1)*sizeof(int)) - * e_gap_high = malloc((num_chunks+1)*sizeof(int)) - * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) - * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1317 + * e_x_gap_low = e_gap_low[j] + * e_x_gap_high = e_gap_high[j] + * if self.tight_phrases == 0: # <<<<<<<<<<<<<< + * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: + * e_x_gap_low = e_x_gap_low - 1 */ - memset(__pyx_v_f_gap_low, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); + __pyx_t_2 = (__pyx_v_self->tight_phrases == 0); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1440 - * e_gap_high = malloc((num_chunks+1)*sizeof(int)) - * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) - * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) - * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1318 + * e_x_gap_high = e_gap_high[j] + * if self.tight_phrases == 0: + * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: # <<<<<<<<<<<<<< + * e_x_gap_low = e_x_gap_low - 1 + * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: */ - memset(__pyx_v_f_gap_high, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); + while (1) { + __pyx_t_2 = (__pyx_v_e_x_gap_low > __pyx_v_e_x_low); + if (__pyx_t_2) { + __pyx_t_6 = ((__pyx_v_e_links_low[(__pyx_v_e_x_gap_low - 1)]) == -1); + __pyx_t_7 = __pyx_t_6; + } else { + __pyx_t_7 = __pyx_t_2; + } + if (!__pyx_t_7) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1441 - * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) - * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) - * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< - * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1319 + * if self.tight_phrases == 0: + * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: + * e_x_gap_low = e_x_gap_low - 1 # <<<<<<<<<<<<<< + * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: + * e_x_gap_high = e_x_gap_high + 1 */ - memset(__pyx_v_e_gap_low, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); + __pyx_v_e_x_gap_low = (__pyx_v_e_x_gap_low - 1); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1442 - * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) - * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) - * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1320 + * while e_x_gap_low > e_x_low and e_links_low[e_x_gap_low-1] == -1: + * e_x_gap_low = e_x_gap_low - 1 + * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: # <<<<<<<<<<<<<< + * e_x_gap_high = e_x_gap_high + 1 * - * reason_for_failure = "" */ - memset(__pyx_v_e_gap_high, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); + while (1) { + __pyx_t_7 = (__pyx_v_e_x_gap_high < __pyx_v_e_x_high); + if (__pyx_t_7) { + __pyx_t_2 = ((__pyx_v_e_links_low[__pyx_v_e_x_gap_high]) == -1); + __pyx_t_6 = __pyx_t_2; + } else { + __pyx_t_6 = __pyx_t_7; + } + if (!__pyx_t_6) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1444 - * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) - * - * reason_for_failure = "" # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1321 + * e_x_gap_low = e_x_gap_low - 1 + * while e_x_gap_high < e_x_high and e_links_low[e_x_gap_high] == -1: + * e_x_gap_high = e_x_gap_high + 1 # <<<<<<<<<<<<<< * - * for i from 0 <= i < e_sent_len: + * k = 0 */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_45)); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_45); + __pyx_v_e_x_gap_high = (__pyx_v_e_x_gap_high + 1); + } + goto __pyx_L20; + } + __pyx_L20:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1446 - * reason_for_failure = "" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1323 + * e_x_gap_high = e_x_gap_high + 1 * - * for i from 0 <= i < e_sent_len: # <<<<<<<<<<<<<< - * e_links_low[i] = -1 - * e_links_high[i] = -1 + * k = 0 # <<<<<<<<<<<<<< + * step = 1+(i*2) + * while k < len1: */ - __pyx_t_3 = __pyx_v_e_sent_len; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + __pyx_v_k = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1447 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1324 * - * for i from 0 <= i < e_sent_len: - * e_links_low[i] = -1 # <<<<<<<<<<<<<< - * e_links_high[i] = -1 - * for i from 0 <= i < f_sent_len: + * k = 0 + * step = 1+(i*2) # <<<<<<<<<<<<<< + * while k < len1: + * for m from e_x_gap_low <= m <= e_gap_low[j]: */ - (__pyx_v_e_links_low[__pyx_v_i]) = -1; + __pyx_v_step = (1 + (__pyx_v_i * 2)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1448 - * for i from 0 <= i < e_sent_len: - * e_links_low[i] = -1 - * e_links_high[i] = -1 # <<<<<<<<<<<<<< - * for i from 0 <= i < f_sent_len: - * f_links_low[i] = -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1325 + * k = 0 + * step = 1+(i*2) + * while k < len1: # <<<<<<<<<<<<<< + * for m from e_x_gap_low <= m <= e_gap_low[j]: + * if m >= e_gaps1[k+step-1]: */ - (__pyx_v_e_links_high[__pyx_v_i]) = -1; - } + while (1) { + __pyx_t_6 = (__pyx_v_k < __pyx_v_len1); + if (!__pyx_t_6) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1449 - * e_links_low[i] = -1 - * e_links_high[i] = -1 - * for i from 0 <= i < f_sent_len: # <<<<<<<<<<<<<< - * f_links_low[i] = -1 - * f_links_high[i] = -1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1326 + * step = 1+(i*2) + * while k < len1: + * for m from e_x_gap_low <= m <= e_gap_low[j]: # <<<<<<<<<<<<<< + * if m >= e_gaps1[k+step-1]: + * for n from e_gap_high[j] <= n <= e_x_gap_high: */ - __pyx_t_3 = __pyx_v_f_sent_len; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + __pyx_t_4 = (__pyx_v_e_gap_low[__pyx_v_j]); + for (__pyx_v_m = __pyx_v_e_x_gap_low; __pyx_v_m <= __pyx_t_4; __pyx_v_m++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1450 - * e_links_high[i] = -1 - * for i from 0 <= i < f_sent_len: - * f_links_low[i] = -1 # <<<<<<<<<<<<<< - * f_links_high[i] = -1 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1327 + * while k < len1: + * for m from e_x_gap_low <= m <= e_gap_low[j]: + * if m >= e_gaps1[k+step-1]: # <<<<<<<<<<<<<< + * for n from e_gap_high[j] <= n <= e_x_gap_high: + * if n-m >= 1: # extractor.py doesn't restrict target-side gap length */ - (__pyx_v_f_links_low[__pyx_v_i]) = -1; + __pyx_t_6 = (__pyx_v_m >= (__pyx_v_e_gaps1[((__pyx_v_k + __pyx_v_step) - 1)])); + if (__pyx_t_6) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1451 - * for i from 0 <= i < f_sent_len: - * f_links_low[i] = -1 - * f_links_high[i] = -1 # <<<<<<<<<<<<<< - * - * # this is really inefficient -- might be good to + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1328 + * for m from e_x_gap_low <= m <= e_gap_low[j]: + * if m >= e_gaps1[k+step-1]: + * for n from e_gap_high[j] <= n <= e_x_gap_high: # <<<<<<<<<<<<<< + * if n-m >= 1: # extractor.py doesn't restrict target-side gap length + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) */ - (__pyx_v_f_links_high[__pyx_v_i]) = -1; - } + __pyx_t_5 = __pyx_v_e_x_gap_high; + for (__pyx_v_n = (__pyx_v_e_gap_high[__pyx_v_j]); __pyx_v_n <= __pyx_t_5; __pyx_v_n++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1457 - * # links that we care about (but then how to look up - * # when we want to check something on the e side?) - * i = 0 # <<<<<<<<<<<<<< - * while i < num_links*2: - * f_i = sent_links[i] + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1329 + * if m >= e_gaps1[k+step-1]: + * for n from e_gap_high[j] <= n <= e_x_gap_high: + * if n-m >= 1: # extractor.py doesn't restrict target-side gap length # <<<<<<<<<<<<<< + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) */ - __pyx_v_i = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1458 - * # when we want to check something on the e side?) - * i = 0 - * while i < num_links*2: # <<<<<<<<<<<<<< - * f_i = sent_links[i] - * e_i = sent_links[i+1] - */ - while (1) { - __pyx_t_7 = (__pyx_v_i < (__pyx_v_num_links * 2)); - if (!__pyx_t_7) break; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1459 - * i = 0 - * while i < num_links*2: - * f_i = sent_links[i] # <<<<<<<<<<<<<< - * e_i = sent_links[i+1] - * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: - */ - __pyx_v_f_i = (__pyx_v_sent_links[__pyx_v_i]); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1460 - * while i < num_links*2: - * f_i = sent_links[i] - * e_i = sent_links[i+1] # <<<<<<<<<<<<<< - * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: - * f_links_low[f_i] = e_i - */ - __pyx_v_e_i = (__pyx_v_sent_links[(__pyx_v_i + 1)]); - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1461 - * f_i = sent_links[i] - * e_i = sent_links[i+1] - * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: # <<<<<<<<<<<<<< - * f_links_low[f_i] = e_i - * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: - */ - __pyx_t_7 = ((__pyx_v_f_links_low[__pyx_v_f_i]) == -1); - if (!__pyx_t_7) { - __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_i]) > __pyx_v_e_i); - __pyx_t_9 = __pyx_t_8; - } else { - __pyx_t_9 = __pyx_t_7; - } - if (__pyx_t_9) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1462 - * e_i = sent_links[i+1] - * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: - * f_links_low[f_i] = e_i # <<<<<<<<<<<<<< - * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: - * f_links_high[f_i] = e_i + 1 - */ - (__pyx_v_f_links_low[__pyx_v_f_i]) = __pyx_v_e_i; - goto __pyx_L14; - } - __pyx_L14:; + __pyx_t_6 = ((__pyx_v_n - __pyx_v_m) >= 1); + if (__pyx_t_6) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1463 - * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: - * f_links_low[f_i] = e_i - * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: # <<<<<<<<<<<<<< - * f_links_high[f_i] = e_i + 1 - * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1330 + * for n from e_gap_high[j] <= n <= e_x_gap_high: + * if n-m >= 1: # extractor.py doesn't restrict target-side gap length + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) # <<<<<<<<<<<<<< + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) */ - __pyx_t_9 = ((__pyx_v_f_links_high[__pyx_v_f_i]) == -1); - if (!__pyx_t_9) { - __pyx_t_7 = ((__pyx_v_f_links_high[__pyx_v_f_i]) < (__pyx_v_e_i + 1)); - __pyx_t_8 = __pyx_t_7; - } else { - __pyx_t_8 = __pyx_t_9; - } - if (__pyx_t_8) { + __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (__pyx_v_e_gaps1 + __pyx_v_k), __pyx_v_step); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1464 - * f_links_low[f_i] = e_i - * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: - * f_links_high[f_i] = e_i + 1 # <<<<<<<<<<<<<< - * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: - * e_links_low[e_i] = f_i + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1331 + * if n-m >= 1: # extractor.py doesn't restrict target-side gap length + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) # <<<<<<<<<<<<<< + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) + * k = k + step */ - (__pyx_v_f_links_high[__pyx_v_f_i]) = (__pyx_v_e_i + 1); - goto __pyx_L15; - } - __pyx_L15:; + __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (&__pyx_v_m), 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1465 - * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: - * f_links_high[f_i] = e_i + 1 - * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: # <<<<<<<<<<<<<< - * e_links_low[e_i] = f_i - * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1332 + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+k, step) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) # <<<<<<<<<<<<<< + * k = k + step + * free(e_gaps1) */ - __pyx_t_8 = ((__pyx_v_e_links_low[__pyx_v_e_i]) == -1); - if (!__pyx_t_8) { - __pyx_t_9 = ((__pyx_v_e_links_low[__pyx_v_e_i]) > __pyx_v_f_i); - __pyx_t_7 = __pyx_t_9; - } else { - __pyx_t_7 = __pyx_t_8; - } - if (__pyx_t_7) { + __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (&__pyx_v_n), 1); + goto __pyx_L32; + } + __pyx_L32:; + } + goto __pyx_L29; + } + __pyx_L29:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1466 - * f_links_high[f_i] = e_i + 1 - * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: - * e_links_low[e_i] = f_i # <<<<<<<<<<<<<< - * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: - * e_links_high[e_i] = f_i + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1333 + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &m, 1) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) + * k = k + step # <<<<<<<<<<<<<< + * free(e_gaps1) + * e_gaps1 = e_gaps2 */ - (__pyx_v_e_links_low[__pyx_v_e_i]) = __pyx_v_f_i; - goto __pyx_L16; + __pyx_v_k = (__pyx_v_k + __pyx_v_step); } - __pyx_L16:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1467 - * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: - * e_links_low[e_i] = f_i - * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: # <<<<<<<<<<<<<< - * e_links_high[e_i] = f_i + 1 - * i = i + 2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1334 + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &n, 1) + * k = k + step + * free(e_gaps1) # <<<<<<<<<<<<<< + * e_gaps1 = e_gaps2 + * len1 = len2 */ - __pyx_t_7 = ((__pyx_v_e_links_high[__pyx_v_e_i]) == -1); - if (!__pyx_t_7) { - __pyx_t_8 = ((__pyx_v_e_links_high[__pyx_v_e_i]) < (__pyx_v_f_i + 1)); - __pyx_t_9 = __pyx_t_8; - } else { - __pyx_t_9 = __pyx_t_7; - } - if (__pyx_t_9) { + free(__pyx_v_e_gaps1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1468 - * e_links_low[e_i] = f_i - * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: - * e_links_high[e_i] = f_i + 1 # <<<<<<<<<<<<<< - * i = i + 2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1335 + * k = k + step + * free(e_gaps1) + * e_gaps1 = e_gaps2 # <<<<<<<<<<<<<< + * len1 = len2 * */ - (__pyx_v_e_links_high[__pyx_v_e_i]) = (__pyx_v_f_i + 1); - goto __pyx_L17; - } - __pyx_L17:; + __pyx_v_e_gaps1 = __pyx_v_e_gaps2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1469 - * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: - * e_links_high[e_i] = f_i + 1 - * i = i + 2 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1336 + * free(e_gaps1) + * e_gaps1 = e_gaps2 + * len1 = len2 # <<<<<<<<<<<<<< * - * als = [] + * step = 1+(num_gaps*2) */ - __pyx_v_i = (__pyx_v_i + 2); + __pyx_v_len1 = __pyx_v_len2; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1471 - * i = i + 2 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1338 + * len1 = len2 * - * als = [] # <<<<<<<<<<<<<< - * for x in range(matching.start,matching.end): - * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) + * step = 1+(num_gaps*2) # <<<<<<<<<<<<<< + * e_gaps2 = malloc(0) + * len2 = 0 */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1471; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_als = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_step = (1 + (__pyx_v_num_gaps * 2)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1472 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1339 * - * als = [] - * for x in range(matching.start,matching.end): # <<<<<<<<<<<<<< - * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) - * als.append(al) - */ - __pyx_t_3 = __pyx_v_matching->end; - for (__pyx_t_4 = __pyx_v_matching->start; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v_x = __pyx_t_4; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1473 - * als = [] - * for x in range(matching.start,matching.end): - * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) # <<<<<<<<<<<<<< - * als.append(al) - * # check all source-side alignment constraints - */ - __pyx_t_2 = PyInt_FromLong(((__pyx_v_matching->arr[__pyx_v_x]) - __pyx_v_f_sent_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyInt_FromLong((__pyx_v_f_links_low[((__pyx_v_matching->arr[__pyx_v_x]) - __pyx_v_f_sent_start)])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1473; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_2 = 0; - __pyx_t_1 = 0; - __Pyx_XDECREF(((PyObject *)__pyx_v_al)); - __pyx_v_al = __pyx_t_10; - __pyx_t_10 = 0; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1474 - * for x in range(matching.start,matching.end): - * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) - * als.append(al) # <<<<<<<<<<<<<< - * # check all source-side alignment constraints - * met_constraints = 1 + * step = 1+(num_gaps*2) + * e_gaps2 = malloc(0) # <<<<<<<<<<<<<< + * len2 = 0 + * for i from e_high <= i <= e_x_high: */ - __pyx_t_11 = PyList_Append(__pyx_v_als, ((PyObject *)__pyx_v_al)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } + __pyx_v_e_gaps2 = ((int *)malloc(0)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1476 - * als.append(al) - * # check all source-side alignment constraints - * met_constraints = 1 # <<<<<<<<<<<<<< - * if self.require_aligned_terminal: - * num_aligned_chunks = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1340 + * step = 1+(num_gaps*2) + * e_gaps2 = malloc(0) + * len2 = 0 # <<<<<<<<<<<<<< + * for i from e_high <= i <= e_x_high: + * j = 0 */ - __pyx_v_met_constraints = 1; + __pyx_v_len2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1477 - * # check all source-side alignment constraints - * met_constraints = 1 - * if self.require_aligned_terminal: # <<<<<<<<<<<<<< - * num_aligned_chunks = 0 - * for i from 0 <= i < num_chunks: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1341 + * e_gaps2 = malloc(0) + * len2 = 0 + * for i from e_high <= i <= e_x_high: # <<<<<<<<<<<<<< + * j = 0 + * while j < len1: */ - if (__pyx_v_self->require_aligned_terminal) { + __pyx_t_3 = __pyx_v_e_x_high; + for (__pyx_v_i = __pyx_v_e_high; __pyx_v_i <= __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1478 - * met_constraints = 1 - * if self.require_aligned_terminal: - * num_aligned_chunks = 0 # <<<<<<<<<<<<<< - * for i from 0 <= i < num_chunks: - * for j from 0 <= j < chunklen[i]: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1342 + * len2 = 0 + * for i from e_high <= i <= e_x_high: + * j = 0 # <<<<<<<<<<<<<< + * while j < len1: + * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: */ - __pyx_v_num_aligned_chunks = 0; + __pyx_v_j = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1479 - * if self.require_aligned_terminal: - * num_aligned_chunks = 0 - * for i from 0 <= i < num_chunks: # <<<<<<<<<<<<<< - * for j from 0 <= j < chunklen[i]: - * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1343 + * for i from e_high <= i <= e_x_high: + * j = 0 + * while j < len1: # <<<<<<<<<<<<<< + * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) */ - __pyx_t_3 = __pyx_v_num_chunks; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + while (1) { + __pyx_t_6 = (__pyx_v_j < __pyx_v_len1); + if (!__pyx_t_6) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1480 - * num_aligned_chunks = 0 - * for i from 0 <= i < num_chunks: - * for j from 0 <= j < chunklen[i]: # <<<<<<<<<<<<<< - * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: - * num_aligned_chunks = num_aligned_chunks + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1344 + * j = 0 + * while j < len1: + * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: # <<<<<<<<<<<<<< + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) */ - __pyx_t_4 = (__pyx_v_chunklen[__pyx_v_i]); - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_4; __pyx_v_j++) { + __pyx_t_6 = ((__pyx_v_i - (__pyx_v_e_gaps1[__pyx_v_j])) <= __pyx_v_self->train_max_initial_size); + if (__pyx_t_6) { + __pyx_t_7 = (__pyx_v_i >= (__pyx_v_e_gaps1[((__pyx_v_j + __pyx_v_step) - 1)])); + __pyx_t_2 = __pyx_t_7; + } else { + __pyx_t_2 = __pyx_t_6; + } + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1481 - * for i from 0 <= i < num_chunks: - * for j from 0 <= j < chunklen[i]: - * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: # <<<<<<<<<<<<<< - * num_aligned_chunks = num_aligned_chunks + 1 - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1345 + * while j < len1: + * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) # <<<<<<<<<<<<<< + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) + * j = j + step */ - __pyx_t_9 = ((__pyx_v_f_links_low[(((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + __pyx_v_j) - __pyx_v_f_sent_start)]) > -1); - if (__pyx_t_9) { + __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (__pyx_v_e_gaps1 + __pyx_v_j), __pyx_v_step); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1482 - * for j from 0 <= j < chunklen[i]: - * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: - * num_aligned_chunks = num_aligned_chunks + 1 # <<<<<<<<<<<<<< - * break - * if num_aligned_chunks == 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1346 + * if i - e_gaps1[j] <= self.train_max_initial_size and i >= e_gaps1[j+step-1]: + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) # <<<<<<<<<<<<<< + * j = j + step + * free(e_gaps1) */ - __pyx_v_num_aligned_chunks = (__pyx_v_num_aligned_chunks + 1); + __pyx_v_e_gaps2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->int_arr_extend(__pyx_v_self, __pyx_v_e_gaps2, (&__pyx_v_len2), (&__pyx_v_i), 1); + goto __pyx_L37; + } + __pyx_L37:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1483 - * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: - * num_aligned_chunks = num_aligned_chunks + 1 - * break # <<<<<<<<<<<<<< - * if num_aligned_chunks == 0: - * reason_for_failure = "No aligned terminals" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1347 + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, e_gaps1+j, step) + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) + * j = j + step # <<<<<<<<<<<<<< + * free(e_gaps1) + * e_gaps1 = e_gaps2 */ - goto __pyx_L24_break; - goto __pyx_L25; - } - __pyx_L25:; - } - __pyx_L24_break:; + __pyx_v_j = (__pyx_v_j + __pyx_v_step); } + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1484 - * num_aligned_chunks = num_aligned_chunks + 1 - * break - * if num_aligned_chunks == 0: # <<<<<<<<<<<<<< - * reason_for_failure = "No aligned terminals" - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1348 + * e_gaps2 = self.int_arr_extend(e_gaps2, &len2, &i, 1) + * j = j + step + * free(e_gaps1) # <<<<<<<<<<<<<< + * e_gaps1 = e_gaps2 + * len1 = len2 */ - __pyx_t_9 = (__pyx_v_num_aligned_chunks == 0); - if (__pyx_t_9) { + free(__pyx_v_e_gaps1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1485 - * break - * if num_aligned_chunks == 0: - * reason_for_failure = "No aligned terminals" # <<<<<<<<<<<<<< - * met_constraints = 0 - * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1349 + * j = j + step + * free(e_gaps1) + * e_gaps1 = e_gaps2 # <<<<<<<<<<<<<< + * len1 = len2 + * */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_126)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_126); + __pyx_v_e_gaps1 = __pyx_v_e_gaps2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1486 - * if num_aligned_chunks == 0: - * reason_for_failure = "No aligned terminals" - * met_constraints = 0 # <<<<<<<<<<<<<< - * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: - * reason_for_failure = "Unaligned chunk" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1350 + * free(e_gaps1) + * e_gaps1 = e_gaps2 + * len1 = len2 # <<<<<<<<<<<<<< + * + * step = (num_gaps+1)*2 */ - __pyx_v_met_constraints = 0; - goto __pyx_L26; - } - __pyx_L26:; + __pyx_v_len1 = __pyx_v_len2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1487 - * reason_for_failure = "No aligned terminals" - * met_constraints = 0 - * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: # <<<<<<<<<<<<<< - * reason_for_failure = "Unaligned chunk" - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1352 + * len1 = len2 + * + * step = (num_gaps+1)*2 # <<<<<<<<<<<<<< + * i = 0 + * */ - if (__pyx_v_self->require_aligned_chunks) { - __pyx_t_9 = (__pyx_v_num_aligned_chunks < __pyx_v_num_chunks); - __pyx_t_7 = __pyx_t_9; - } else { - __pyx_t_7 = __pyx_v_self->require_aligned_chunks; - } - if (__pyx_t_7) { + __pyx_v_step = ((__pyx_v_num_gaps + 1) * 2); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1488 - * met_constraints = 0 - * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: - * reason_for_failure = "Unaligned chunk" # <<<<<<<<<<<<<< - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1353 + * + * step = (num_gaps+1)*2 + * i = 0 # <<<<<<<<<<<<<< * + * while i < len1: */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_127)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_127); + __pyx_v_i = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1489 - * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: - * reason_for_failure = "Unaligned chunk" - * met_constraints = 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1355 + * i = 0 * - * if met_constraints and self.tight_phrases: + * while i < len1: # <<<<<<<<<<<<<< + * ephr_arr._clear() + * num_chunks = 0 */ - __pyx_v_met_constraints = 0; - goto __pyx_L27; - } - __pyx_L27:; - goto __pyx_L20; - } - __pyx_L20:; + while (1) { + __pyx_t_2 = (__pyx_v_i < __pyx_v_len1); + if (!__pyx_t_2) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1491 - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1356 * - * if met_constraints and self.tight_phrases: # <<<<<<<<<<<<<< - * # outside edge constraints are checked later - * for i from 0 <= i < num_chunks-1: + * while i < len1: + * ephr_arr._clear() # <<<<<<<<<<<<<< + * num_chunks = 0 + * indexes = [] */ - if (__pyx_v_met_constraints) { - __pyx_t_7 = __pyx_v_self->tight_phrases; - } else { - __pyx_t_7 = __pyx_v_met_constraints; - } - if (__pyx_t_7) { + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_ephr_arr->__pyx_vtab)->_clear(__pyx_v_ephr_arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1493 - * if met_constraints and self.tight_phrases: - * # outside edge constraints are checked later - * for i from 0 <= i < num_chunks-1: # <<<<<<<<<<<<<< - * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: - * reason_for_failure = "Gaps are not tight phrases" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1357 + * while i < len1: + * ephr_arr._clear() + * num_chunks = 0 # <<<<<<<<<<<<<< + * indexes = [] + * for j from 0 <= j < num_gaps+1: */ - __pyx_t_12 = (__pyx_v_num_chunks - 1); - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) { + __pyx_v_num_chunks = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1494 - * # outside edge constraints are checked later - * for i from 0 <= i < num_chunks-1: - * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: # <<<<<<<<<<<<<< - * reason_for_failure = "Gaps are not tight phrases" - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1358 + * ephr_arr._clear() + * num_chunks = 0 + * indexes = [] # <<<<<<<<<<<<<< + * for j from 0 <= j < num_gaps+1: + * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: */ - __pyx_t_7 = ((__pyx_v_f_links_low[(((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + (__pyx_v_chunklen[__pyx_v_i])) - __pyx_v_f_sent_start)]) == -1); - if (__pyx_t_7) { + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1358; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(((PyObject *)__pyx_v_indexes)); + __pyx_v_indexes = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1495 - * for i from 0 <= i < num_chunks-1: - * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: - * reason_for_failure = "Gaps are not tight phrases" # <<<<<<<<<<<<<< - * met_constraints = 0 - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1359 + * num_chunks = 0 + * indexes = [] + * for j from 0 <= j < num_gaps+1: # <<<<<<<<<<<<<< + * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: + * num_chunks = num_chunks + 1 */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_128)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_128); + __pyx_t_9 = (__pyx_v_num_gaps + 1); + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_9; __pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1496 - * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: - * reason_for_failure = "Gaps are not tight phrases" - * met_constraints = 0 # <<<<<<<<<<<<<< - * break - * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1360 + * indexes = [] + * for j from 0 <= j < num_gaps+1: + * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: # <<<<<<<<<<<<<< + * num_chunks = num_chunks + 1 + * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: */ - __pyx_v_met_constraints = 0; + __pyx_t_2 = ((__pyx_v_e_gaps1[(__pyx_v_i + (2 * __pyx_v_j))]) < (__pyx_v_e_gaps1[((__pyx_v_i + (2 * __pyx_v_j)) + 1)])); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1497 - * reason_for_failure = "Gaps are not tight phrases" - * met_constraints = 0 - * break # <<<<<<<<<<<<<< - * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: - * reason_for_failure = "Gaps are not tight phrases" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1361 + * for j from 0 <= j < num_gaps+1: + * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: + * num_chunks = num_chunks + 1 # <<<<<<<<<<<<<< + * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: + * indexes.append(k) */ - goto __pyx_L30_break; - goto __pyx_L31; + __pyx_v_num_chunks = (__pyx_v_num_chunks + 1); + goto __pyx_L42; } - __pyx_L31:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1498 - * met_constraints = 0 - * break - * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: # <<<<<<<<<<<<<< - * reason_for_failure = "Gaps are not tight phrases" - * met_constraints = 0 - */ - __pyx_t_7 = ((__pyx_v_f_links_low[(((__pyx_v_matching->arr[((__pyx_v_matching->start + __pyx_v_i) + 1)]) - 1) - __pyx_v_f_sent_start)]) == -1); - if (__pyx_t_7) { + __pyx_L42:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1499 - * break - * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: - * reason_for_failure = "Gaps are not tight phrases" # <<<<<<<<<<<<<< - * met_constraints = 0 - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1362 + * if e_gaps1[i+2*j] < e_gaps1[i+(2*j)+1]: + * num_chunks = num_chunks + 1 + * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: # <<<<<<<<<<<<<< + * indexes.append(k) + * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_128)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_128); + __pyx_t_3 = (__pyx_v_e_gaps1[((__pyx_v_i + (2 * __pyx_v_j)) + 1)]); + for (__pyx_v_k = (__pyx_v_e_gaps1[(__pyx_v_i + (2 * __pyx_v_j))]); __pyx_v_k < __pyx_t_3; __pyx_v_k++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1500 - * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: - * reason_for_failure = "Gaps are not tight phrases" - * met_constraints = 0 # <<<<<<<<<<<<<< - * break - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1363 + * num_chunks = num_chunks + 1 + * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: + * indexes.append(k) # <<<<<<<<<<<<<< + * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) + * if j < num_gaps: */ - __pyx_v_met_constraints = 0; + __pyx_t_1 = PyInt_FromLong(__pyx_v_k); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyList_Append(__pyx_v_indexes, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1501 - * reason_for_failure = "Gaps are not tight phrases" - * met_constraints = 0 - * break # <<<<<<<<<<<<<< - * - * f_low = matching.arr[matching.start] - f_sent_start + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1364 + * for k from e_gaps1[i+2*j] <= k < e_gaps1[i+(2*j)+1]: + * indexes.append(k) + * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) # <<<<<<<<<<<<<< + * if j < num_gaps: + * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) */ - goto __pyx_L30_break; - goto __pyx_L32; + __pyx_t_4 = (__pyx_v_self->eda->data->arr[(__pyx_v_e_sent_start + __pyx_v_k)]); + __pyx_t_1 = __Pyx_GetItemInt(((PyObject *)__pyx_v_self->eid2symid), __pyx_t_4, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_ephr_arr->__pyx_vtab)->_append(__pyx_v_ephr_arr, __pyx_t_4); } - __pyx_L32:; - } - __pyx_L30_break:; - goto __pyx_L28; - } - __pyx_L28:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1503 - * break - * - * f_low = matching.arr[matching.start] - f_sent_start # <<<<<<<<<<<<<< - * f_high = matching.arr[matching.start + matching.size - 1] + chunklen[num_chunks-1] - f_sent_start - * if met_constraints: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1365 + * indexes.append(k) + * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) + * if j < num_gaps: # <<<<<<<<<<<<<< + * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) + * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) */ - __pyx_v_f_low = ((__pyx_v_matching->arr[__pyx_v_matching->start]) - __pyx_v_f_sent_start); + __pyx_t_2 = (__pyx_v_j < __pyx_v_num_gaps); + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1504 - * - * f_low = matching.arr[matching.start] - f_sent_start - * f_high = matching.arr[matching.start + matching.size - 1] + chunklen[num_chunks-1] - f_sent_start # <<<<<<<<<<<<<< - * if met_constraints: - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1366 + * ephr_arr._append(self.eid2symid[self.eda.data.arr[e_sent_start+k]]) + * if j < num_gaps: + * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) # <<<<<<<<<<<<<< + * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) + * i = i + step */ - __pyx_v_f_high = (((__pyx_v_matching->arr[((__pyx_v_matching->start + __pyx_v_matching->size) - 1)]) + (__pyx_v_chunklen[(__pyx_v_num_chunks - 1)])) - __pyx_v_f_sent_start); + __pyx_t_1 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, ((__pyx_v_e_gap_order[__pyx_v_j]) + 1))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyList_Append(__pyx_v_indexes, __pyx_t_1); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1505 - * f_low = matching.arr[matching.start] - f_sent_start - * f_high = matching.arr[matching.start + matching.size - 1] + chunklen[num_chunks-1] - f_sent_start - * if met_constraints: # <<<<<<<<<<<<<< - * - * if self.find_fixpoint(f_low, f_high, f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1367 + * if j < num_gaps: + * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) + * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) # <<<<<<<<<<<<<< + * i = i + step + * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: */ - if (__pyx_v_met_constraints) { + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_ephr_arr->__pyx_vtab)->_append(__pyx_v_ephr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, ((__pyx_v_e_gap_order[__pyx_v_j]) + 1))); + goto __pyx_L45; + } + __pyx_L45:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1507 - * if met_constraints: - * - * if self.find_fixpoint(f_low, f_high, f_links_low, f_links_high, e_links_low, e_links_high, # <<<<<<<<<<<<<< - * -1, -1, &e_low, &e_high, &f_back_low, &f_back_high, f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1368 + * indexes.append(sym_setindex(self.category, e_gap_order[j]+1)) + * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) + * i = i + step # <<<<<<<<<<<<<< + * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: + * result.append((Phrase(ephr_arr),indexes)) */ - __pyx_t_10 = PyInt_FromLong(__pyx_v_f_high); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); + __pyx_v_i = (__pyx_v_i + __pyx_v_step); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1511 - * self.train_max_initial_size, self.train_max_initial_size, - * self.train_min_gap_size, 0, - * self.max_nonterminals - num_chunks + 1, 1, 1, 0, 0): # <<<<<<<<<<<<<< - * gap_error = 0 - * num_gaps = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1369 + * ephr_arr._append(sym_setindex(self.category, e_gap_order[j]+1)) + * i = i + step + * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: # <<<<<<<<<<<<<< + * result.append((Phrase(ephr_arr),indexes)) + * */ - __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_low, __pyx_t_10, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, (&__pyx_v_e_low), (&__pyx_v_e_high), (&__pyx_v_f_back_low), (&__pyx_v_f_back_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_min_gap_size, 0, ((__pyx_v_self->max_nonterminals - __pyx_v_num_chunks) + 1), 1, 1, 0, 0); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_3) { + __pyx_t_2 = (__pyx_v_ephr_arr->len <= __pyx_v_self->max_target_length); + if (__pyx_t_2) { + __pyx_t_6 = (__pyx_v_num_chunks <= __pyx_v_self->max_target_chunks); + __pyx_t_7 = __pyx_t_6; + } else { + __pyx_t_7 = __pyx_t_2; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1512 - * self.train_min_gap_size, 0, - * self.max_nonterminals - num_chunks + 1, 1, 1, 0, 0): - * gap_error = 0 # <<<<<<<<<<<<<< - * num_gaps = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1370 + * i = i + step + * if ephr_arr.len <= self.max_target_length and num_chunks <= self.max_target_chunks: + * result.append((Phrase(ephr_arr),indexes)) # <<<<<<<<<<<<<< * + * free(e_gaps1) */ - __pyx_v_gap_error = 0; + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_ephr_arr)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_ephr_arr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_ephr_arr)); + __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_11); + __Pyx_GIVEREF(__pyx_t_11); + __Pyx_INCREF(((PyObject *)__pyx_v_indexes)); + PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_indexes)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_indexes)); + __pyx_t_11 = 0; + __pyx_t_11 = __Pyx_PyObject_Append(__pyx_v_result, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_11); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0; + goto __pyx_L46; + } + __pyx_L46:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1513 - * self.max_nonterminals - num_chunks + 1, 1, 1, 0, 0): - * gap_error = 0 - * num_gaps = 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1372 + * result.append((Phrase(ephr_arr),indexes)) * - * if f_back_low < f_low: + * free(e_gaps1) # <<<<<<<<<<<<<< + * free(e_gap_order) + * return result */ - __pyx_v_num_gaps = 0; + free(__pyx_v_e_gaps1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1515 - * num_gaps = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1373 + * + * free(e_gaps1) + * free(e_gap_order) # <<<<<<<<<<<<<< + * return result * - * if f_back_low < f_low: # <<<<<<<<<<<<<< - * f_gap_low[0] = f_back_low - * f_gap_high[0] = f_low */ - __pyx_t_7 = (__pyx_v_f_back_low < __pyx_v_f_low); - if (__pyx_t_7) { + free(__pyx_v_e_gap_order); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1516 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1374 + * free(e_gaps1) + * free(e_gap_order) + * return result # <<<<<<<<<<<<<< * - * if f_back_low < f_low: - * f_gap_low[0] = f_back_low # <<<<<<<<<<<<<< - * f_gap_high[0] = f_low - * num_gaps = 1 + * cdef IntList create_alignments(self, int* sent_links, int num_links, findexes, eindexes): */ - (__pyx_v_f_gap_low[0]) = __pyx_v_f_back_low; + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_result); + __pyx_r = __pyx_v_result; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1517 - * if f_back_low < f_low: - * f_gap_low[0] = f_back_low - * f_gap_high[0] = f_low # <<<<<<<<<<<<<< - * num_gaps = 1 - * gap_start = 0 - */ - (__pyx_v_f_gap_high[0]) = __pyx_v_f_low; + __pyx_r = Py_None; __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_11); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.extract_phrases", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_ephr_arr); + __Pyx_XDECREF(__pyx_v_result); + __Pyx_XDECREF(__pyx_v_indexes); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1518 - * f_gap_low[0] = f_back_low - * f_gap_high[0] = f_low - * num_gaps = 1 # <<<<<<<<<<<<<< - * gap_start = 0 - * phrase_len = phrase_len+1 +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1376 + * return result + * + * cdef IntList create_alignments(self, int* sent_links, int num_links, findexes, eindexes): # <<<<<<<<<<<<<< + * cdef unsigned i + * cdef IntList ret = IntList() */ - __pyx_v_num_gaps = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1519 - * f_gap_high[0] = f_low - * num_gaps = 1 - * gap_start = 0 # <<<<<<<<<<<<<< - * phrase_len = phrase_len+1 - * if phrase_len > self.max_length: - */ - __pyx_v_gap_start = 0; +static struct __pyx_obj_3_sa_IntList *__pyx_f_3_sa_23HieroCachingRuleFactory_create_alignments(CYTHON_UNUSED struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, int *__pyx_v_sent_links, int __pyx_v_num_links, PyObject *__pyx_v_findexes, PyObject *__pyx_v_eindexes) { + unsigned int __pyx_v_i; + struct __pyx_obj_3_sa_IntList *__pyx_v_ret = 0; + PyObject *__pyx_v_s = NULL; + PyObject *__pyx_v_idx = NULL; + PyObject *__pyx_v_j = NULL; + struct __pyx_obj_3_sa_IntList *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + Py_ssize_t __pyx_t_2; + unsigned int __pyx_t_3; + int __pyx_t_4; + PyObject *__pyx_t_5 = NULL; + Py_ssize_t __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("create_alignments", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1520 - * num_gaps = 1 - * gap_start = 0 - * phrase_len = phrase_len+1 # <<<<<<<<<<<<<< - * if phrase_len > self.max_length: - * gap_error = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1378 + * cdef IntList create_alignments(self, int* sent_links, int num_links, findexes, eindexes): + * cdef unsigned i + * cdef IntList ret = IntList() # <<<<<<<<<<<<<< + * for i in range(len(findexes)): + * s = findexes[i] */ - __pyx_v_phrase_len = (__pyx_v_phrase_len + 1); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_ret = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1521 - * gap_start = 0 - * phrase_len = phrase_len+1 - * if phrase_len > self.max_length: # <<<<<<<<<<<<<< - * gap_error = 1 - * if self.tight_phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1379 + * cdef unsigned i + * cdef IntList ret = IntList() + * for i in range(len(findexes)): # <<<<<<<<<<<<<< + * s = findexes[i] + * if (s<0): */ - __pyx_t_7 = (__pyx_v_phrase_len > __pyx_v_self->max_length); - if (__pyx_t_7) { + __pyx_t_2 = PyObject_Length(__pyx_v_findexes); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1522 - * phrase_len = phrase_len+1 - * if phrase_len > self.max_length: - * gap_error = 1 # <<<<<<<<<<<<<< - * if self.tight_phrases: - * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1380 + * cdef IntList ret = IntList() + * for i in range(len(findexes)): + * s = findexes[i] # <<<<<<<<<<<<<< + * if (s<0): + * continue */ - __pyx_v_gap_error = 1; - goto __pyx_L36; - } - __pyx_L36:; + __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_findexes, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_v_s); + __pyx_v_s = __pyx_t_1; + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1523 - * if phrase_len > self.max_length: - * gap_error = 1 - * if self.tight_phrases: # <<<<<<<<<<<<<< - * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: - * gap_error = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1381 + * for i in range(len(findexes)): + * s = findexes[i] + * if (s<0): # <<<<<<<<<<<<<< + * continue + * idx = 0 */ - if (__pyx_v_self->tight_phrases) { + __pyx_t_1 = PyObject_RichCompare(__pyx_v_s, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1524 - * gap_error = 1 - * if self.tight_phrases: - * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: # <<<<<<<<<<<<<< - * gap_error = 1 - * reason_for_failure = "Inside edges of preceding subphrase are not tight" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1382 + * s = findexes[i] + * if (s<0): + * continue # <<<<<<<<<<<<<< + * idx = 0 + * while (idx < num_links*2): */ - __pyx_t_7 = ((__pyx_v_f_links_low[__pyx_v_f_back_low]) == -1); - if (!__pyx_t_7) { - __pyx_t_9 = ((__pyx_v_f_links_low[(__pyx_v_f_low - 1)]) == -1); - __pyx_t_8 = __pyx_t_9; - } else { - __pyx_t_8 = __pyx_t_7; - } - if (__pyx_t_8) { + goto __pyx_L3_continue; + goto __pyx_L5; + } + __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1525 - * if self.tight_phrases: - * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: - * gap_error = 1 # <<<<<<<<<<<<<< - * reason_for_failure = "Inside edges of preceding subphrase are not tight" - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1383 + * if (s<0): + * continue + * idx = 0 # <<<<<<<<<<<<<< + * while (idx < num_links*2): + * if (sent_links[idx] == s): */ - __pyx_v_gap_error = 1; + __Pyx_INCREF(__pyx_int_0); + __Pyx_XDECREF(__pyx_v_idx); + __pyx_v_idx = __pyx_int_0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1526 - * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: - * gap_error = 1 - * reason_for_failure = "Inside edges of preceding subphrase are not tight" # <<<<<<<<<<<<<< - * else: - * gap_start = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1384 + * continue + * idx = 0 + * while (idx < num_links*2): # <<<<<<<<<<<<<< + * if (sent_links[idx] == s): + * j = eindexes.index(sent_links[idx+1]) */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_129)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_129); - goto __pyx_L38; - } - __pyx_L38:; - goto __pyx_L37; - } - __pyx_L37:; - goto __pyx_L35; - } - /*else*/ { + while (1) { + __pyx_t_1 = PyInt_FromLong((__pyx_v_num_links * 2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyObject_RichCompare(__pyx_v_idx, __pyx_t_1, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1384; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + if (!__pyx_t_4) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1528 - * reason_for_failure = "Inside edges of preceding subphrase are not tight" - * else: - * gap_start = 1 # <<<<<<<<<<<<<< - * if self.tight_phrases and f_links_low[f_low] == -1: - * # this is not a hard error. we can't extract this phrase + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1385 + * idx = 0 + * while (idx < num_links*2): + * if (sent_links[idx] == s): # <<<<<<<<<<<<<< + * j = eindexes.index(sent_links[idx+1]) + * ret.append(i*65536+j) */ - __pyx_v_gap_start = 1; + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_idx); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong((__pyx_v_sent_links[__pyx_t_6])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_1 = PyObject_RichCompare(__pyx_t_5, __pyx_v_s, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1529 - * else: - * gap_start = 1 - * if self.tight_phrases and f_links_low[f_low] == -1: # <<<<<<<<<<<<<< - * # this is not a hard error. we can't extract this phrase - * # but we still might be able to extract a superphrase + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1386 + * while (idx < num_links*2): + * if (sent_links[idx] == s): + * j = eindexes.index(sent_links[idx+1]) # <<<<<<<<<<<<<< + * ret.append(i*65536+j) + * idx += 2 */ - if (__pyx_v_self->tight_phrases) { - __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_low]) == -1); - __pyx_t_7 = __pyx_t_8; - } else { - __pyx_t_7 = __pyx_v_self->tight_phrases; - } - if (__pyx_t_7) { + __pyx_t_1 = PyObject_GetAttr(__pyx_v_eindexes, __pyx_n_s__index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_5 = PyNumber_Add(__pyx_v_idx, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_t_5); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = PyInt_FromLong((__pyx_v_sent_links[__pyx_t_6])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); + __Pyx_GIVEREF(__pyx_t_5); + __pyx_t_5 = 0; + __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; + __Pyx_XDECREF(__pyx_v_j); + __pyx_v_j = __pyx_t_5; + __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1532 - * # this is not a hard error. we can't extract this phrase - * # but we still might be able to extract a superphrase - * met_constraints = 0 # <<<<<<<<<<<<<< - * - * for i from 0 <= i < matching.size - 1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1387 + * if (sent_links[idx] == s): + * j = eindexes.index(sent_links[idx+1]) + * ret.append(i*65536+j) # <<<<<<<<<<<<<< + * idx += 2 + * return ret */ - __pyx_v_met_constraints = 0; - goto __pyx_L39; - } - __pyx_L39:; + __pyx_t_5 = PyInt_FromLong((__pyx_v_i * 65536)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_j); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_7); + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + __pyx_t_5 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_ret), __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; + __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; + goto __pyx_L8; } - __pyx_L35:; + __pyx_L8:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1534 - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1388 + * j = eindexes.index(sent_links[idx+1]) + * ret.append(i*65536+j) + * idx += 2 # <<<<<<<<<<<<<< + * return ret * - * for i from 0 <= i < matching.size - 1: # <<<<<<<<<<<<<< - * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start - * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start */ - __pyx_t_12 = (__pyx_v_matching->size - 1); - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) { + __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_idx, __pyx_int_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_DECREF(__pyx_v_idx); + __pyx_v_idx = __pyx_t_5; + __pyx_t_5 = 0; + } + __pyx_L3_continue:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1535 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1389 + * ret.append(i*65536+j) + * idx += 2 + * return ret # <<<<<<<<<<<<<< * - * for i from 0 <= i < matching.size - 1: - * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start # <<<<<<<<<<<<<< - * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start - * num_gaps = num_gaps + 1 + * cdef extract(self, Phrase phrase, Matching* matching, int* chunklen, int num_chunks): */ - (__pyx_v_f_gap_low[(1 + __pyx_v_i)]) = (((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + (__pyx_v_chunklen[__pyx_v_i])) - __pyx_v_f_sent_start); + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_ret)); + __pyx_r = __pyx_v_ret; + goto __pyx_L0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1536 - * for i from 0 <= i < matching.size - 1: - * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start - * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start # <<<<<<<<<<<<<< - * num_gaps = num_gaps + 1 - * - */ - (__pyx_v_f_gap_high[(1 + __pyx_v_i)]) = ((__pyx_v_matching->arr[((__pyx_v_matching->start + __pyx_v_i) + 1)]) - __pyx_v_f_sent_start); + __pyx_r = ((struct __pyx_obj_3_sa_IntList *)Py_None); __Pyx_INCREF(Py_None); + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_5); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.create_alignments", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF((PyObject *)__pyx_v_ret); + __Pyx_XDECREF(__pyx_v_s); + __Pyx_XDECREF(__pyx_v_idx); + __Pyx_XDECREF(__pyx_v_j); + __Pyx_XGIVEREF((PyObject *)__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1537 - * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start - * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start - * num_gaps = num_gaps + 1 # <<<<<<<<<<<<<< +/* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1391 + * return ret * - * if f_high < f_back_high: + * cdef extract(self, Phrase phrase, Matching* matching, int* chunklen, int num_chunks): # <<<<<<<<<<<<<< + * cdef int* sent_links, *e_links_low, *e_links_high, *f_links_low, *f_links_high + * cdef int *f_gap_low, *f_gap_high, *e_gap_low, *e_gap_high, num_gaps, gap_start */ - __pyx_v_num_gaps = (__pyx_v_num_gaps + 1); - } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1539 - * num_gaps = num_gaps + 1 - * - * if f_high < f_back_high: # <<<<<<<<<<<<<< - * f_gap_low[gap_start+num_gaps] = f_high - * f_gap_high[gap_start+num_gaps] = f_back_high - */ - __pyx_t_7 = (__pyx_v_f_high < __pyx_v_f_back_high); - if (__pyx_t_7) { +static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj_3_sa_HieroCachingRuleFactory *__pyx_v_self, struct __pyx_obj_3_sa_Phrase *__pyx_v_phrase, struct __pyx_t_3_sa_Matching *__pyx_v_matching, int *__pyx_v_chunklen, int __pyx_v_num_chunks) { + int *__pyx_v_sent_links; + int *__pyx_v_e_links_low; + int *__pyx_v_e_links_high; + int *__pyx_v_f_links_low; + int *__pyx_v_f_links_high; + int *__pyx_v_f_gap_low; + int *__pyx_v_f_gap_high; + int *__pyx_v_e_gap_low; + int *__pyx_v_e_gap_high; + int __pyx_v_num_gaps; + int __pyx_v_gap_start; + int __pyx_v_i; + int __pyx_v_j; + int __pyx_v_e_i; + int __pyx_v_f_i; + int __pyx_v_num_links; + int __pyx_v_num_aligned_chunks; + int __pyx_v_met_constraints; + int __pyx_v_x; + int __pyx_v_f_low; + int __pyx_v_f_high; + int __pyx_v_e_low; + int __pyx_v_e_high; + int __pyx_v_f_back_low; + int __pyx_v_f_back_high; + int __pyx_v_e_sent_start; + int __pyx_v_e_sent_end; + int __pyx_v_f_sent_start; + int __pyx_v_f_sent_end; + int __pyx_v_e_sent_len; + int __pyx_v_f_sent_len; + CYTHON_UNUSED int __pyx_v_e_word_count; + int __pyx_v_f_x_low; + int __pyx_v_f_x_high; + int __pyx_v_e_x_low; + int __pyx_v_e_x_high; + int __pyx_v_phrase_len; + float __pyx_v_pair_count; + PyObject *__pyx_v_extracts = 0; + PyObject *__pyx_v_phrase_list = 0; + struct __pyx_obj_3_sa_IntList *__pyx_v_fphr_arr = 0; + struct __pyx_obj_3_sa_Phrase *__pyx_v_fphr = 0; + CYTHON_UNUSED PyObject *__pyx_v_reason_for_failure = 0; + PyObject *__pyx_v_sofar = NULL; + PyObject *__pyx_v_als = NULL; + PyObject *__pyx_v_al = NULL; + long __pyx_v_gap_error; + PyObject *__pyx_v_phrase2 = NULL; + PyObject *__pyx_v_eindexes = NULL; + struct __pyx_obj_3_sa_IntList *__pyx_v_als1 = NULL; + struct __pyx_obj_3_sa_IntList *__pyx_v_als2 = NULL; + struct __pyx_obj_3_sa_IntList *__pyx_v_als3 = NULL; + struct __pyx_obj_3_sa_IntList *__pyx_v_als4 = NULL; + PyObject *__pyx_r = NULL; + __Pyx_RefNannyDeclarations + PyObject *__pyx_t_1 = NULL; + PyObject *__pyx_t_2 = NULL; + int __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + int __pyx_t_7; + int __pyx_t_8; + int __pyx_t_9; + PyObject *__pyx_t_10 = NULL; + int __pyx_t_11; + long __pyx_t_12; + Py_ssize_t __pyx_t_13; + PyObject *__pyx_t_14 = NULL; + PyObject *__pyx_t_15 = NULL; + PyObject *(*__pyx_t_16)(PyObject *); + PyObject *(*__pyx_t_17)(PyObject *); + int __pyx_t_18; + int __pyx_t_19; + int __pyx_t_20; + int __pyx_t_21; + int __pyx_t_22; + int __pyx_t_23; + int __pyx_t_24; + int __pyx_t_25; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("extract", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1540 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1404 + * cdef reason_for_failure * - * if f_high < f_back_high: - * f_gap_low[gap_start+num_gaps] = f_high # <<<<<<<<<<<<<< - * f_gap_high[gap_start+num_gaps] = f_back_high - * num_gaps = num_gaps + 1 - */ - (__pyx_v_f_gap_low[(__pyx_v_gap_start + __pyx_v_num_gaps)]) = __pyx_v_f_high; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1541 - * if f_high < f_back_high: - * f_gap_low[gap_start+num_gaps] = f_high - * f_gap_high[gap_start+num_gaps] = f_back_high # <<<<<<<<<<<<<< - * num_gaps = num_gaps + 1 - * phrase_len = phrase_len+1 + * fphr_arr = IntList() # <<<<<<<<<<<<<< + * phrase_len = phrase.n + * extracts = [] */ - (__pyx_v_f_gap_high[(__pyx_v_gap_start + __pyx_v_num_gaps)]) = __pyx_v_f_back_high; + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_IntList)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1404; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_fphr_arr = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1542 - * f_gap_low[gap_start+num_gaps] = f_high - * f_gap_high[gap_start+num_gaps] = f_back_high - * num_gaps = num_gaps + 1 # <<<<<<<<<<<<<< - * phrase_len = phrase_len+1 - * if phrase_len > self.max_length: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1405 + * + * fphr_arr = IntList() + * phrase_len = phrase.n # <<<<<<<<<<<<<< + * extracts = [] + * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) */ - __pyx_v_num_gaps = (__pyx_v_num_gaps + 1); + __pyx_v_phrase_len = __pyx_v_phrase->n; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1543 - * f_gap_high[gap_start+num_gaps] = f_back_high - * num_gaps = num_gaps + 1 - * phrase_len = phrase_len+1 # <<<<<<<<<<<<<< - * if phrase_len > self.max_length: - * gap_error = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1406 + * fphr_arr = IntList() + * phrase_len = phrase.n + * extracts = [] # <<<<<<<<<<<<<< + * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) + * */ - __pyx_v_phrase_len = (__pyx_v_phrase_len + 1); + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1406; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_extracts = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1544 - * num_gaps = num_gaps + 1 - * phrase_len = phrase_len+1 - * if phrase_len > self.max_length: # <<<<<<<<<<<<<< - * gap_error = 1 - * if self.tight_phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1407 + * phrase_len = phrase.n + * extracts = [] + * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) # <<<<<<<<<<<<<< + * + * e_sent_start = self.eda.sent_index.arr[matching.sent_id] */ - __pyx_t_7 = (__pyx_v_phrase_len > __pyx_v_self->max_length); - if (__pyx_t_7) { + __pyx_v_sent_links = ((struct __pyx_vtabstruct_3_sa_Alignment *)__pyx_v_self->alignment->__pyx_vtab)->_get_sent_links(__pyx_v_self->alignment, __pyx_v_matching->sent_id, (&__pyx_v_num_links)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1545 - * phrase_len = phrase_len+1 - * if phrase_len > self.max_length: - * gap_error = 1 # <<<<<<<<<<<<<< - * if self.tight_phrases: - * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1409 + * sent_links = self.alignment._get_sent_links(matching.sent_id, &num_links) + * + * e_sent_start = self.eda.sent_index.arr[matching.sent_id] # <<<<<<<<<<<<<< + * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] + * e_sent_len = e_sent_end - e_sent_start - 1 */ - __pyx_v_gap_error = 1; - goto __pyx_L43; - } - __pyx_L43:; + __pyx_v_e_sent_start = (__pyx_v_self->eda->sent_index->arr[__pyx_v_matching->sent_id]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1546 - * if phrase_len > self.max_length: - * gap_error = 1 - * if self.tight_phrases: # <<<<<<<<<<<<<< - * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: - * gap_error = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1410 + * + * e_sent_start = self.eda.sent_index.arr[matching.sent_id] + * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] # <<<<<<<<<<<<<< + * e_sent_len = e_sent_end - e_sent_start - 1 + * f_sent_start = self.fda.sent_index.arr[matching.sent_id] */ - if (__pyx_v_self->tight_phrases) { + __pyx_v_e_sent_end = (__pyx_v_self->eda->sent_index->arr[(__pyx_v_matching->sent_id + 1)]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1547 - * gap_error = 1 - * if self.tight_phrases: - * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: # <<<<<<<<<<<<<< - * gap_error = 1 - * reason_for_failure = "Inside edges of following subphrase are not tight" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1411 + * e_sent_start = self.eda.sent_index.arr[matching.sent_id] + * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] + * e_sent_len = e_sent_end - e_sent_start - 1 # <<<<<<<<<<<<<< + * f_sent_start = self.fda.sent_index.arr[matching.sent_id] + * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] */ - __pyx_t_7 = ((__pyx_v_f_links_low[(__pyx_v_f_back_high - 1)]) == -1); - if (!__pyx_t_7) { - __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_high]) == -1); - __pyx_t_9 = __pyx_t_8; - } else { - __pyx_t_9 = __pyx_t_7; - } - if (__pyx_t_9) { + __pyx_v_e_sent_len = ((__pyx_v_e_sent_end - __pyx_v_e_sent_start) - 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1548 - * if self.tight_phrases: - * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: - * gap_error = 1 # <<<<<<<<<<<<<< - * reason_for_failure = "Inside edges of following subphrase are not tight" - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1412 + * e_sent_end = self.eda.sent_index.arr[matching.sent_id+1] + * e_sent_len = e_sent_end - e_sent_start - 1 + * f_sent_start = self.fda.sent_index.arr[matching.sent_id] # <<<<<<<<<<<<<< + * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] + * f_sent_len = f_sent_end - f_sent_start - 1 */ - __pyx_v_gap_error = 1; + __pyx_v_f_sent_start = (__pyx_v_self->fda->sent_index->arr[__pyx_v_matching->sent_id]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1549 - * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: - * gap_error = 1 - * reason_for_failure = "Inside edges of following subphrase are not tight" # <<<<<<<<<<<<<< - * else: - * if self.tight_phrases and f_links_low[f_high-1] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1413 + * e_sent_len = e_sent_end - e_sent_start - 1 + * f_sent_start = self.fda.sent_index.arr[matching.sent_id] + * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] # <<<<<<<<<<<<<< + * f_sent_len = f_sent_end - f_sent_start - 1 + * */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_130)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_130); - goto __pyx_L45; - } - __pyx_L45:; - goto __pyx_L44; - } - __pyx_L44:; - goto __pyx_L42; - } - /*else*/ { + __pyx_v_f_sent_end = (__pyx_v_self->fda->sent_index->arr[(__pyx_v_matching->sent_id + 1)]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1551 - * reason_for_failure = "Inside edges of following subphrase are not tight" - * else: - * if self.tight_phrases and f_links_low[f_high-1] == -1: # <<<<<<<<<<<<<< - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1414 + * f_sent_start = self.fda.sent_index.arr[matching.sent_id] + * f_sent_end = self.fda.sent_index.arr[matching.sent_id+1] + * f_sent_len = f_sent_end - f_sent_start - 1 # <<<<<<<<<<<<<< * + * self.findexes1.reset() */ - if (__pyx_v_self->tight_phrases) { - __pyx_t_9 = ((__pyx_v_f_links_low[(__pyx_v_f_high - 1)]) == -1); - __pyx_t_7 = __pyx_t_9; - } else { - __pyx_t_7 = __pyx_v_self->tight_phrases; - } - if (__pyx_t_7) { + __pyx_v_f_sent_len = ((__pyx_v_f_sent_end - __pyx_v_f_sent_start) - 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1552 - * else: - * if self.tight_phrases and f_links_low[f_high-1] == -1: - * met_constraints = 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1416 + * f_sent_len = f_sent_end - f_sent_start - 1 * - * if gap_error == 0: + * self.findexes1.reset() # <<<<<<<<<<<<<< + * sofar = 0 + * for i in range(num_chunks): */ - __pyx_v_met_constraints = 0; - goto __pyx_L46; - } - __pyx_L46:; - } - __pyx_L42:; + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes1), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1416; __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[8]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1554 - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1417 * - * if gap_error == 0: # <<<<<<<<<<<<<< - * e_word_count = e_high - e_low - * for i from 0 <= i < num_gaps: # check integrity of subphrases + * self.findexes1.reset() + * sofar = 0 # <<<<<<<<<<<<<< + * for i in range(num_chunks): + * for j in range(chunklen[i]): */ - __pyx_t_7 = (__pyx_v_gap_error == 0); - if (__pyx_t_7) { + __Pyx_INCREF(__pyx_int_0); + __pyx_v_sofar = __pyx_int_0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1555 - * - * if gap_error == 0: - * e_word_count = e_high - e_low # <<<<<<<<<<<<<< - * for i from 0 <= i < num_gaps: # check integrity of subphrases - * if self.find_fixpoint(f_gap_low[gap_start+i], f_gap_high[gap_start+i], + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1418 + * self.findexes1.reset() + * sofar = 0 + * for i in range(num_chunks): # <<<<<<<<<<<<<< + * for j in range(chunklen[i]): + * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); */ - __pyx_v_e_word_count = (__pyx_v_e_high - __pyx_v_e_low); + __pyx_t_3 = __pyx_v_num_chunks; + for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1556 - * if gap_error == 0: - * e_word_count = e_high - e_low - * for i from 0 <= i < num_gaps: # check integrity of subphrases # <<<<<<<<<<<<<< - * if self.find_fixpoint(f_gap_low[gap_start+i], f_gap_high[gap_start+i], - * f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1419 + * sofar = 0 + * for i in range(num_chunks): + * for j in range(chunklen[i]): # <<<<<<<<<<<<<< + * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); + * sofar += 1 */ - __pyx_t_3 = __pyx_v_num_gaps; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { + __pyx_t_5 = (__pyx_v_chunklen[__pyx_v_i]); + for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { + __pyx_v_j = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1557 - * e_word_count = e_high - e_low - * for i from 0 <= i < num_gaps: # check integrity of subphrases - * if self.find_fixpoint(f_gap_low[gap_start+i], f_gap_high[gap_start+i], # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * -1, -1, e_gap_low+gap_start+i, e_gap_high+gap_start+i, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1420 + * for i in range(num_chunks): + * for j in range(chunklen[i]): + * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); # <<<<<<<<<<<<<< + * sofar += 1 + * if (i+1arr[(__pyx_v_matching->start + __pyx_v_i)]) + __pyx_v_j) - __pyx_v_f_sent_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes1), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1562 - * f_gap_low+gap_start+i, f_gap_high+gap_start+i, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 0, 0, 0, 0, 0, 0, 0) == 0: - * gap_error = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1421 + * for j in range(chunklen[i]): + * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); + * sofar += 1 # <<<<<<<<<<<<<< + * if (i+1__pyx_vtab)->find_fixpoint(__pyx_v_self, (__pyx_v_f_gap_low[(__pyx_v_gap_start + __pyx_v_i)]), __pyx_t_10, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, ((__pyx_v_e_gap_low + __pyx_v_gap_start) + __pyx_v_i), ((__pyx_v_e_gap_high + __pyx_v_gap_start) + __pyx_v_i), ((__pyx_v_f_gap_low + __pyx_v_gap_start) + __pyx_v_i), ((__pyx_v_f_gap_high + __pyx_v_gap_start) + __pyx_v_i), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0) == 0); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - if (__pyx_t_7) { + __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_sofar, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_v_sofar); + __pyx_v_sofar = __pyx_t_1; + __pyx_t_1 = 0; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1564 - * self.train_max_initial_size, self.train_max_initial_size, - * 0, 0, 0, 0, 0, 0, 0) == 0: - * gap_error = 1 # <<<<<<<<<<<<<< - * reason_for_failure = "Subphrase [%d, %d] failed integrity check" % (f_gap_low[gap_start+i], f_gap_high[gap_start+i]) - * break + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1422 + * self.findexes1.append(matching.arr[matching.start+i]+j-f_sent_start); + * sofar += 1 + * if (i+1findexes1), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1566 - * gap_error = 1 - * reason_for_failure = "Subphrase [%d, %d] failed integrity check" % (f_gap_low[gap_start+i], f_gap_high[gap_start+i]) - * break # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1424 + * if (i+1 malloc(e_sent_len*sizeof(int)) # <<<<<<<<<<<<<< + * e_links_high = malloc(e_sent_len*sizeof(int)) + * f_links_low = malloc(f_sent_len*sizeof(int)) */ - __pyx_t_7 = (__pyx_v_gap_error == 0); - if (__pyx_t_7) { + __pyx_v_e_links_low = ((int *)malloc((__pyx_v_e_sent_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1569 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1428 * - * if gap_error == 0: - * i = 1 # <<<<<<<<<<<<<< - * self.findexes.reset() - * if f_back_low < f_low: + * e_links_low = malloc(e_sent_len*sizeof(int)) + * e_links_high = malloc(e_sent_len*sizeof(int)) # <<<<<<<<<<<<<< + * f_links_low = malloc(f_sent_len*sizeof(int)) + * f_links_high = malloc(f_sent_len*sizeof(int)) */ - __pyx_v_i = 1; + __pyx_v_e_links_high = ((int *)malloc((__pyx_v_e_sent_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1570 - * if gap_error == 0: - * i = 1 - * self.findexes.reset() # <<<<<<<<<<<<<< - * if f_back_low < f_low: - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1429 + * e_links_low = malloc(e_sent_len*sizeof(int)) + * e_links_high = malloc(e_sent_len*sizeof(int)) + * f_links_low = malloc(f_sent_len*sizeof(int)) # <<<<<<<<<<<<<< + * f_links_high = malloc(f_sent_len*sizeof(int)) + * f_gap_low = malloc((num_chunks+1)*sizeof(int)) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1570; __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[8]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_v_f_links_low = ((int *)malloc((__pyx_v_f_sent_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1571 - * i = 1 - * self.findexes.reset() - * if f_back_low < f_low: # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1430 + * e_links_high = malloc(e_sent_len*sizeof(int)) + * f_links_low = malloc(f_sent_len*sizeof(int)) + * f_links_high = malloc(f_sent_len*sizeof(int)) # <<<<<<<<<<<<<< + * f_gap_low = malloc((num_chunks+1)*sizeof(int)) + * f_gap_high = malloc((num_chunks+1)*sizeof(int)) */ - __pyx_t_7 = (__pyx_v_f_back_low < __pyx_v_f_low); - if (__pyx_t_7) { + __pyx_v_f_links_high = ((int *)malloc((__pyx_v_f_sent_len * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1572 - * self.findexes.reset() - * if f_back_low < f_low: - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * i = i+1 - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1431 + * f_links_low = malloc(f_sent_len*sizeof(int)) + * f_links_high = malloc(f_sent_len*sizeof(int)) + * f_gap_low = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * f_gap_high = malloc((num_chunks+1)*sizeof(int)) + * e_gap_low = malloc((num_chunks+1)*sizeof(int)) */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + __pyx_v_f_gap_low = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1573 - * if f_back_low < f_low: - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) - * self.findexes.extend(self.findexes1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1432 + * f_links_high = malloc(f_sent_len*sizeof(int)) + * f_gap_low = malloc((num_chunks+1)*sizeof(int)) + * f_gap_high = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * e_gap_low = malloc((num_chunks+1)*sizeof(int)) + * e_gap_high = malloc((num_chunks+1)*sizeof(int)) */ - __pyx_v_i = (__pyx_v_i + 1); + __pyx_v_f_gap_high = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1574 - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1433 + * f_gap_low = malloc((num_chunks+1)*sizeof(int)) + * f_gap_high = malloc((num_chunks+1)*sizeof(int)) + * e_gap_low = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * e_gap_high = malloc((num_chunks+1)*sizeof(int)) + * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) */ - __pyx_t_2 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1574; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L52; - } - __pyx_L52:; + __pyx_v_e_gap_low = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1575 - * i = i+1 - * self.findexes.append(sym_setindex(self.category, i)) - * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1434 + * f_gap_high = malloc((num_chunks+1)*sizeof(int)) + * e_gap_low = malloc((num_chunks+1)*sizeof(int)) + * e_gap_high = malloc((num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) + * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->findexes1)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); - __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_v_e_gap_high = ((int *)malloc(((__pyx_v_num_chunks + 1) * (sizeof(int))))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1576 - * self.findexes.append(sym_setindex(self.category, i)) - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1435 + * e_gap_low = malloc((num_chunks+1)*sizeof(int)) + * e_gap_high = malloc((num_chunks+1)*sizeof(int)) + * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) + * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) */ - __pyx_t_3 = __pyx_v_phrase->n; - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { + memset(__pyx_v_f_gap_low, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1577 - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1436 + * e_gap_high = malloc((num_chunks+1)*sizeof(int)) + * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) + * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) + * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) */ - __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); - if (__pyx_t_4) { + memset(__pyx_v_f_gap_high, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1578 - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * i = i + 1 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1437 + * memset(f_gap_low, 0, (num_chunks+1)*sizeof(int)) + * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) + * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) + * */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + memset(__pyx_v_e_gap_low, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1579 - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i + 1 # <<<<<<<<<<<<<< - * else: - * fphr_arr._append(phrase.syms[j]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1438 + * memset(f_gap_high, 0, (num_chunks+1)*sizeof(int)) + * memset(e_gap_low, 0, (num_chunks+1)*sizeof(int)) + * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) # <<<<<<<<<<<<<< + * + * reason_for_failure = "" */ - __pyx_v_i = (__pyx_v_i + 1); - goto __pyx_L55; - } - /*else*/ { + memset(__pyx_v_e_gap_high, 0, ((__pyx_v_num_chunks + 1) * (sizeof(int)))); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1581 - * i = i + 1 - * else: - * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< - * if f_back_high > f_high: - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1440 + * memset(e_gap_high, 0, (num_chunks+1)*sizeof(int)) + * + * reason_for_failure = "" # <<<<<<<<<<<<<< + * + * for i from 0 <= i < e_sent_len: */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); - } - __pyx_L55:; - } + __Pyx_INCREF(((PyObject *)__pyx_kp_s_45)); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_45); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1582 - * else: - * fphr_arr._append(phrase.syms[j]) - * if f_back_high > f_high: # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1442 + * reason_for_failure = "" + * + * for i from 0 <= i < e_sent_len: # <<<<<<<<<<<<<< + * e_links_low[i] = -1 + * e_links_high[i] = -1 */ - __pyx_t_7 = (__pyx_v_f_back_high > __pyx_v_f_high); - if (__pyx_t_7) { + __pyx_t_3 = __pyx_v_e_sent_len; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1583 - * fphr_arr._append(phrase.syms[j]) - * if f_back_high > f_high: - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1443 * + * for i from 0 <= i < e_sent_len: + * e_links_low[i] = -1 # <<<<<<<<<<<<<< + * e_links_high[i] = -1 + * for i from 0 <= i < f_sent_len: */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + (__pyx_v_e_links_low[__pyx_v_i]) = -1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1584 - * if f_back_high > f_high: - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * - * fphr = Phrase(fphr_arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1444 + * for i from 0 <= i < e_sent_len: + * e_links_low[i] = -1 + * e_links_high[i] = -1 # <<<<<<<<<<<<<< + * for i from 0 <= i < f_sent_len: + * f_links_low[i] = -1 */ - __pyx_t_10 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - goto __pyx_L56; - } - __pyx_L56:; + (__pyx_v_e_links_high[__pyx_v_i]) = -1; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1586 - * self.findexes.append(sym_setindex(self.category, i)) - * - * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< - * if met_constraints: - * phrase_list = self.extract_phrases(e_low, e_high, e_gap_low + gap_start, e_gap_high + gap_start, e_links_low, num_gaps, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1445 + * e_links_low[i] = -1 + * e_links_high[i] = -1 + * for i from 0 <= i < f_sent_len: # <<<<<<<<<<<<<< + * f_links_low[i] = -1 + * f_links_high[i] = -1 */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); - PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_fphr_arr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); - __pyx_t_10 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1586; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_10); - __pyx_t_10 = 0; + __pyx_t_3 = __pyx_v_f_sent_len; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1587 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1446 + * e_links_high[i] = -1 + * for i from 0 <= i < f_sent_len: + * f_links_low[i] = -1 # <<<<<<<<<<<<<< + * f_links_high[i] = -1 * - * fphr = Phrase(fphr_arr) - * if met_constraints: # <<<<<<<<<<<<<< - * phrase_list = self.extract_phrases(e_low, e_high, e_gap_low + gap_start, e_gap_high + gap_start, e_links_low, num_gaps, - * f_back_low, f_back_high, f_gap_low + gap_start, f_gap_high + gap_start, f_links_low, */ - if (__pyx_v_met_constraints) { + (__pyx_v_f_links_low[__pyx_v_i]) = -1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1590 - * phrase_list = self.extract_phrases(e_low, e_high, e_gap_low + gap_start, e_gap_high + gap_start, e_links_low, num_gaps, - * f_back_low, f_back_high, f_gap_low + gap_start, f_gap_high + gap_start, f_links_low, - * matching.sent_id, e_sent_len, e_sent_start) # <<<<<<<<<<<<<< - * if len(phrase_list) > 0: - * pair_count = 1.0 / len(phrase_list) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1447 + * for i from 0 <= i < f_sent_len: + * f_links_low[i] = -1 + * f_links_high[i] = -1 # <<<<<<<<<<<<<< + * + * # this is really inefficient -- might be good to */ - __pyx_t_10 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_low, __pyx_v_e_high, (__pyx_v_e_gap_low + __pyx_v_gap_start), (__pyx_v_e_gap_high + __pyx_v_gap_start), __pyx_v_e_links_low, __pyx_v_num_gaps, __pyx_v_f_back_low, __pyx_v_f_back_high, (__pyx_v_f_gap_low + __pyx_v_gap_start), (__pyx_v_f_gap_high + __pyx_v_gap_start), __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_v_phrase_list = __pyx_t_10; - __pyx_t_10 = 0; + (__pyx_v_f_links_high[__pyx_v_i]) = -1; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1591 - * f_back_low, f_back_high, f_gap_low + gap_start, f_gap_high + gap_start, f_links_low, - * matching.sent_id, e_sent_len, e_sent_start) - * if len(phrase_list) > 0: # <<<<<<<<<<<<<< - * pair_count = 1.0 / len(phrase_list) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1453 + * # links that we care about (but then how to look up + * # when we want to check something on the e side?) + * i = 0 # <<<<<<<<<<<<<< + * while i < num_links*2: + * f_i = sent_links[i] */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = (__pyx_t_13 > 0); - if (__pyx_t_7) { + __pyx_v_i = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1592 - * matching.sent_id, e_sent_len, e_sent_start) - * if len(phrase_list) > 0: - * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< - * else: - * pair_count = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1454 + * # when we want to check something on the e side?) + * i = 0 + * while i < num_links*2: # <<<<<<<<<<<<<< + * f_i = sent_links[i] + * e_i = sent_links[i+1] */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(__pyx_t_13 == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_pair_count = (1.0 / __pyx_t_13); - goto __pyx_L58; - } - /*else*/ { + while (1) { + __pyx_t_7 = (__pyx_v_i < (__pyx_v_num_links * 2)); + if (!__pyx_t_7) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1594 - * pair_count = 1.0 / len(phrase_list) - * else: - * pair_count = 0 # <<<<<<<<<<<<<< - * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) - * for (phrase2,eindexes) in phrase_list: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1455 + * i = 0 + * while i < num_links*2: + * f_i = sent_links[i] # <<<<<<<<<<<<<< + * e_i = sent_links[i+1] + * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: */ - __pyx_v_pair_count = 0.0; + __pyx_v_f_i = (__pyx_v_sent_links[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1595 - * else: - * pair_count = 0 - * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) # <<<<<<<<<<<<<< - * for (phrase2,eindexes) in phrase_list: - * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1456 + * while i < num_links*2: + * f_i = sent_links[i] + * e_i = sent_links[i+1] # <<<<<<<<<<<<<< + * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: + * f_links_low[f_i] = e_i */ - __pyx_t_10 = PyInt_FromLong(__pyx_v_f_back_low); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __pyx_t_2 = PyInt_FromLong(__pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyInt_FromLong(__pyx_v_e_low); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_14 = PyInt_FromLong(__pyx_v_e_high); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10); - __Pyx_GIVEREF(__pyx_t_10); - PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_t_10 = 0; - __pyx_t_2 = 0; - __pyx_t_1 = 0; - __pyx_t_14 = 0; - __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_132), ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_14)); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_t_14); - __pyx_t_14 = 0; - } - __pyx_L58:; + __pyx_v_e_i = (__pyx_v_sent_links[(__pyx_v_i + 1)]); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1596 - * pair_count = 0 - * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) - * for (phrase2,eindexes) in phrase_list: # <<<<<<<<<<<<<< - * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als1))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1457 + * f_i = sent_links[i] + * e_i = sent_links[i+1] + * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: # <<<<<<<<<<<<<< + * f_links_low[f_i] = e_i + * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: */ - if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { - __pyx_t_14 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_14); __pyx_t_13 = 0; - __pyx_t_16 = NULL; - } else { - __pyx_t_13 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_16 = Py_TYPE(__pyx_t_14)->tp_iternext; - } - for (;;) { - if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_14)) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_14)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_15 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; - #else - __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_14)) { - if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_14)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; - #else - __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_15 = __pyx_t_16(__pyx_t_14); - if (unlikely(!__pyx_t_15)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_15); - } - if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) { - PyObject* sequence = __pyx_t_15; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_1 = PyList_GET_ITEM(sequence, 0); - __pyx_t_2 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_1); - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - } else - { - Py_ssize_t index = -1; - __pyx_t_10 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; - index = 0; __pyx_t_1 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L61_unpacking_failed; - __Pyx_GOTREF(__pyx_t_1); - index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L61_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_17 = NULL; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - goto __pyx_L62_unpacking_done; - __pyx_L61_unpacking_failed:; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_17 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1596; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L62_unpacking_done:; - } - __Pyx_XDECREF(__pyx_v_phrase2); - __pyx_v_phrase2 = __pyx_t_1; - __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_v_eindexes); - __pyx_v_eindexes = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_7 = ((__pyx_v_f_links_low[__pyx_v_f_i]) == -1); + if (!__pyx_t_7) { + __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_i]) > __pyx_v_e_i); + __pyx_t_9 = __pyx_t_8; + } else { + __pyx_t_9 = __pyx_t_7; + } + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1597 - * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) - * for (phrase2,eindexes) in phrase_list: - * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< - * extracts.append((fphr, phrase2, pair_count, tuple(als1))) - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1458 + * e_i = sent_links[i+1] + * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: + * f_links_low[f_i] = e_i # <<<<<<<<<<<<<< + * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: + * f_links_high[f_i] = e_i + 1 */ - __pyx_t_15 = ((PyObject *)__pyx_v_self->findexes); - __Pyx_INCREF(__pyx_t_15); - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_15, __pyx_v_eindexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1597; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_XDECREF(__pyx_v_als1); - __pyx_v_als1 = __pyx_t_2; - __pyx_t_2 = 0; + (__pyx_v_f_links_low[__pyx_v_f_i]) = __pyx_v_e_i; + goto __pyx_L14; + } + __pyx_L14:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1598 - * for (phrase2,eindexes) in phrase_list: - * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als1))) # <<<<<<<<<<<<<< - * - * if (num_gaps < self.max_nonterminals and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1459 + * if f_links_low[f_i] == -1 or f_links_low[f_i] > e_i: + * f_links_low[f_i] = e_i + * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: # <<<<<<<<<<<<<< + * f_links_high[f_i] = e_i + 1 + * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_INCREF(__pyx_v_als1); - PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_als1); - __Pyx_GIVEREF(__pyx_v_als1); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); - PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_fphr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); - __Pyx_INCREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_phrase2); - __Pyx_GIVEREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_2 = 0; - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - goto __pyx_L57; - } - __pyx_L57:; + __pyx_t_9 = ((__pyx_v_f_links_high[__pyx_v_f_i]) == -1); + if (!__pyx_t_9) { + __pyx_t_7 = ((__pyx_v_f_links_high[__pyx_v_f_i]) < (__pyx_v_e_i + 1)); + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_9; + } + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1600 - * extracts.append((fphr, phrase2, pair_count, tuple(als1))) - * - * if (num_gaps < self.max_nonterminals and # <<<<<<<<<<<<<< - * phrase_len < self.max_length and - * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1460 + * f_links_low[f_i] = e_i + * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: + * f_links_high[f_i] = e_i + 1 # <<<<<<<<<<<<<< + * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: + * e_links_low[e_i] = f_i */ - __pyx_t_7 = (__pyx_v_num_gaps < __pyx_v_self->max_nonterminals); - if (__pyx_t_7) { + (__pyx_v_f_links_high[__pyx_v_f_i]) = (__pyx_v_e_i + 1); + goto __pyx_L15; + } + __pyx_L15:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1601 - * - * if (num_gaps < self.max_nonterminals and - * phrase_len < self.max_length and # <<<<<<<<<<<<<< - * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): - * if (f_back_low == f_low and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1461 + * if f_links_high[f_i] == -1 or f_links_high[f_i] < e_i + 1: + * f_links_high[f_i] = e_i + 1 + * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: # <<<<<<<<<<<<<< + * e_links_low[e_i] = f_i + * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: */ - __pyx_t_9 = (__pyx_v_phrase_len < __pyx_v_self->max_length); - if (__pyx_t_9) { + __pyx_t_8 = ((__pyx_v_e_links_low[__pyx_v_e_i]) == -1); + if (!__pyx_t_8) { + __pyx_t_9 = ((__pyx_v_e_links_low[__pyx_v_e_i]) > __pyx_v_f_i); + __pyx_t_7 = __pyx_t_9; + } else { + __pyx_t_7 = __pyx_t_8; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1602 - * if (num_gaps < self.max_nonterminals and - * phrase_len < self.max_length and - * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): # <<<<<<<<<<<<<< - * if (f_back_low == f_low and - * f_low >= self.train_min_gap_size and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1462 + * f_links_high[f_i] = e_i + 1 + * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: + * e_links_low[e_i] = f_i # <<<<<<<<<<<<<< + * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: + * e_links_high[e_i] = f_i + 1 */ - __pyx_t_8 = (((__pyx_v_f_back_high - __pyx_v_f_back_low) + __pyx_v_self->train_min_gap_size) <= __pyx_v_self->train_max_initial_size); - __pyx_t_18 = __pyx_t_8; - } else { - __pyx_t_18 = __pyx_t_9; - } - __pyx_t_9 = __pyx_t_18; - } else { - __pyx_t_9 = __pyx_t_7; - } - if (__pyx_t_9) { + (__pyx_v_e_links_low[__pyx_v_e_i]) = __pyx_v_f_i; + goto __pyx_L16; + } + __pyx_L16:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1603 - * phrase_len < self.max_length and - * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): - * if (f_back_low == f_low and # <<<<<<<<<<<<<< - * f_low >= self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1463 + * if e_links_low[e_i] == -1 or e_links_low[e_i] > f_i: + * e_links_low[e_i] = f_i + * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: # <<<<<<<<<<<<<< + * e_links_high[e_i] = f_i + 1 + * i = i + 2 */ - __pyx_t_9 = (__pyx_v_f_back_low == __pyx_v_f_low); - if (__pyx_t_9) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1604 - * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): - * if (f_back_low == f_low and - * f_low >= self.train_min_gap_size and # <<<<<<<<<<<<<< - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): - * f_x_low = f_low-self.train_min_gap_size - */ - __pyx_t_7 = (__pyx_v_f_low >= __pyx_v_self->train_min_gap_size); - if (__pyx_t_7) { + __pyx_t_7 = ((__pyx_v_e_links_high[__pyx_v_e_i]) == -1); + if (!__pyx_t_7) { + __pyx_t_8 = ((__pyx_v_e_links_high[__pyx_v_e_i]) < (__pyx_v_f_i + 1)); + __pyx_t_9 = __pyx_t_8; + } else { + __pyx_t_9 = __pyx_t_7; + } + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1605 - * if (f_back_low == f_low and - * f_low >= self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): # <<<<<<<<<<<<<< - * f_x_low = f_low-self.train_min_gap_size - * met_constraints = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1464 + * e_links_low[e_i] = f_i + * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: + * e_links_high[e_i] = f_i + 1 # <<<<<<<<<<<<<< + * i = i + 2 + * */ - __pyx_t_18 = (!__pyx_v_self->tight_phrases); - if (!__pyx_t_18) { - __pyx_t_8 = ((__pyx_v_f_links_low[(__pyx_v_f_low - 1)]) != -1); - if (__pyx_t_8) { - __pyx_t_19 = ((__pyx_v_f_links_low[(__pyx_v_f_back_high - 1)]) != -1); - __pyx_t_20 = __pyx_t_19; - } else { - __pyx_t_20 = __pyx_t_8; - } - __pyx_t_8 = __pyx_t_20; - } else { - __pyx_t_8 = __pyx_t_18; - } - __pyx_t_18 = __pyx_t_8; - } else { - __pyx_t_18 = __pyx_t_7; - } - __pyx_t_7 = __pyx_t_18; - } else { - __pyx_t_7 = __pyx_t_9; - } - if (__pyx_t_7) { + (__pyx_v_e_links_high[__pyx_v_e_i]) = (__pyx_v_f_i + 1); + goto __pyx_L17; + } + __pyx_L17:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1606 - * f_low >= self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): - * f_x_low = f_low-self.train_min_gap_size # <<<<<<<<<<<<<< - * met_constraints = 1 - * if self.tight_phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1465 + * if e_links_high[e_i] == -1 or e_links_high[e_i] < f_i + 1: + * e_links_high[e_i] = f_i + 1 + * i = i + 2 # <<<<<<<<<<<<<< + * + * als = [] */ - __pyx_v_f_x_low = (__pyx_v_f_low - __pyx_v_self->train_min_gap_size); + __pyx_v_i = (__pyx_v_i + 2); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1607 - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): - * f_x_low = f_low-self.train_min_gap_size - * met_constraints = 1 # <<<<<<<<<<<<<< - * if self.tight_phrases: - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1467 + * i = i + 2 + * + * als = [] # <<<<<<<<<<<<<< + * for x in range(matching.start,matching.end): + * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) */ - __pyx_v_met_constraints = 1; + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_v_als = __pyx_t_2; + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1608 - * f_x_low = f_low-self.train_min_gap_size - * met_constraints = 1 - * if self.tight_phrases: # <<<<<<<<<<<<<< - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: - * f_x_low = f_x_low - 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1468 + * + * als = [] + * for x in range(matching.start,matching.end): # <<<<<<<<<<<<<< + * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) + * als.append(al) */ - if (__pyx_v_self->tight_phrases) { + __pyx_t_3 = __pyx_v_matching->end; + for (__pyx_t_4 = __pyx_v_matching->start; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { + __pyx_v_x = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1609 - * met_constraints = 1 - * if self.tight_phrases: - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: # <<<<<<<<<<<<<< - * f_x_low = f_x_low - 1 - * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1469 + * als = [] + * for x in range(matching.start,matching.end): + * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) # <<<<<<<<<<<<<< + * als.append(al) + * # check all source-side alignment constraints */ - while (1) { - __pyx_t_7 = (__pyx_v_f_x_low >= 0); - if (__pyx_t_7) { - __pyx_t_9 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) == -1); - __pyx_t_18 = __pyx_t_9; - } else { - __pyx_t_18 = __pyx_t_7; - } - if (!__pyx_t_18) break; + __pyx_t_2 = PyInt_FromLong(((__pyx_v_matching->arr[__pyx_v_x]) - __pyx_v_f_sent_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyInt_FromLong((__pyx_v_f_links_low[((__pyx_v_matching->arr[__pyx_v_x]) - __pyx_v_f_sent_start)])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_al)); + __pyx_v_al = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1610 - * if self.tight_phrases: - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: - * f_x_low = f_x_low - 1 # <<<<<<<<<<<<<< - * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1470 + * for x in range(matching.start,matching.end): + * al = (matching.arr[x]-f_sent_start,f_links_low[matching.arr[x]-f_sent_start]) + * als.append(al) # <<<<<<<<<<<<<< + * # check all source-side alignment constraints + * met_constraints = 1 */ - __pyx_v_f_x_low = (__pyx_v_f_x_low - 1); - } - goto __pyx_L65; - } - __pyx_L65:; + __pyx_t_11 = PyList_Append(__pyx_v_als, ((PyObject *)__pyx_v_al)); if (unlikely(__pyx_t_11 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1470; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1611 - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: - * f_x_low = f_x_low - 1 - * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: # <<<<<<<<<<<<<< - * met_constraints = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1472 + * als.append(al) + * # check all source-side alignment constraints + * met_constraints = 1 # <<<<<<<<<<<<<< + * if self.require_aligned_terminal: + * num_aligned_chunks = 0 */ - __pyx_t_18 = (__pyx_v_f_x_low < 0); - if (!__pyx_t_18) { - __pyx_t_7 = ((__pyx_v_f_back_high - __pyx_v_f_x_low) > __pyx_v_self->train_max_initial_size); - __pyx_t_9 = __pyx_t_7; - } else { - __pyx_t_9 = __pyx_t_18; - } - if (__pyx_t_9) { + __pyx_v_met_constraints = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1612 - * f_x_low = f_x_low - 1 - * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: - * met_constraints = 0 # <<<<<<<<<<<<<< - * - * if (met_constraints and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1473 + * # check all source-side alignment constraints + * met_constraints = 1 + * if self.require_aligned_terminal: # <<<<<<<<<<<<<< + * num_aligned_chunks = 0 + * for i from 0 <= i < num_chunks: */ - __pyx_v_met_constraints = 0; - goto __pyx_L68; - } - __pyx_L68:; + if (__pyx_v_self->require_aligned_terminal) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1614 - * met_constraints = 0 - * - * if (met_constraints and # <<<<<<<<<<<<<< - * self.find_fixpoint(f_x_low, f_back_high, - * f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1474 + * met_constraints = 1 + * if self.require_aligned_terminal: + * num_aligned_chunks = 0 # <<<<<<<<<<<<<< + * for i from 0 <= i < num_chunks: + * for j from 0 <= j < chunklen[i]: */ - if (__pyx_v_met_constraints) { + __pyx_v_num_aligned_chunks = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1615 - * - * if (met_constraints and - * self.find_fixpoint(f_x_low, f_back_high, # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1475 + * if self.require_aligned_terminal: + * num_aligned_chunks = 0 + * for i from 0 <= i < num_chunks: # <<<<<<<<<<<<<< + * for j from 0 <= j < chunklen[i]: + * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: */ - __pyx_t_14 = PyInt_FromLong(__pyx_v_f_back_high); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1615; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); + __pyx_t_3 = __pyx_v_num_chunks; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1619 - * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 1, 1, 1, 1, 0, 1, 0) and - * ((not self.tight_phrases) or f_links_low[f_x_low] != -1) and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1476 + * num_aligned_chunks = 0 + * for i from 0 <= i < num_chunks: + * for j from 0 <= j < chunklen[i]: # <<<<<<<<<<<<<< + * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: + * num_aligned_chunks = num_aligned_chunks + 1 */ - if (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_14, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 1, 0, 1, 0)) { - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_4 = (__pyx_v_chunklen[__pyx_v_i]); + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_4; __pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1621 - * self.train_max_initial_size, self.train_max_initial_size, - * 1, 1, 1, 1, 0, 1, 0) and - * ((not self.tight_phrases) or f_links_low[f_x_low] != -1) and # <<<<<<<<<<<<<< - * self.find_fixpoint(f_x_low, f_low, # check integrity of new subphrase - * f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1477 + * for i from 0 <= i < num_chunks: + * for j from 0 <= j < chunklen[i]: + * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: # <<<<<<<<<<<<<< + * num_aligned_chunks = num_aligned_chunks + 1 + * break */ - __pyx_t_9 = (!__pyx_v_self->tight_phrases); - if (!__pyx_t_9) { - __pyx_t_18 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) != -1); - __pyx_t_7 = __pyx_t_18; - } else { - __pyx_t_7 = __pyx_t_9; - } - if (__pyx_t_7) { + __pyx_t_9 = ((__pyx_v_f_links_low[(((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + __pyx_v_j) - __pyx_v_f_sent_start)]) > -1); + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1622 - * 1, 1, 1, 1, 0, 1, 0) and - * ((not self.tight_phrases) or f_links_low[f_x_low] != -1) and - * self.find_fixpoint(f_x_low, f_low, # check integrity of new subphrase # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1478 + * for j from 0 <= j < chunklen[i]: + * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: + * num_aligned_chunks = num_aligned_chunks + 1 # <<<<<<<<<<<<<< + * break + * if num_aligned_chunks == 0: */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_f_low); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_v_num_aligned_chunks = (__pyx_v_num_aligned_chunks + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1626 - * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1479 + * if f_links_low[matching.arr[matching.start+i]+j-f_sent_start] > -1: + * num_aligned_chunks = num_aligned_chunks + 1 + * break # <<<<<<<<<<<<<< + * if num_aligned_chunks == 0: + * reason_for_failure = "No aligned terminals" */ - __pyx_t_9 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else { - __pyx_t_9 = __pyx_t_7; - } - __pyx_t_7 = __pyx_t_9; - } else { - __pyx_t_7 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_14, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 1, 0, 1, 0); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - } - __pyx_t_9 = __pyx_t_7; - } else { - __pyx_t_9 = __pyx_v_met_constraints; - } - if (__pyx_t_9) { + goto __pyx_L24_break; + goto __pyx_L25; + } + __pyx_L25:; + } + __pyx_L24_break:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1628 - * self.train_max_initial_size, self.train_max_initial_size, - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() # <<<<<<<<<<<<<< - * i = 1 - * self.findexes.reset() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1480 + * num_aligned_chunks = num_aligned_chunks + 1 + * break + * if num_aligned_chunks == 0: # <<<<<<<<<<<<<< + * reason_for_failure = "No aligned terminals" + * met_constraints = 0 */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_clear(__pyx_v_fphr_arr); + __pyx_t_9 = (__pyx_v_num_aligned_chunks == 0); + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1629 - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() - * i = 1 # <<<<<<<<<<<<<< - * self.findexes.reset() - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1481 + * break + * if num_aligned_chunks == 0: + * reason_for_failure = "No aligned terminals" # <<<<<<<<<<<<<< + * met_constraints = 0 + * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: */ - __pyx_v_i = 1; + __Pyx_INCREF(((PyObject *)__pyx_kp_s_128)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_128); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1630 - * fphr_arr._clear() - * i = 1 - * self.findexes.reset() # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1482 + * if num_aligned_chunks == 0: + * reason_for_failure = "No aligned terminals" + * met_constraints = 0 # <<<<<<<<<<<<<< + * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: + * reason_for_failure = "Unaligned chunk" */ - __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_1 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_met_constraints = 0; + goto __pyx_L26; + } + __pyx_L26:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1631 - * i = 1 - * self.findexes.reset() - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1483 + * reason_for_failure = "No aligned terminals" + * met_constraints = 0 + * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: # <<<<<<<<<<<<<< + * reason_for_failure = "Unaligned chunk" + * met_constraints = 0 */ - __pyx_t_1 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_14 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1631; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + if (__pyx_v_self->require_aligned_chunks) { + __pyx_t_9 = (__pyx_v_num_aligned_chunks < __pyx_v_num_chunks); + __pyx_t_7 = __pyx_t_9; + } else { + __pyx_t_7 = __pyx_v_self->require_aligned_chunks; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1632 - * self.findexes.reset() - * self.findexes.append(sym_setindex(self.category, i)) - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * i = i+1 - * self.findexes.extend(self.findexes1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1484 + * met_constraints = 0 + * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: + * reason_for_failure = "Unaligned chunk" # <<<<<<<<<<<<<< + * met_constraints = 0 + * */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_129)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_129); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1633 - * self.findexes.append(sym_setindex(self.category, i)) - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 # <<<<<<<<<<<<<< - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1485 + * if self.require_aligned_chunks and num_aligned_chunks < num_chunks: + * reason_for_failure = "Unaligned chunk" + * met_constraints = 0 # <<<<<<<<<<<<<< + * + * if met_constraints and self.tight_phrases: */ - __pyx_v_i = (__pyx_v_i + 1); + __pyx_v_met_constraints = 0; + goto __pyx_L27; + } + __pyx_L27:; + goto __pyx_L20; + } + __pyx_L20:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1634 - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 - * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1487 + * met_constraints = 0 + * + * if met_constraints and self.tight_phrases: # <<<<<<<<<<<<<< + * # outside edge constraints are checked later + * for i from 0 <= i < num_chunks-1: */ - __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->findexes1)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); - __pyx_t_15 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1634; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_v_met_constraints) { + __pyx_t_7 = __pyx_v_self->tight_phrases; + } else { + __pyx_t_7 = __pyx_v_met_constraints; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1635 - * i = i+1 - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1489 + * if met_constraints and self.tight_phrases: + * # outside edge constraints are checked later + * for i from 0 <= i < num_chunks-1: # <<<<<<<<<<<<<< + * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: + * reason_for_failure = "Gaps are not tight phrases" */ - __pyx_t_3 = __pyx_v_phrase->n; - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { + __pyx_t_12 = (__pyx_v_num_chunks - 1); + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1636 - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1490 + * # outside edge constraints are checked later + * for i from 0 <= i < num_chunks-1: + * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: # <<<<<<<<<<<<<< + * reason_for_failure = "Gaps are not tight phrases" + * met_constraints = 0 */ - __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); - if (__pyx_t_4) { + __pyx_t_7 = ((__pyx_v_f_links_low[(((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + (__pyx_v_chunklen[__pyx_v_i])) - __pyx_v_f_sent_start)]) == -1); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1637 - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * i = i + 1 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1491 + * for i from 0 <= i < num_chunks-1: + * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: + * reason_for_failure = "Gaps are not tight phrases" # <<<<<<<<<<<<<< + * met_constraints = 0 + * break */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_130)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_130); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1638 - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i + 1 # <<<<<<<<<<<<<< - * else: - * fphr_arr._append(phrase.syms[j]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1492 + * if f_links_low[matching.arr[matching.start+i]+chunklen[i]-f_sent_start] == -1: + * reason_for_failure = "Gaps are not tight phrases" + * met_constraints = 0 # <<<<<<<<<<<<<< + * break + * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: */ - __pyx_v_i = (__pyx_v_i + 1); - goto __pyx_L72; - } - /*else*/ { + __pyx_v_met_constraints = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1640 - * i = i + 1 - * else: - * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< - * if f_back_high > f_high: - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1493 + * reason_for_failure = "Gaps are not tight phrases" + * met_constraints = 0 + * break # <<<<<<<<<<<<<< + * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: + * reason_for_failure = "Gaps are not tight phrases" */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); - } - __pyx_L72:; - } + goto __pyx_L30_break; + goto __pyx_L31; + } + __pyx_L31:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1641 - * else: - * fphr_arr._append(phrase.syms[j]) - * if f_back_high > f_high: # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1494 + * met_constraints = 0 + * break + * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: # <<<<<<<<<<<<<< + * reason_for_failure = "Gaps are not tight phrases" + * met_constraints = 0 */ - __pyx_t_9 = (__pyx_v_f_back_high > __pyx_v_f_high); - if (__pyx_t_9) { + __pyx_t_7 = ((__pyx_v_f_links_low[(((__pyx_v_matching->arr[((__pyx_v_matching->start + __pyx_v_i) + 1)]) - 1) - __pyx_v_f_sent_start)]) == -1); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1642 - * fphr_arr._append(phrase.syms[j]) - * if f_back_high > f_high: - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) - * fphr = Phrase(fphr_arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1495 + * break + * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: + * reason_for_failure = "Gaps are not tight phrases" # <<<<<<<<<<<<<< + * met_constraints = 0 + * break */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_130)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_130); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1643 - * if f_back_high > f_high: - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * fphr = Phrase(fphr_arr) - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+1, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1496 + * if f_links_low[matching.arr[matching.start+i+1]-1-f_sent_start] == -1: + * reason_for_failure = "Gaps are not tight phrases" + * met_constraints = 0 # <<<<<<<<<<<<<< + * break + * */ - __pyx_t_15 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1643; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1643; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L73; - } - __pyx_L73:; + __pyx_v_met_constraints = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1644 - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) - * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+1, - * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, matching.sent_id, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1497 + * reason_for_failure = "Gaps are not tight phrases" + * met_constraints = 0 + * break # <<<<<<<<<<<<<< + * + * f_low = matching.arr[matching.start] - f_sent_start */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_fphr_arr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); - __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_fphr)); - __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_15); - __pyx_t_15 = 0; + goto __pyx_L30_break; + goto __pyx_L32; + } + __pyx_L32:; + } + __pyx_L30_break:; + goto __pyx_L28; + } + __pyx_L28:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1647 - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+1, - * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, matching.sent_id, - * e_sent_len, e_sent_start) # <<<<<<<<<<<<<< - * if len(phrase_list) > 0: - * pair_count = 1.0 / len(phrase_list) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1499 + * break + * + * f_low = matching.arr[matching.start] - f_sent_start # <<<<<<<<<<<<<< + * f_high = matching.arr[matching.start + matching.size - 1] + chunklen[num_chunks-1] - f_sent_start + * if met_constraints: */ - __pyx_t_15 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_x_low, __pyx_v_e_x_high, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_e_links_low, (__pyx_v_num_gaps + 1), __pyx_v_f_x_low, __pyx_v_f_x_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_XDECREF(__pyx_v_phrase_list); - __pyx_v_phrase_list = __pyx_t_15; - __pyx_t_15 = 0; + __pyx_v_f_low = ((__pyx_v_matching->arr[__pyx_v_matching->start]) - __pyx_v_f_sent_start); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1648 - * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, matching.sent_id, - * e_sent_len, e_sent_start) - * if len(phrase_list) > 0: # <<<<<<<<<<<<<< - * pair_count = 1.0 / len(phrase_list) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1500 + * + * f_low = matching.arr[matching.start] - f_sent_start + * f_high = matching.arr[matching.start + matching.size - 1] + chunklen[num_chunks-1] - f_sent_start # <<<<<<<<<<<<<< + * if met_constraints: + * */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = (__pyx_t_13 > 0); - if (__pyx_t_9) { + __pyx_v_f_high = (((__pyx_v_matching->arr[((__pyx_v_matching->start + __pyx_v_matching->size) - 1)]) + (__pyx_v_chunklen[(__pyx_v_num_chunks - 1)])) - __pyx_v_f_sent_start); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1649 - * e_sent_len, e_sent_start) - * if len(phrase_list) > 0: - * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< - * else: - * pair_count = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1501 + * f_low = matching.arr[matching.start] - f_sent_start + * f_high = matching.arr[matching.start + matching.size - 1] + chunklen[num_chunks-1] - f_sent_start + * if met_constraints: # <<<<<<<<<<<<<< + * + * if self.find_fixpoint(f_low, f_high, f_links_low, f_links_high, e_links_low, e_links_high, */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(__pyx_t_13 == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_pair_count = (1.0 / __pyx_t_13); - goto __pyx_L74; - } - /*else*/ { + if (__pyx_v_met_constraints) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1651 - * pair_count = 1.0 / len(phrase_list) - * else: - * pair_count = 0 # <<<<<<<<<<<<<< - * for phrase2,eindexes in phrase_list: - * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1503 + * if met_constraints: + * + * if self.find_fixpoint(f_low, f_high, f_links_low, f_links_high, e_links_low, e_links_high, # <<<<<<<<<<<<<< + * -1, -1, &e_low, &e_high, &f_back_low, &f_back_high, f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, */ - __pyx_v_pair_count = 0.0; - } - __pyx_L74:; + __pyx_t_10 = PyInt_FromLong(__pyx_v_f_high); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1503; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1652 - * else: - * pair_count = 0 - * for phrase2,eindexes in phrase_list: # <<<<<<<<<<<<<< - * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als2))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1507 + * self.train_max_initial_size, self.train_max_initial_size, + * self.train_min_gap_size, 0, + * self.max_nonterminals - num_chunks + 1, 1, 1, 0, 0): # <<<<<<<<<<<<<< + * gap_error = 0 + * num_gaps = 0 */ - if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { - __pyx_t_15 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_15); __pyx_t_13 = 0; - __pyx_t_16 = NULL; - } else { - __pyx_t_13 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext; - } - for (;;) { - if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_15)) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_15)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_13); __Pyx_INCREF(__pyx_t_1); __pyx_t_13++; - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_15, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_15)) { - if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_15)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_13); __Pyx_INCREF(__pyx_t_1); __pyx_t_13++; - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_15, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_1 = __pyx_t_16(__pyx_t_15); - if (unlikely(!__pyx_t_1)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { - PyObject* sequence = __pyx_t_1; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_14 = PyList_GET_ITEM(sequence, 0); - __pyx_t_2 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_14); - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_14 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - { - Py_ssize_t index = -1; - __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; - index = 0; __pyx_t_14 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_14)) goto __pyx_L77_unpacking_failed; - __Pyx_GOTREF(__pyx_t_14); - index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L77_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_17 = NULL; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - goto __pyx_L78_unpacking_done; - __pyx_L77_unpacking_failed:; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_17 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L78_unpacking_done:; - } - __Pyx_XDECREF(__pyx_v_phrase2); - __pyx_v_phrase2 = __pyx_t_14; - __pyx_t_14 = 0; - __Pyx_XDECREF(__pyx_v_eindexes); - __pyx_v_eindexes = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_low, __pyx_t_10, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, (&__pyx_v_e_low), (&__pyx_v_e_high), (&__pyx_v_f_back_low), (&__pyx_v_f_back_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_min_gap_size, 0, ((__pyx_v_self->max_nonterminals - __pyx_v_num_chunks) + 1), 1, 1, 0, 0); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1653 - * pair_count = 0 - * for phrase2,eindexes in phrase_list: - * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< - * extracts.append((fphr, phrase2, pair_count, tuple(als2))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1508 + * self.train_min_gap_size, 0, + * self.max_nonterminals - num_chunks + 1, 1, 1, 0, 0): + * gap_error = 0 # <<<<<<<<<<<<<< + * num_gaps = 0 * */ - __pyx_t_1 = ((PyObject *)__pyx_v_self->findexes); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_1, __pyx_v_eindexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1653; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_XDECREF(__pyx_v_als2); - __pyx_v_als2 = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_gap_error = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1654 - * for phrase2,eindexes in phrase_list: - * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als2))) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1509 + * self.max_nonterminals - num_chunks + 1, 1, 1, 0, 0): + * gap_error = 0 + * num_gaps = 0 # <<<<<<<<<<<<<< * - * if (f_back_high == f_high and + * if f_back_low < f_low: */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_als2); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_als2); - __Pyx_GIVEREF(__pyx_v_als2); - __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_fphr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); - __Pyx_INCREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_phrase2); - __Pyx_GIVEREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_14); - __Pyx_GIVEREF(__pyx_t_14); - __pyx_t_2 = 0; - __pyx_t_14 = 0; - __pyx_t_14 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - } - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - goto __pyx_L69; - } - __pyx_L69:; - goto __pyx_L64; - } - __pyx_L64:; + __pyx_v_num_gaps = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1656 - * extracts.append((fphr, phrase2, pair_count, tuple(als2))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1511 + * num_gaps = 0 * - * if (f_back_high == f_high and # <<<<<<<<<<<<<< - * f_sent_len - f_high >= self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): + * if f_back_low < f_low: # <<<<<<<<<<<<<< + * f_gap_low[0] = f_back_low + * f_gap_high[0] = f_low */ - __pyx_t_9 = (__pyx_v_f_back_high == __pyx_v_f_high); - if (__pyx_t_9) { + __pyx_t_7 = (__pyx_v_f_back_low < __pyx_v_f_low); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1657 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1512 * - * if (f_back_high == f_high and - * f_sent_len - f_high >= self.train_min_gap_size and # <<<<<<<<<<<<<< - * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): - * f_x_high = f_high+self.train_min_gap_size + * if f_back_low < f_low: + * f_gap_low[0] = f_back_low # <<<<<<<<<<<<<< + * f_gap_high[0] = f_low + * num_gaps = 1 */ - __pyx_t_7 = ((__pyx_v_f_sent_len - __pyx_v_f_high) >= __pyx_v_self->train_min_gap_size); - if (__pyx_t_7) { + (__pyx_v_f_gap_low[0]) = __pyx_v_f_back_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1658 - * if (f_back_high == f_high and - * f_sent_len - f_high >= self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): # <<<<<<<<<<<<<< - * f_x_high = f_high+self.train_min_gap_size - * met_constraints = 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1513 + * if f_back_low < f_low: + * f_gap_low[0] = f_back_low + * f_gap_high[0] = f_low # <<<<<<<<<<<<<< + * num_gaps = 1 + * gap_start = 0 */ - __pyx_t_18 = (!__pyx_v_self->tight_phrases); - if (!__pyx_t_18) { - __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_high]) != -1); - if (__pyx_t_8) { - __pyx_t_20 = ((__pyx_v_f_links_low[__pyx_v_f_back_low]) != -1); - __pyx_t_19 = __pyx_t_20; - } else { - __pyx_t_19 = __pyx_t_8; - } - __pyx_t_8 = __pyx_t_19; - } else { - __pyx_t_8 = __pyx_t_18; - } - __pyx_t_18 = __pyx_t_8; - } else { - __pyx_t_18 = __pyx_t_7; - } - __pyx_t_7 = __pyx_t_18; - } else { - __pyx_t_7 = __pyx_t_9; - } - if (__pyx_t_7) { + (__pyx_v_f_gap_high[0]) = __pyx_v_f_low; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1659 - * f_sent_len - f_high >= self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): - * f_x_high = f_high+self.train_min_gap_size # <<<<<<<<<<<<<< - * met_constraints = 1 - * if self.tight_phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1514 + * f_gap_low[0] = f_back_low + * f_gap_high[0] = f_low + * num_gaps = 1 # <<<<<<<<<<<<<< + * gap_start = 0 + * phrase_len = phrase_len+1 */ - __pyx_v_f_x_high = (__pyx_v_f_high + __pyx_v_self->train_min_gap_size); + __pyx_v_num_gaps = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1660 - * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): - * f_x_high = f_high+self.train_min_gap_size - * met_constraints = 1 # <<<<<<<<<<<<<< - * if self.tight_phrases: - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1515 + * f_gap_high[0] = f_low + * num_gaps = 1 + * gap_start = 0 # <<<<<<<<<<<<<< + * phrase_len = phrase_len+1 + * if phrase_len > self.max_length: */ - __pyx_v_met_constraints = 1; + __pyx_v_gap_start = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1661 - * f_x_high = f_high+self.train_min_gap_size - * met_constraints = 1 - * if self.tight_phrases: # <<<<<<<<<<<<<< - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: - * f_x_high = f_x_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1516 + * num_gaps = 1 + * gap_start = 0 + * phrase_len = phrase_len+1 # <<<<<<<<<<<<<< + * if phrase_len > self.max_length: + * gap_error = 1 */ - if (__pyx_v_self->tight_phrases) { + __pyx_v_phrase_len = (__pyx_v_phrase_len + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1662 - * met_constraints = 1 - * if self.tight_phrases: - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: # <<<<<<<<<<<<<< - * f_x_high = f_x_high + 1 - * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1517 + * gap_start = 0 + * phrase_len = phrase_len+1 + * if phrase_len > self.max_length: # <<<<<<<<<<<<<< + * gap_error = 1 + * if self.tight_phrases: */ - while (1) { - __pyx_t_7 = (__pyx_v_f_x_high <= __pyx_v_f_sent_len); - if (__pyx_t_7) { - __pyx_t_9 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) == -1); - __pyx_t_18 = __pyx_t_9; - } else { - __pyx_t_18 = __pyx_t_7; - } - if (!__pyx_t_18) break; + __pyx_t_7 = (__pyx_v_phrase_len > __pyx_v_self->max_length); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1663 - * if self.tight_phrases: - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: - * f_x_high = f_x_high + 1 # <<<<<<<<<<<<<< - * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1518 + * phrase_len = phrase_len+1 + * if phrase_len > self.max_length: + * gap_error = 1 # <<<<<<<<<<<<<< + * if self.tight_phrases: + * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: */ - __pyx_v_f_x_high = (__pyx_v_f_x_high + 1); - } - goto __pyx_L80; - } - __pyx_L80:; + __pyx_v_gap_error = 1; + goto __pyx_L36; + } + __pyx_L36:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1664 - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: - * f_x_high = f_x_high + 1 - * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: # <<<<<<<<<<<<<< - * met_constraints = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1519 + * if phrase_len > self.max_length: + * gap_error = 1 + * if self.tight_phrases: # <<<<<<<<<<<<<< + * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: + * gap_error = 1 */ - __pyx_t_18 = (__pyx_v_f_x_high > __pyx_v_f_sent_len); - if (!__pyx_t_18) { - __pyx_t_7 = ((__pyx_v_f_x_high - __pyx_v_f_back_low) > __pyx_v_self->train_max_initial_size); - __pyx_t_9 = __pyx_t_7; - } else { - __pyx_t_9 = __pyx_t_18; - } - if (__pyx_t_9) { + if (__pyx_v_self->tight_phrases) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1665 - * f_x_high = f_x_high + 1 - * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: - * met_constraints = 0 # <<<<<<<<<<<<<< - * - * if (met_constraints and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1520 + * gap_error = 1 + * if self.tight_phrases: + * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: # <<<<<<<<<<<<<< + * gap_error = 1 + * reason_for_failure = "Inside edges of preceding subphrase are not tight" */ - __pyx_v_met_constraints = 0; - goto __pyx_L83; - } - __pyx_L83:; + __pyx_t_7 = ((__pyx_v_f_links_low[__pyx_v_f_back_low]) == -1); + if (!__pyx_t_7) { + __pyx_t_9 = ((__pyx_v_f_links_low[(__pyx_v_f_low - 1)]) == -1); + __pyx_t_8 = __pyx_t_9; + } else { + __pyx_t_8 = __pyx_t_7; + } + if (__pyx_t_8) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1667 - * met_constraints = 0 - * - * if (met_constraints and # <<<<<<<<<<<<<< - * self.find_fixpoint(f_back_low, f_x_high, - * f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1521 + * if self.tight_phrases: + * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: + * gap_error = 1 # <<<<<<<<<<<<<< + * reason_for_failure = "Inside edges of preceding subphrase are not tight" + * else: */ - if (__pyx_v_met_constraints) { + __pyx_v_gap_error = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1668 - * - * if (met_constraints and - * self.find_fixpoint(f_back_low, f_x_high, # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1522 + * if f_links_low[f_back_low] == -1 or f_links_low[f_low-1] == -1: + * gap_error = 1 + * reason_for_failure = "Inside edges of preceding subphrase are not tight" # <<<<<<<<<<<<<< + * else: + * gap_start = 1 */ - __pyx_t_15 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_131)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_131); + goto __pyx_L38; + } + __pyx_L38:; + goto __pyx_L37; + } + __pyx_L37:; + goto __pyx_L35; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1672 - * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 1, 1, 1, 0, 1, 1, 0) and - * ((not self.tight_phrases) or f_links_low[f_x_high-1] != -1) and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1524 + * reason_for_failure = "Inside edges of preceding subphrase are not tight" + * else: + * gap_start = 1 # <<<<<<<<<<<<<< + * if self.tight_phrases and f_links_low[f_low] == -1: + * # this is not a hard error. we can't extract this phrase */ - if (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_back_low, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 0, 1, 1, 0)) { - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_v_gap_start = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1674 - * self.train_max_initial_size, self.train_max_initial_size, - * 1, 1, 1, 0, 1, 1, 0) and - * ((not self.tight_phrases) or f_links_low[f_x_high-1] != -1) and # <<<<<<<<<<<<<< - * self.find_fixpoint(f_high, f_x_high, - * f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1525 + * else: + * gap_start = 1 + * if self.tight_phrases and f_links_low[f_low] == -1: # <<<<<<<<<<<<<< + * # this is not a hard error. we can't extract this phrase + * # but we still might be able to extract a superphrase */ - __pyx_t_9 = (!__pyx_v_self->tight_phrases); - if (!__pyx_t_9) { - __pyx_t_18 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) != -1); - __pyx_t_7 = __pyx_t_18; - } else { - __pyx_t_7 = __pyx_t_9; - } - if (__pyx_t_7) { + if (__pyx_v_self->tight_phrases) { + __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_low]) == -1); + __pyx_t_7 = __pyx_t_8; + } else { + __pyx_t_7 = __pyx_v_self->tight_phrases; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1675 - * 1, 1, 1, 0, 1, 1, 0) and - * ((not self.tight_phrases) or f_links_low[f_x_high-1] != -1) and - * self.find_fixpoint(f_high, f_x_high, # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * -1, -1, e_gap_low+gap_start+num_gaps, e_gap_high+gap_start+num_gaps, - */ - __pyx_t_14 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1528 + * # this is not a hard error. we can't extract this phrase + * # but we still might be able to extract a superphrase + * met_constraints = 0 # <<<<<<<<<<<<<< + * + * for i from 0 <= i < matching.size - 1: + */ + __pyx_v_met_constraints = 0; + goto __pyx_L39; + } + __pyx_L39:; + } + __pyx_L35:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1680 - * f_gap_low+gap_start+num_gaps, f_gap_high+gap_start+num_gaps, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1530 + * met_constraints = 0 + * + * for i from 0 <= i < matching.size - 1: # <<<<<<<<<<<<<< + * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start + * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start */ - __pyx_t_9 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_high, __pyx_t_14, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, ((__pyx_v_e_gap_low + __pyx_v_gap_start) + __pyx_v_num_gaps), ((__pyx_v_e_gap_high + __pyx_v_gap_start) + __pyx_v_num_gaps), ((__pyx_v_f_gap_low + __pyx_v_gap_start) + __pyx_v_num_gaps), ((__pyx_v_f_gap_high + __pyx_v_gap_start) + __pyx_v_num_gaps), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - } else { - __pyx_t_9 = __pyx_t_7; - } - __pyx_t_7 = __pyx_t_9; - } else { - __pyx_t_7 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_back_low, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 0, 1, 1, 0); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - } - __pyx_t_9 = __pyx_t_7; - } else { - __pyx_t_9 = __pyx_v_met_constraints; - } - if (__pyx_t_9) { + __pyx_t_12 = (__pyx_v_matching->size - 1); + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_12; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1682 - * self.train_max_initial_size, self.train_max_initial_size, - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() # <<<<<<<<<<<<<< - * i = 1 - * self.findexes.reset() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1531 + * + * for i from 0 <= i < matching.size - 1: + * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start # <<<<<<<<<<<<<< + * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start + * num_gaps = num_gaps + 1 */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_clear(__pyx_v_fphr_arr); + (__pyx_v_f_gap_low[(1 + __pyx_v_i)]) = (((__pyx_v_matching->arr[(__pyx_v_matching->start + __pyx_v_i)]) + (__pyx_v_chunklen[__pyx_v_i])) - __pyx_v_f_sent_start); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1683 - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() - * i = 1 # <<<<<<<<<<<<<< - * self.findexes.reset() - * if f_back_low < f_low: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1532 + * for i from 0 <= i < matching.size - 1: + * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start + * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start # <<<<<<<<<<<<<< + * num_gaps = num_gaps + 1 + * */ - __pyx_v_i = 1; + (__pyx_v_f_gap_high[(1 + __pyx_v_i)]) = ((__pyx_v_matching->arr[((__pyx_v_matching->start + __pyx_v_i) + 1)]) - __pyx_v_f_sent_start); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1684 - * fphr_arr._clear() - * i = 1 - * self.findexes.reset() # <<<<<<<<<<<<<< - * if f_back_low < f_low: - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1533 + * f_gap_low[1+i] = matching.arr[matching.start+i] + chunklen[i] - f_sent_start + * f_gap_high[1+i] = matching.arr[matching.start+i+1] - f_sent_start + * num_gaps = num_gaps + 1 # <<<<<<<<<<<<<< + * + * if f_high < f_back_high: */ - __pyx_t_15 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_14 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_v_num_gaps = (__pyx_v_num_gaps + 1); + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1685 - * i = 1 - * self.findexes.reset() - * if f_back_low < f_low: # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1535 + * num_gaps = num_gaps + 1 + * + * if f_high < f_back_high: # <<<<<<<<<<<<<< + * f_gap_low[gap_start+num_gaps] = f_high + * f_gap_high[gap_start+num_gaps] = f_back_high */ - __pyx_t_9 = (__pyx_v_f_back_low < __pyx_v_f_low); - if (__pyx_t_9) { + __pyx_t_7 = (__pyx_v_f_high < __pyx_v_f_back_high); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1686 - * self.findexes.reset() - * if f_back_low < f_low: - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * i = i+1 - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1536 + * + * if f_high < f_back_high: + * f_gap_low[gap_start+num_gaps] = f_high # <<<<<<<<<<<<<< + * f_gap_high[gap_start+num_gaps] = f_back_high + * num_gaps = num_gaps + 1 */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + (__pyx_v_f_gap_low[(__pyx_v_gap_start + __pyx_v_num_gaps)]) = __pyx_v_f_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1687 - * if f_back_low < f_low: - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) - * self.findexes.extend(self.findexes1) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1537 + * if f_high < f_back_high: + * f_gap_low[gap_start+num_gaps] = f_high + * f_gap_high[gap_start+num_gaps] = f_back_high # <<<<<<<<<<<<<< + * num_gaps = num_gaps + 1 + * phrase_len = phrase_len+1 */ - __pyx_v_i = (__pyx_v_i + 1); + (__pyx_v_f_gap_high[(__pyx_v_gap_start + __pyx_v_num_gaps)]) = __pyx_v_f_back_high; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1688 - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i+1 - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1538 + * f_gap_low[gap_start+num_gaps] = f_high + * f_gap_high[gap_start+num_gaps] = f_back_high + * num_gaps = num_gaps + 1 # <<<<<<<<<<<<<< + * phrase_len = phrase_len+1 + * if phrase_len > self.max_length: */ - __pyx_t_14 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - goto __pyx_L85; - } - __pyx_L85:; + __pyx_v_num_gaps = (__pyx_v_num_gaps + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1689 - * i = i+1 - * self.findexes.append(sym_setindex(self.category, i)) - * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1539 + * f_gap_high[gap_start+num_gaps] = f_back_high + * num_gaps = num_gaps + 1 + * phrase_len = phrase_len+1 # <<<<<<<<<<<<<< + * if phrase_len > self.max_length: + * gap_error = 1 */ - __pyx_t_15 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); - PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_self->findexes1)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); - __pyx_t_1 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1689; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_v_phrase_len = (__pyx_v_phrase_len + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1690 - * self.findexes.append(sym_setindex(self.category, i)) - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1540 + * num_gaps = num_gaps + 1 + * phrase_len = phrase_len+1 + * if phrase_len > self.max_length: # <<<<<<<<<<<<<< + * gap_error = 1 + * if self.tight_phrases: */ - __pyx_t_3 = __pyx_v_phrase->n; - for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { + __pyx_t_7 = (__pyx_v_phrase_len > __pyx_v_self->max_length); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1691 - * self.findexes.extend(self.findexes1) - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1541 + * phrase_len = phrase_len+1 + * if phrase_len > self.max_length: + * gap_error = 1 # <<<<<<<<<<<<<< + * if self.tight_phrases: + * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: */ - __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); - if (__pyx_t_4) { + __pyx_v_gap_error = 1; + goto __pyx_L43; + } + __pyx_L43:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1692 - * for j from 0 <= j < phrase.n: - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * i = i + 1 - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1542 + * if phrase_len > self.max_length: + * gap_error = 1 + * if self.tight_phrases: # <<<<<<<<<<<<<< + * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: + * gap_error = 1 */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + if (__pyx_v_self->tight_phrases) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1693 - * if sym_isvar(phrase.syms[j]): - * fphr_arr._append(sym_setindex(self.category, i)) - * i = i + 1 # <<<<<<<<<<<<<< - * else: - * fphr_arr._append(phrase.syms[j]) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1543 + * gap_error = 1 + * if self.tight_phrases: + * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: # <<<<<<<<<<<<<< + * gap_error = 1 + * reason_for_failure = "Inside edges of following subphrase are not tight" */ - __pyx_v_i = (__pyx_v_i + 1); - goto __pyx_L88; - } - /*else*/ { + __pyx_t_7 = ((__pyx_v_f_links_low[(__pyx_v_f_back_high - 1)]) == -1); + if (!__pyx_t_7) { + __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_high]) == -1); + __pyx_t_9 = __pyx_t_8; + } else { + __pyx_t_9 = __pyx_t_7; + } + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1695 - * i = i + 1 - * else: - * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1544 + * if self.tight_phrases: + * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: + * gap_error = 1 # <<<<<<<<<<<<<< + * reason_for_failure = "Inside edges of following subphrase are not tight" + * else: */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); - } - __pyx_L88:; - } + __pyx_v_gap_error = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1696 - * else: - * fphr_arr._append(phrase.syms[j]) - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) - * fphr = Phrase(fphr_arr) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1545 + * if f_links_low[f_back_high-1] == -1 or f_links_low[f_high] == -1: + * gap_error = 1 + * reason_for_failure = "Inside edges of following subphrase are not tight" # <<<<<<<<<<<<<< + * else: + * if self.tight_phrases and f_links_low[f_high-1] == -1: */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_132)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_132); + goto __pyx_L45; + } + __pyx_L45:; + goto __pyx_L44; + } + __pyx_L44:; + goto __pyx_L42; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1697 - * fphr_arr._append(phrase.syms[j]) - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * fphr = Phrase(fphr_arr) - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low+gap_start, e_gap_high+gap_start, e_links_low, num_gaps+1, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1547 + * reason_for_failure = "Inside edges of following subphrase are not tight" + * else: + * if self.tight_phrases and f_links_low[f_high-1] == -1: # <<<<<<<<<<<<<< + * met_constraints = 0 + * */ - __pyx_t_1 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_14 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + if (__pyx_v_self->tight_phrases) { + __pyx_t_9 = ((__pyx_v_f_links_low[(__pyx_v_f_high - 1)]) == -1); + __pyx_t_7 = __pyx_t_9; + } else { + __pyx_t_7 = __pyx_v_self->tight_phrases; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1698 - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) - * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low+gap_start, e_gap_high+gap_start, e_links_low, num_gaps+1, - * f_x_low, f_x_high, f_gap_low+gap_start, f_gap_high+gap_start, f_links_low, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1548 + * else: + * if self.tight_phrases and f_links_low[f_high-1] == -1: + * met_constraints = 0 # <<<<<<<<<<<<<< + * + * if gap_error == 0: */ - __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1698; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); - PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_fphr_arr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1698; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; - __Pyx_DECREF(((PyObject *)__pyx_v_fphr)); - __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_1); - __pyx_t_1 = 0; + __pyx_v_met_constraints = 0; + goto __pyx_L46; + } + __pyx_L46:; + } + __pyx_L42:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1701 - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low+gap_start, e_gap_high+gap_start, e_links_low, num_gaps+1, - * f_x_low, f_x_high, f_gap_low+gap_start, f_gap_high+gap_start, f_links_low, - * matching.sent_id, e_sent_len, e_sent_start) # <<<<<<<<<<<<<< - * if len(phrase_list) > 0: - * pair_count = 1.0 / len(phrase_list) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1550 + * met_constraints = 0 + * + * if gap_error == 0: # <<<<<<<<<<<<<< + * e_word_count = e_high - e_low + * for i from 0 <= i < num_gaps: # check integrity of subphrases */ - __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_x_low, __pyx_v_e_x_high, (__pyx_v_e_gap_low + __pyx_v_gap_start), (__pyx_v_e_gap_high + __pyx_v_gap_start), __pyx_v_e_links_low, (__pyx_v_num_gaps + 1), __pyx_v_f_x_low, __pyx_v_f_x_high, (__pyx_v_f_gap_low + __pyx_v_gap_start), (__pyx_v_f_gap_high + __pyx_v_gap_start), __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_v_phrase_list); - __pyx_v_phrase_list = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_t_7 = (__pyx_v_gap_error == 0); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1702 - * f_x_low, f_x_high, f_gap_low+gap_start, f_gap_high+gap_start, f_links_low, - * matching.sent_id, e_sent_len, e_sent_start) - * if len(phrase_list) > 0: # <<<<<<<<<<<<<< - * pair_count = 1.0 / len(phrase_list) - * else: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1551 + * + * if gap_error == 0: + * e_word_count = e_high - e_low # <<<<<<<<<<<<<< + * for i from 0 <= i < num_gaps: # check integrity of subphrases + * if self.find_fixpoint(f_gap_low[gap_start+i], f_gap_high[gap_start+i], */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_9 = (__pyx_t_13 > 0); - if (__pyx_t_9) { + __pyx_v_e_word_count = (__pyx_v_e_high - __pyx_v_e_low); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1703 - * matching.sent_id, e_sent_len, e_sent_start) - * if len(phrase_list) > 0: - * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< - * else: - * pair_count = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1552 + * if gap_error == 0: + * e_word_count = e_high - e_low + * for i from 0 <= i < num_gaps: # check integrity of subphrases # <<<<<<<<<<<<<< + * if self.find_fixpoint(f_gap_low[gap_start+i], f_gap_high[gap_start+i], + * f_links_low, f_links_high, e_links_low, e_links_high, */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(__pyx_t_13 == 0)) { - PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - __pyx_v_pair_count = (1.0 / __pyx_t_13); - goto __pyx_L89; - } - /*else*/ { + __pyx_t_3 = __pyx_v_num_gaps; + for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_3; __pyx_v_i++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1705 - * pair_count = 1.0 / len(phrase_list) - * else: - * pair_count = 0 # <<<<<<<<<<<<<< - * for phrase2, eindexes in phrase_list: - * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1553 + * e_word_count = e_high - e_low + * for i from 0 <= i < num_gaps: # check integrity of subphrases + * if self.find_fixpoint(f_gap_low[gap_start+i], f_gap_high[gap_start+i], # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * -1, -1, e_gap_low+gap_start+i, e_gap_high+gap_start+i, */ - __pyx_v_pair_count = 0.0; - } - __pyx_L89:; + __pyx_t_10 = PyInt_FromLong((__pyx_v_f_gap_high[(__pyx_v_gap_start + __pyx_v_i)])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1553; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1706 - * else: - * pair_count = 0 - * for phrase2, eindexes in phrase_list: # <<<<<<<<<<<<<< - * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als3))) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1558 + * f_gap_low+gap_start+i, f_gap_high+gap_start+i, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 0, 0, 0, 0, 0, 0, 0) == 0: + * gap_error = 1 */ - if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { - __pyx_t_1 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_13 = 0; - __pyx_t_16 = NULL; - } else { - __pyx_t_13 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_16 = Py_TYPE(__pyx_t_1)->tp_iternext; - } - for (;;) { - if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_14 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_14); __pyx_t_13++; - #else - __pyx_t_14 = PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_14); __pyx_t_13++; - #else - __pyx_t_14 = PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #endif - } else { - __pyx_t_14 = __pyx_t_16(__pyx_t_1); - if (unlikely(!__pyx_t_14)) { - if (PyErr_Occurred()) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - break; - } - __Pyx_GOTREF(__pyx_t_14); - } - if ((likely(PyTuple_CheckExact(__pyx_t_14))) || (PyList_CheckExact(__pyx_t_14))) { - PyObject* sequence = __pyx_t_14; - #if CYTHON_COMPILING_IN_CPYTHON - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - } - #if CYTHON_COMPILING_IN_CPYTHON - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_15 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_15 = PyList_GET_ITEM(sequence, 0); - __pyx_t_2 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_15); - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_15 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - #endif - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - } else - { - Py_ssize_t index = -1; - __pyx_t_10 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; - index = 0; __pyx_t_15 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_15)) goto __pyx_L92_unpacking_failed; - __Pyx_GOTREF(__pyx_t_15); - index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L92_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_17 = NULL; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - goto __pyx_L93_unpacking_done; - __pyx_L92_unpacking_failed:; - __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - __pyx_t_17 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L93_unpacking_done:; - } - __Pyx_XDECREF(__pyx_v_phrase2); - __pyx_v_phrase2 = __pyx_t_15; - __pyx_t_15 = 0; - __Pyx_XDECREF(__pyx_v_eindexes); - __pyx_v_eindexes = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_t_7 = (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, (__pyx_v_f_gap_low[(__pyx_v_gap_start + __pyx_v_i)]), __pyx_t_10, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, ((__pyx_v_e_gap_low + __pyx_v_gap_start) + __pyx_v_i), ((__pyx_v_e_gap_high + __pyx_v_gap_start) + __pyx_v_i), ((__pyx_v_f_gap_low + __pyx_v_gap_start) + __pyx_v_i), ((__pyx_v_f_gap_high + __pyx_v_gap_start) + __pyx_v_i), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0) == 0); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1707 - * pair_count = 0 - * for phrase2, eindexes in phrase_list: - * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< - * extracts.append((fphr, phrase2, pair_count, tuple(als3))) - * if (num_gaps < self.max_nonterminals - 1 and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1560 + * self.train_max_initial_size, self.train_max_initial_size, + * 0, 0, 0, 0, 0, 0, 0) == 0: + * gap_error = 1 # <<<<<<<<<<<<<< + * reason_for_failure = "Subphrase [%d, %d] failed integrity check" % (f_gap_low[gap_start+i], f_gap_high[gap_start+i]) + * break */ - __pyx_t_14 = ((PyObject *)__pyx_v_self->findexes); - __Pyx_INCREF(__pyx_t_14); - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_14, __pyx_v_eindexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_XDECREF(__pyx_v_als3); - __pyx_v_als3 = __pyx_t_2; - __pyx_t_2 = 0; + __pyx_v_gap_error = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1708 - * for phrase2, eindexes in phrase_list: - * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als3))) # <<<<<<<<<<<<<< - * if (num_gaps < self.max_nonterminals - 1 and - * phrase_len+1 < self.max_length and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1561 + * 0, 0, 0, 0, 0, 0, 0) == 0: + * gap_error = 1 + * reason_for_failure = "Subphrase [%d, %d] failed integrity check" % (f_gap_low[gap_start+i], f_gap_high[gap_start+i]) # <<<<<<<<<<<<<< + * break + * */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_INCREF(__pyx_v_als3); - PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_v_als3); - __Pyx_GIVEREF(__pyx_v_als3); - __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; - __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); - PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_fphr)); - __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); - __Pyx_INCREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_v_phrase2); - __Pyx_GIVEREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_2); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_15); - __Pyx_GIVEREF(__pyx_t_15); - __pyx_t_2 = 0; - __pyx_t_15 = 0; - __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_14)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L84; - } - __pyx_L84:; - goto __pyx_L79; - } - __pyx_L79:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1709 - * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als3))) - * if (num_gaps < self.max_nonterminals - 1 and # <<<<<<<<<<<<<< - * phrase_len+1 < self.max_length and - * f_back_high == f_high and - */ - __pyx_t_9 = (__pyx_v_num_gaps < (__pyx_v_self->max_nonterminals - 1)); - if (__pyx_t_9) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1710 - * extracts.append((fphr, phrase2, pair_count, tuple(als3))) - * if (num_gaps < self.max_nonterminals - 1 and - * phrase_len+1 < self.max_length and # <<<<<<<<<<<<<< - * f_back_high == f_high and - * f_back_low == f_low and - */ - __pyx_t_7 = ((__pyx_v_phrase_len + 1) < __pyx_v_self->max_length); - if (__pyx_t_7) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1711 - * if (num_gaps < self.max_nonterminals - 1 and - * phrase_len+1 < self.max_length and - * f_back_high == f_high and # <<<<<<<<<<<<<< - * f_back_low == f_low and - * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and - */ - __pyx_t_18 = (__pyx_v_f_back_high == __pyx_v_f_high); - if (__pyx_t_18) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1712 - * phrase_len+1 < self.max_length and - * f_back_high == f_high and - * f_back_low == f_low and # <<<<<<<<<<<<<< - * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and - * f_low >= self.train_min_gap_size and - */ - __pyx_t_8 = (__pyx_v_f_back_low == __pyx_v_f_low); - if (__pyx_t_8) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1713 - * f_back_high == f_high and - * f_back_low == f_low and - * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and # <<<<<<<<<<<<<< - * f_low >= self.train_min_gap_size and - * f_high <= f_sent_len - self.train_min_gap_size and - */ - __pyx_t_19 = (((__pyx_v_f_back_high - __pyx_v_f_back_low) + (2 * __pyx_v_self->train_min_gap_size)) <= __pyx_v_self->train_max_initial_size); - if (__pyx_t_19) { + __pyx_t_10 = PyInt_FromLong((__pyx_v_f_gap_low[(__pyx_v_gap_start + __pyx_v_i)])); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_1 = PyInt_FromLong((__pyx_v_f_gap_high[(__pyx_v_gap_start + __pyx_v_i)])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_10 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_133), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1561; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_t_1); + __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1714 - * f_back_low == f_low and - * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and - * f_low >= self.train_min_gap_size and # <<<<<<<<<<<<<< - * f_high <= f_sent_len - self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1562 + * gap_error = 1 + * reason_for_failure = "Subphrase [%d, %d] failed integrity check" % (f_gap_low[gap_start+i], f_gap_high[gap_start+i]) + * break # <<<<<<<<<<<<<< + * + * if gap_error == 0: */ - __pyx_t_20 = (__pyx_v_f_low >= __pyx_v_self->train_min_gap_size); - if (__pyx_t_20) { + goto __pyx_L49_break; + goto __pyx_L50; + } + __pyx_L50:; + } + __pyx_L49_break:; + goto __pyx_L47; + } + __pyx_L47:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1715 - * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and - * f_low >= self.train_min_gap_size and - * f_high <= f_sent_len - self.train_min_gap_size and # <<<<<<<<<<<<<< - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1564 + * break * + * if gap_error == 0: # <<<<<<<<<<<<<< + * i = 1 + * self.findexes.reset() */ - __pyx_t_21 = (__pyx_v_f_high <= (__pyx_v_f_sent_len - __pyx_v_self->train_min_gap_size)); - if (__pyx_t_21) { + __pyx_t_7 = (__pyx_v_gap_error == 0); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1716 - * f_low >= self.train_min_gap_size and - * f_high <= f_sent_len - self.train_min_gap_size and - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1565 * - * met_constraints = 1 + * if gap_error == 0: + * i = 1 # <<<<<<<<<<<<<< + * self.findexes.reset() + * if f_back_low < f_low: */ - __pyx_t_22 = (!__pyx_v_self->tight_phrases); - if (!__pyx_t_22) { - __pyx_t_23 = ((__pyx_v_f_links_low[(__pyx_v_f_low - 1)]) != -1); - if (__pyx_t_23) { - __pyx_t_24 = ((__pyx_v_f_links_low[__pyx_v_f_high]) != -1); - __pyx_t_25 = __pyx_t_24; - } else { - __pyx_t_25 = __pyx_t_23; - } - __pyx_t_23 = __pyx_t_25; - } else { - __pyx_t_23 = __pyx_t_22; - } - __pyx_t_22 = __pyx_t_23; - } else { - __pyx_t_22 = __pyx_t_21; - } - __pyx_t_21 = __pyx_t_22; - } else { - __pyx_t_21 = __pyx_t_20; - } - __pyx_t_20 = __pyx_t_21; - } else { - __pyx_t_20 = __pyx_t_19; - } - __pyx_t_19 = __pyx_t_20; - } else { - __pyx_t_19 = __pyx_t_8; - } - __pyx_t_8 = __pyx_t_19; - } else { - __pyx_t_8 = __pyx_t_18; - } - __pyx_t_18 = __pyx_t_8; - } else { - __pyx_t_18 = __pyx_t_7; - } - __pyx_t_7 = __pyx_t_18; - } else { - __pyx_t_7 = __pyx_t_9; - } - if (__pyx_t_7) { + __pyx_v_i = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1718 - * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): - * - * met_constraints = 1 # <<<<<<<<<<<<<< - * f_x_low = f_low-self.train_min_gap_size - * if self.tight_phrases: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1566 + * if gap_error == 0: + * i = 1 + * self.findexes.reset() # <<<<<<<<<<<<<< + * if f_back_low < f_low: + * fphr_arr._append(sym_setindex(self.category, i)) */ - __pyx_v_met_constraints = 1; + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1566; __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[8]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1719 - * - * met_constraints = 1 - * f_x_low = f_low-self.train_min_gap_size # <<<<<<<<<<<<<< - * if self.tight_phrases: - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1567 + * i = 1 + * self.findexes.reset() + * if f_back_low < f_low: # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 */ - __pyx_v_f_x_low = (__pyx_v_f_low - __pyx_v_self->train_min_gap_size); + __pyx_t_7 = (__pyx_v_f_back_low < __pyx_v_f_low); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1720 - * met_constraints = 1 - * f_x_low = f_low-self.train_min_gap_size - * if self.tight_phrases: # <<<<<<<<<<<<<< - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: - * f_x_low = f_x_low - 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1568 + * self.findexes.reset() + * if f_back_low < f_low: + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * i = i+1 + * self.findexes.append(sym_setindex(self.category, i)) */ - if (__pyx_v_self->tight_phrases) { + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1721 - * f_x_low = f_low-self.train_min_gap_size - * if self.tight_phrases: - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: # <<<<<<<<<<<<<< - * f_x_low = f_x_low - 1 - * if f_x_low < 0: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1569 + * if f_back_low < f_low: + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) + * self.findexes.extend(self.findexes1) */ - while (1) { - __pyx_t_7 = (__pyx_v_f_x_low >= 0); - if (__pyx_t_7) { - __pyx_t_9 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) == -1); - __pyx_t_18 = __pyx_t_9; - } else { - __pyx_t_18 = __pyx_t_7; - } - if (!__pyx_t_18) break; + __pyx_v_i = (__pyx_v_i + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1722 - * if self.tight_phrases: - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: - * f_x_low = f_x_low - 1 # <<<<<<<<<<<<<< - * if f_x_low < 0: - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1570 + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: */ - __pyx_v_f_x_low = (__pyx_v_f_x_low - 1); - } - goto __pyx_L95; - } - __pyx_L95:; + __pyx_t_2 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1570; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L52; + } + __pyx_L52:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1723 - * while f_x_low >= 0 and f_links_low[f_x_low] == -1: - * f_x_low = f_x_low - 1 - * if f_x_low < 0: # <<<<<<<<<<<<<< - * met_constraints = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1571 + * i = i+1 + * self.findexes.append(sym_setindex(self.category, i)) + * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): */ - __pyx_t_18 = (__pyx_v_f_x_low < 0); - if (__pyx_t_18) { + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->findexes1)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); + __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1571; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1724 - * f_x_low = f_x_low - 1 - * if f_x_low < 0: - * met_constraints = 0 # <<<<<<<<<<<<<< - * - * f_x_high = f_high+self.train_min_gap_size + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1572 + * self.findexes.append(sym_setindex(self.category, i)) + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) */ - __pyx_v_met_constraints = 0; - goto __pyx_L98; - } - __pyx_L98:; + __pyx_t_3 = __pyx_v_phrase->n; + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1726 - * met_constraints = 0 - * - * f_x_high = f_high+self.train_min_gap_size # <<<<<<<<<<<<<< - * if self.tight_phrases: - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1573 + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i + 1 */ - __pyx_v_f_x_high = (__pyx_v_f_high + __pyx_v_self->train_min_gap_size); + __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); + if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1727 - * - * f_x_high = f_high+self.train_min_gap_size - * if self.tight_phrases: # <<<<<<<<<<<<<< - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: - * f_x_high = f_x_high + 1 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1574 + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * i = i + 1 + * else: */ - if (__pyx_v_self->tight_phrases) { + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1728 - * f_x_high = f_high+self.train_min_gap_size - * if self.tight_phrases: - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: # <<<<<<<<<<<<<< - * f_x_high = f_x_high + 1 - * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1575 + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i + 1 # <<<<<<<<<<<<<< + * else: + * fphr_arr._append(phrase.syms[j]) */ - while (1) { - __pyx_t_18 = (__pyx_v_f_x_high <= __pyx_v_f_sent_len); - if (__pyx_t_18) { - __pyx_t_7 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) == -1); - __pyx_t_9 = __pyx_t_7; - } else { - __pyx_t_9 = __pyx_t_18; - } - if (!__pyx_t_9) break; + __pyx_v_i = (__pyx_v_i + 1); + goto __pyx_L55; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1729 - * if self.tight_phrases: - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: - * f_x_high = f_x_high + 1 # <<<<<<<<<<<<<< - * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1577 + * i = i + 1 + * else: + * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< + * if f_back_high > f_high: + * fphr_arr._append(sym_setindex(self.category, i)) */ - __pyx_v_f_x_high = (__pyx_v_f_x_high + 1); - } - goto __pyx_L99; - } - __pyx_L99:; + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); + } + __pyx_L55:; + } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1730 - * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: - * f_x_high = f_x_high + 1 - * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: # <<<<<<<<<<<<<< - * met_constraints = 0 - * + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1578 + * else: + * fphr_arr._append(phrase.syms[j]) + * if f_back_high > f_high: # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) */ - __pyx_t_9 = (__pyx_v_f_x_high > __pyx_v_f_sent_len); - if (!__pyx_t_9) { - __pyx_t_18 = ((__pyx_v_f_x_high - __pyx_v_f_x_low) > __pyx_v_self->train_max_initial_size); - __pyx_t_7 = __pyx_t_18; - } else { - __pyx_t_7 = __pyx_t_9; - } - if (__pyx_t_7) { + __pyx_t_7 = (__pyx_v_f_back_high > __pyx_v_f_high); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1731 - * f_x_high = f_x_high + 1 - * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: - * met_constraints = 0 # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1579 + * fphr_arr._append(phrase.syms[j]) + * if f_back_high > f_high: + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) * - * if (met_constraints and */ - __pyx_v_met_constraints = 0; - goto __pyx_L102; - } - __pyx_L102:; + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1733 - * met_constraints = 0 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1580 + * if f_back_high > f_high: + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< * - * if (met_constraints and # <<<<<<<<<<<<<< - * self.find_fixpoint(f_x_low, f_x_high, - * f_links_low, f_links_high, e_links_low, e_links_high, + * fphr = Phrase(fphr_arr) */ - if (__pyx_v_met_constraints) { + __pyx_t_10 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1580; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + goto __pyx_L56; + } + __pyx_L56:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1734 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1582 + * self.findexes.append(sym_setindex(self.category, i)) * - * if (met_constraints and - * self.find_fixpoint(f_x_low, f_x_high, # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< + * if met_constraints: + * phrase_list = self.extract_phrases(e_low, e_high, e_gap_low + gap_start, e_gap_high + gap_start, e_links_low, num_gaps, */ - __pyx_t_1 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); + PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_fphr_arr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); + __pyx_t_10 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1582; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_10); + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1738 - * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 1, 1, 2, 1, 1, 1, 1) and - * ((not self.tight_phrases) or (f_links_low[f_x_low] != -1 and f_links_low[f_x_high-1] != -1)) and + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1583 + * + * fphr = Phrase(fphr_arr) + * if met_constraints: # <<<<<<<<<<<<<< + * phrase_list = self.extract_phrases(e_low, e_high, e_gap_low + gap_start, e_gap_high + gap_start, e_links_low, num_gaps, + * f_back_low, f_back_high, f_gap_low + gap_start, f_gap_high + gap_start, f_links_low, */ - if (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 2, 1, 1, 1, 1)) { - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_v_met_constraints) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1740 - * self.train_max_initial_size, self.train_max_initial_size, - * 1, 1, 2, 1, 1, 1, 1) and - * ((not self.tight_phrases) or (f_links_low[f_x_low] != -1 and f_links_low[f_x_high-1] != -1)) and # <<<<<<<<<<<<<< - * self.find_fixpoint(f_x_low, f_low, - * f_links_low, f_links_high, e_links_low, e_links_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1586 + * phrase_list = self.extract_phrases(e_low, e_high, e_gap_low + gap_start, e_gap_high + gap_start, e_links_low, num_gaps, + * f_back_low, f_back_high, f_gap_low + gap_start, f_gap_high + gap_start, f_links_low, + * matching.sent_id, e_sent_len, e_sent_start) # <<<<<<<<<<<<<< + * if len(phrase_list) > 0: + * pair_count = 1.0 / len(phrase_list) */ - __pyx_t_7 = (!__pyx_v_self->tight_phrases); - if (!__pyx_t_7) { - __pyx_t_9 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) != -1); - if (__pyx_t_9) { - __pyx_t_18 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) != -1); - __pyx_t_8 = __pyx_t_18; - } else { - __pyx_t_8 = __pyx_t_9; - } - __pyx_t_9 = __pyx_t_8; - } else { - __pyx_t_9 = __pyx_t_7; - } - if (__pyx_t_9) { + __pyx_t_10 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_low, __pyx_v_e_high, (__pyx_v_e_gap_low + __pyx_v_gap_start), (__pyx_v_e_gap_high + __pyx_v_gap_start), __pyx_v_e_links_low, __pyx_v_num_gaps, __pyx_v_f_back_low, __pyx_v_f_back_high, (__pyx_v_f_gap_low + __pyx_v_gap_start), (__pyx_v_f_gap_high + __pyx_v_gap_start), __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1584; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_v_phrase_list = __pyx_t_10; + __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1741 - * 1, 1, 2, 1, 1, 1, 1) and - * ((not self.tight_phrases) or (f_links_low[f_x_low] != -1 and f_links_low[f_x_high-1] != -1)) and - * self.find_fixpoint(f_x_low, f_low, # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1587 + * f_back_low, f_back_high, f_gap_low + gap_start, f_gap_high + gap_start, f_links_low, + * matching.sent_id, e_sent_len, e_sent_start) + * if len(phrase_list) > 0: # <<<<<<<<<<<<<< + * pair_count = 1.0 / len(phrase_list) + * else: */ - __pyx_t_15 = PyInt_FromLong(__pyx_v_f_low); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1587; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = (__pyx_t_13 > 0); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1745 - * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 0, 0, 0, 0, 0, 0, 0) and - * self.find_fixpoint(f_high, f_x_high, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1588 + * matching.sent_id, e_sent_len, e_sent_start) + * if len(phrase_list) > 0: + * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< + * else: + * pair_count = 0 */ - __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - if (__pyx_t_3) { + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_13 == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1588; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_pair_count = (1.0 / __pyx_t_13); + goto __pyx_L58; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1747 - * self.train_max_initial_size, self.train_max_initial_size, - * 0, 0, 0, 0, 0, 0, 0) and - * self.find_fixpoint(f_high, f_x_high, # <<<<<<<<<<<<<< - * f_links_low, f_links_high, e_links_low, e_links_high, - * -1, -1, e_gap_low+1+num_gaps, e_gap_high+1+num_gaps, + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1590 + * pair_count = 1.0 / len(phrase_list) + * else: + * pair_count = 0 # <<<<<<<<<<<<<< + * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) + * for (phrase2,eindexes) in phrase_list: */ - __pyx_t_15 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); + __pyx_v_pair_count = 0.0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1752 - * f_gap_low+1+num_gaps, f_gap_high+1+num_gaps, - * f_sent_len, e_sent_len, - * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< - * 0, 0, 0, 0, 0, 0, 0)): - * fphr_arr._clear() + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1591 + * else: + * pair_count = 0 + * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) # <<<<<<<<<<<<<< + * for (phrase2,eindexes) in phrase_list: + * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) */ - __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_high, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, ((__pyx_v_e_gap_low + 1) + __pyx_v_num_gaps), ((__pyx_v_e_gap_high + 1) + __pyx_v_num_gaps), ((__pyx_v_f_gap_low + 1) + __pyx_v_num_gaps), ((__pyx_v_f_gap_high + 1) + __pyx_v_num_gaps), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __pyx_t_7 = __pyx_t_4; - } else { - __pyx_t_7 = __pyx_t_3; - } - __pyx_t_8 = __pyx_t_7; + __pyx_t_10 = PyInt_FromLong(__pyx_v_f_back_low); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __pyx_t_2 = PyInt_FromLong(__pyx_v_f_back_high); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_1 = PyInt_FromLong(__pyx_v_e_low); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_14 = PyInt_FromLong(__pyx_v_e_high); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10); + __Pyx_GIVEREF(__pyx_t_10); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); + __pyx_t_10 = 0; + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_t_14 = 0; + __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_134), ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1591; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_14)); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_t_14); + __pyx_t_14 = 0; + } + __pyx_L58:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1592 + * pair_count = 0 + * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) + * for (phrase2,eindexes) in phrase_list: # <<<<<<<<<<<<<< + * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als1))) + */ + if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { + __pyx_t_14 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_14); __pyx_t_13 = 0; + __pyx_t_16 = NULL; + } else { + __pyx_t_13 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_16 = Py_TYPE(__pyx_t_14)->tp_iternext; + } + for (;;) { + if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_14)) { + if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_14)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_15 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; + #else + __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_14)) { + if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_14)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; + #else + __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_15 = __pyx_t_16(__pyx_t_14); + if (unlikely(!__pyx_t_15)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_15); + } + if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) { + PyObject* sequence = __pyx_t_15; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_2 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_10 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; + index = 0; __pyx_t_1 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L61_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L61_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = NULL; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L62_unpacking_done; + __pyx_L61_unpacking_failed:; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_17 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1592; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L62_unpacking_done:; + } + __Pyx_XDECREF(__pyx_v_phrase2); + __pyx_v_phrase2 = __pyx_t_1; + __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_v_eindexes); + __pyx_v_eindexes = __pyx_t_2; + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1593 + * reason_for_failure = "Didn't extract anything from [%d, %d] -> [%d, %d]" % (f_back_low, f_back_high, e_low, e_high) + * for (phrase2,eindexes) in phrase_list: + * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< + * extracts.append((fphr, phrase2, pair_count, tuple(als1))) + * + */ + __pyx_t_15 = ((PyObject *)__pyx_v_self->findexes); + __Pyx_INCREF(__pyx_t_15); + __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_15, __pyx_v_eindexes)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1593; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_als1)); + __pyx_v_als1 = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1594 + * for (phrase2,eindexes) in phrase_list: + * als1 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als1))) # <<<<<<<<<<<<<< + * + * if (num_gaps < self.max_nonterminals and + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_v_als1)); + PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_als1)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_als1)); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); + PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_fphr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); + __Pyx_INCREF(__pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_phrase2); + __Pyx_GIVEREF(__pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + goto __pyx_L57; + } + __pyx_L57:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1596 + * extracts.append((fphr, phrase2, pair_count, tuple(als1))) + * + * if (num_gaps < self.max_nonterminals and # <<<<<<<<<<<<<< + * phrase_len < self.max_length and + * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): + */ + __pyx_t_7 = (__pyx_v_num_gaps < __pyx_v_self->max_nonterminals); + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1597 + * + * if (num_gaps < self.max_nonterminals and + * phrase_len < self.max_length and # <<<<<<<<<<<<<< + * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): + * if (f_back_low == f_low and + */ + __pyx_t_9 = (__pyx_v_phrase_len < __pyx_v_self->max_length); + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1598 + * if (num_gaps < self.max_nonterminals and + * phrase_len < self.max_length and + * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): # <<<<<<<<<<<<<< + * if (f_back_low == f_low and + * f_low >= self.train_min_gap_size and + */ + __pyx_t_8 = (((__pyx_v_f_back_high - __pyx_v_f_back_low) + __pyx_v_self->train_min_gap_size) <= __pyx_v_self->train_max_initial_size); + __pyx_t_18 = __pyx_t_8; + } else { + __pyx_t_18 = __pyx_t_9; + } + __pyx_t_9 = __pyx_t_18; + } else { + __pyx_t_9 = __pyx_t_7; + } + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1599 + * phrase_len < self.max_length and + * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): + * if (f_back_low == f_low and # <<<<<<<<<<<<<< + * f_low >= self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): + */ + __pyx_t_9 = (__pyx_v_f_back_low == __pyx_v_f_low); + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1600 + * f_back_high - f_back_low + self.train_min_gap_size <= self.train_max_initial_size): + * if (f_back_low == f_low and + * f_low >= self.train_min_gap_size and # <<<<<<<<<<<<<< + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): + * f_x_low = f_low-self.train_min_gap_size + */ + __pyx_t_7 = (__pyx_v_f_low >= __pyx_v_self->train_min_gap_size); + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1601 + * if (f_back_low == f_low and + * f_low >= self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): # <<<<<<<<<<<<<< + * f_x_low = f_low-self.train_min_gap_size + * met_constraints = 1 + */ + __pyx_t_18 = (!__pyx_v_self->tight_phrases); + if (!__pyx_t_18) { + __pyx_t_8 = ((__pyx_v_f_links_low[(__pyx_v_f_low - 1)]) != -1); + if (__pyx_t_8) { + __pyx_t_19 = ((__pyx_v_f_links_low[(__pyx_v_f_back_high - 1)]) != -1); + __pyx_t_20 = __pyx_t_19; } else { - __pyx_t_8 = __pyx_t_9; + __pyx_t_20 = __pyx_t_8; } - __pyx_t_9 = __pyx_t_8; + __pyx_t_8 = __pyx_t_20; } else { - __pyx_t_9 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 2, 1, 1, 1, 1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_8 = __pyx_t_18; } - __pyx_t_8 = __pyx_t_9; + __pyx_t_18 = __pyx_t_8; } else { - __pyx_t_8 = __pyx_v_met_constraints; + __pyx_t_18 = __pyx_t_7; } - if (__pyx_t_8) { + __pyx_t_7 = __pyx_t_18; + } else { + __pyx_t_7 = __pyx_t_9; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1754 - * self.train_max_initial_size, self.train_max_initial_size, - * 0, 0, 0, 0, 0, 0, 0)): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1602 + * f_low >= self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): + * f_x_low = f_low-self.train_min_gap_size # <<<<<<<<<<<<<< + * met_constraints = 1 + * if self.tight_phrases: + */ + __pyx_v_f_x_low = (__pyx_v_f_low - __pyx_v_self->train_min_gap_size); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1603 + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_back_high-1] != -1))): + * f_x_low = f_low-self.train_min_gap_size + * met_constraints = 1 # <<<<<<<<<<<<<< + * if self.tight_phrases: + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + */ + __pyx_v_met_constraints = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1604 + * f_x_low = f_low-self.train_min_gap_size + * met_constraints = 1 + * if self.tight_phrases: # <<<<<<<<<<<<<< + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + * f_x_low = f_x_low - 1 + */ + if (__pyx_v_self->tight_phrases) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1605 + * met_constraints = 1 + * if self.tight_phrases: + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: # <<<<<<<<<<<<<< + * f_x_low = f_x_low - 1 + * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: + */ + while (1) { + __pyx_t_7 = (__pyx_v_f_x_low >= 0); + if (__pyx_t_7) { + __pyx_t_9 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) == -1); + __pyx_t_18 = __pyx_t_9; + } else { + __pyx_t_18 = __pyx_t_7; + } + if (!__pyx_t_18) break; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1606 + * if self.tight_phrases: + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + * f_x_low = f_x_low - 1 # <<<<<<<<<<<<<< + * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: + * met_constraints = 0 + */ + __pyx_v_f_x_low = (__pyx_v_f_x_low - 1); + } + goto __pyx_L65; + } + __pyx_L65:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1607 + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + * f_x_low = f_x_low - 1 + * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: # <<<<<<<<<<<<<< + * met_constraints = 0 + * + */ + __pyx_t_18 = (__pyx_v_f_x_low < 0); + if (!__pyx_t_18) { + __pyx_t_7 = ((__pyx_v_f_back_high - __pyx_v_f_x_low) > __pyx_v_self->train_max_initial_size); + __pyx_t_9 = __pyx_t_7; + } else { + __pyx_t_9 = __pyx_t_18; + } + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1608 + * f_x_low = f_x_low - 1 + * if f_x_low < 0 or f_back_high - f_x_low > self.train_max_initial_size: + * met_constraints = 0 # <<<<<<<<<<<<<< + * + * if (met_constraints and + */ + __pyx_v_met_constraints = 0; + goto __pyx_L68; + } + __pyx_L68:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1610 + * met_constraints = 0 + * + * if (met_constraints and # <<<<<<<<<<<<<< + * self.find_fixpoint(f_x_low, f_back_high, + * f_links_low, f_links_high, e_links_low, e_links_high, + */ + if (__pyx_v_met_constraints) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1611 + * + * if (met_constraints and + * self.find_fixpoint(f_x_low, f_back_high, # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + */ + __pyx_t_14 = PyInt_FromLong(__pyx_v_f_back_high); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1611; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1615 + * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 1, 1, 1, 1, 0, 1, 0) and + * ((not self.tight_phrases) or f_links_low[f_x_low] != -1) and + */ + if (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_14, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 1, 0, 1, 0)) { + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1617 + * self.train_max_initial_size, self.train_max_initial_size, + * 1, 1, 1, 1, 0, 1, 0) and + * ((not self.tight_phrases) or f_links_low[f_x_low] != -1) and # <<<<<<<<<<<<<< + * self.find_fixpoint(f_x_low, f_low, # check integrity of new subphrase + * f_links_low, f_links_high, e_links_low, e_links_high, + */ + __pyx_t_9 = (!__pyx_v_self->tight_phrases); + if (!__pyx_t_9) { + __pyx_t_18 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) != -1); + __pyx_t_7 = __pyx_t_18; + } else { + __pyx_t_7 = __pyx_t_9; + } + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1618 + * 1, 1, 1, 1, 0, 1, 0) and + * ((not self.tight_phrases) or f_links_low[f_x_low] != -1) and + * self.find_fixpoint(f_x_low, f_low, # check integrity of new subphrase # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, + */ + __pyx_t_1 = PyInt_FromLong(__pyx_v_f_low); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1618; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1622 + * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() + */ + __pyx_t_9 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } else { + __pyx_t_9 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_9; + } else { + __pyx_t_7 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_14, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 1, 0, 1, 0); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + } + __pyx_t_9 = __pyx_t_7; + } else { + __pyx_t_9 = __pyx_v_met_constraints; + } + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1624 + * self.train_max_initial_size, self.train_max_initial_size, + * 0, 0, 0, 0, 0, 0, 0)): * fphr_arr._clear() # <<<<<<<<<<<<<< * i = 1 * self.findexes.reset() */ ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_clear(__pyx_v_fphr_arr); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1755 - * 0, 0, 0, 0, 0, 0, 0)): + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1625 + * 0, 0, 0, 0, 0, 0, 0)): * fphr_arr._clear() * i = 1 # <<<<<<<<<<<<<< * self.findexes.reset() @@ -53596,35 +53936,35 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj */ __pyx_v_i = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1756 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1626 * fphr_arr._clear() * i = 1 * self.findexes.reset() # <<<<<<<<<<<<<< * self.findexes.append(sym_setindex(self.category, i)) * fphr_arr._append(sym_setindex(self.category, i)) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_1 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1626; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_15 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1757 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1627 * i = 1 * self.findexes.reset() * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< * fphr_arr._append(sym_setindex(self.category, i)) * i = i+1 */ - __pyx_t_15 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_14 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1758 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1628 * self.findexes.reset() * self.findexes.append(sym_setindex(self.category, i)) * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< @@ -53633,7 +53973,7 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj */ ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1759 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1629 * self.findexes.append(sym_setindex(self.category, i)) * fphr_arr._append(sym_setindex(self.category, i)) * i = i+1 # <<<<<<<<<<<<<< @@ -53642,27 +53982,27 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj */ __pyx_v_i = (__pyx_v_i + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1760 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1630 * fphr_arr._append(sym_setindex(self.category, i)) * i = i+1 * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< * for j from 0 <= j < phrase.n: * if sym_isvar(phrase.syms[j]): */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); - PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_self->findexes1)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->findexes1)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); - __pyx_t_14 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1760; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __pyx_t_15 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1630; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1761 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1631 * i = i+1 * self.findexes.extend(self.findexes1) * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< @@ -53672,7 +54012,7 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj __pyx_t_3 = __pyx_v_phrase->n; for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1762 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1632 * self.findexes.extend(self.findexes1) * for j from 0 <= j < phrase.n: * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< @@ -53682,7 +54022,7 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1763 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1633 * for j from 0 <= j < phrase.n: * if sym_isvar(phrase.syms[j]): * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< @@ -53691,7 +54031,7 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj */ ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1764 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1634 * if sym_isvar(phrase.syms[j]): * fphr_arr._append(sym_setindex(self.category, i)) * i = i + 1 # <<<<<<<<<<<<<< @@ -53699,159 +54039,172 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj * fphr_arr._append(phrase.syms[j]) */ __pyx_v_i = (__pyx_v_i + 1); - goto __pyx_L106; + goto __pyx_L72; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1766 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1636 * i = i + 1 * else: * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) + * if f_back_high > f_high: + * fphr_arr._append(sym_setindex(self.category, i)) */ ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); } - __pyx_L106:; + __pyx_L72:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1767 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1637 * else: * fphr_arr._append(phrase.syms[j]) - * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< - * self.findexes.append(sym_setindex(self.category, i)) - * fphr = Phrase(fphr_arr) + * if f_back_high > f_high: # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) */ - ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + __pyx_t_9 = (__pyx_v_f_back_high > __pyx_v_f_high); + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1768 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1638 * fphr_arr._append(phrase.syms[j]) - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * if f_back_high > f_high: + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) * fphr = Phrase(fphr_arr) - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+2, */ - __pyx_t_14 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_15 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1768; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1769 - * fphr_arr._append(sym_setindex(self.category, i)) - * self.findexes.append(sym_setindex(self.category, i)) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1639 + * if f_back_high > f_high: + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * fphr = Phrase(fphr_arr) + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+1, + */ + __pyx_t_15 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1639; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1639; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L73; + } + __pyx_L73:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1640 + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+2, - * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+1, + * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, matching.sent_id, */ - __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); - PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_fphr_arr)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_fphr_arr)); __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); - __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1640; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_v_fphr)); - __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_14); - __pyx_t_14 = 0; + __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_15); + __pyx_t_15 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1772 - * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+2, - * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, - * matching.sent_id, e_sent_len, e_sent_start) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1643 + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+1, + * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, matching.sent_id, + * e_sent_len, e_sent_start) # <<<<<<<<<<<<<< * if len(phrase_list) > 0: * pair_count = 1.0 / len(phrase_list) */ - __pyx_t_14 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_x_low, __pyx_v_e_x_high, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_e_links_low, (__pyx_v_num_gaps + 2), __pyx_v_f_x_low, __pyx_v_f_x_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); + __pyx_t_15 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_x_low, __pyx_v_e_x_high, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_e_links_low, (__pyx_v_num_gaps + 1), __pyx_v_f_x_low, __pyx_v_f_x_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); __Pyx_XDECREF(__pyx_v_phrase_list); - __pyx_v_phrase_list = __pyx_t_14; - __pyx_t_14 = 0; + __pyx_v_phrase_list = __pyx_t_15; + __pyx_t_15 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1773 - * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, - * matching.sent_id, e_sent_len, e_sent_start) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1644 + * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, matching.sent_id, + * e_sent_len, e_sent_start) * if len(phrase_list) > 0: # <<<<<<<<<<<<<< * pair_count = 1.0 / len(phrase_list) * else: */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_8 = (__pyx_t_13 > 0); - if (__pyx_t_8) { + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = (__pyx_t_13 > 0); + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1774 - * matching.sent_id, e_sent_len, e_sent_start) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1645 + * e_sent_len, e_sent_start) * if len(phrase_list) > 0: * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< * else: * pair_count = 0 */ - __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (unlikely(__pyx_t_13 == 0)) { PyErr_Format(PyExc_ZeroDivisionError, "float division"); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1645; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_v_pair_count = (1.0 / __pyx_t_13); - goto __pyx_L107; + goto __pyx_L74; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1776 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1647 * pair_count = 1.0 / len(phrase_list) * else: * pair_count = 0 # <<<<<<<<<<<<<< - * for phrase2, eindexes in phrase_list: - * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * for phrase2,eindexes in phrase_list: + * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) */ __pyx_v_pair_count = 0.0; } - __pyx_L107:; + __pyx_L74:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1777 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1648 * else: * pair_count = 0 - * for phrase2, eindexes in phrase_list: # <<<<<<<<<<<<<< - * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als4))) + * for phrase2,eindexes in phrase_list: # <<<<<<<<<<<<<< + * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als2))) */ if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { - __pyx_t_14 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_14); __pyx_t_13 = 0; + __pyx_t_15 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_15); __pyx_t_13 = 0; __pyx_t_16 = NULL; } else { - __pyx_t_13 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_14); - __pyx_t_16 = Py_TYPE(__pyx_t_14)->tp_iternext; + __pyx_t_13 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_16 = Py_TYPE(__pyx_t_15)->tp_iternext; } for (;;) { - if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_14)) { - if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_14)) break; + if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_15)) { + if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_15)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_15 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_15, __pyx_t_13); __Pyx_INCREF(__pyx_t_1); __pyx_t_13++; #else - __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_15, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif - } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_14)) { - if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_14)) break; + } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_15)) { + if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_15)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_13); __Pyx_INCREF(__pyx_t_1); __pyx_t_13++; #else - __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_15, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; #endif } else { - __pyx_t_15 = __pyx_t_16(__pyx_t_14); - if (unlikely(!__pyx_t_15)) { + __pyx_t_1 = __pyx_t_16(__pyx_t_15); + if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } - __Pyx_GOTREF(__pyx_t_15); + __Pyx_GOTREF(__pyx_t_1); } - if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) { - PyObject* sequence = __pyx_t_15; + if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { + PyObject* sequence = __pyx_t_1; #if CYTHON_COMPILING_IN_CPYTHON Py_ssize_t size = Py_SIZE(sequence); #else @@ -53860,313 +54213,3621 @@ static PyObject *__pyx_f_3_sa_23HieroCachingRuleFactory_extract(struct __pyx_obj if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_14 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); } else { - __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_14 = PyList_GET_ITEM(sequence, 0); __pyx_t_2 = PyList_GET_ITEM(sequence, 1); } - __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_14); __Pyx_INCREF(__pyx_t_2); #else - __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_14 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } else { Py_ssize_t index = -1; - __pyx_t_10 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; - index = 0; __pyx_t_1 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L110_unpacking_failed; - __Pyx_GOTREF(__pyx_t_1); - index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L110_unpacking_failed; + index = 0; __pyx_t_14 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_14)) goto __pyx_L77_unpacking_failed; + __Pyx_GOTREF(__pyx_t_14); + index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L77_unpacking_failed; __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_17 = NULL; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; - goto __pyx_L111_unpacking_done; - __pyx_L110_unpacking_failed:; + goto __pyx_L78_unpacking_done; + __pyx_L77_unpacking_failed:; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_17 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_L111_unpacking_done:; + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1648; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L78_unpacking_done:; } __Pyx_XDECREF(__pyx_v_phrase2); - __pyx_v_phrase2 = __pyx_t_1; - __pyx_t_1 = 0; + __pyx_v_phrase2 = __pyx_t_14; + __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_v_eindexes); __pyx_v_eindexes = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1778 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1649 * pair_count = 0 - * for phrase2, eindexes in phrase_list: - * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< - * extracts.append((fphr, phrase2, pair_count, tuple(als4))) - * else: + * for phrase2,eindexes in phrase_list: + * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< + * extracts.append((fphr, phrase2, pair_count, tuple(als2))) + * */ - __pyx_t_15 = ((PyObject *)__pyx_v_self->findexes); - __Pyx_INCREF(__pyx_t_15); - __pyx_t_2 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_15, __pyx_v_eindexes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1778; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = ((PyObject *)__pyx_v_self->findexes); + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_1, __pyx_v_eindexes)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1649; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; - __Pyx_XDECREF(__pyx_v_als4); - __pyx_v_als4 = __pyx_t_2; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_als2)); + __pyx_v_als2 = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1779 - * for phrase2, eindexes in phrase_list: - * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) - * extracts.append((fphr, phrase2, pair_count, tuple(als4))) # <<<<<<<<<<<<<< - * else: - * reason_for_failure = "Unable to extract basic phrase" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1650 + * for phrase2,eindexes in phrase_list: + * als2 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als2))) # <<<<<<<<<<<<<< + * + * if (f_back_high == f_high and */ - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); - __Pyx_INCREF(__pyx_v_als4); - PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_als4); - __Pyx_GIVEREF(__pyx_v_als4); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_v_als2)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_als2)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_als2)); + __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_15); __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); - PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_fphr)); + PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_fphr)); __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); __Pyx_INCREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_phrase2); __Pyx_GIVEREF(__pyx_v_phrase2); - PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_14); + __Pyx_GIVEREF(__pyx_t_14); __pyx_t_2 = 0; - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1779; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_14 = 0; + __pyx_t_14 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1650; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; } - __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; - goto __pyx_L103; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + goto __pyx_L69; } - __pyx_L103:; - goto __pyx_L94; + __pyx_L69:; + goto __pyx_L64; } - __pyx_L94:; - goto __pyx_L63; - } - __pyx_L63:; - goto __pyx_L51; - } - __pyx_L51:; - goto __pyx_L34; - } - /*else*/ { + __pyx_L64:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1781 - * extracts.append((fphr, phrase2, pair_count, tuple(als4))) - * else: - * reason_for_failure = "Unable to extract basic phrase" # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1652 + * extracts.append((fphr, phrase2, pair_count, tuple(als2))) * - * free(sent_links) + * if (f_back_high == f_high and # <<<<<<<<<<<<<< + * f_sent_len - f_high >= self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_133)); - __Pyx_DECREF(__pyx_v_reason_for_failure); - __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_133); - } - __pyx_L34:; - goto __pyx_L33; - } - __pyx_L33:; + __pyx_t_9 = (__pyx_v_f_back_high == __pyx_v_f_high); + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1783 - * reason_for_failure = "Unable to extract basic phrase" + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1653 * - * free(sent_links) # <<<<<<<<<<<<<< - * free(f_links_low) - * free(f_links_high) + * if (f_back_high == f_high and + * f_sent_len - f_high >= self.train_min_gap_size and # <<<<<<<<<<<<<< + * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): + * f_x_high = f_high+self.train_min_gap_size */ - free(__pyx_v_sent_links); + __pyx_t_7 = ((__pyx_v_f_sent_len - __pyx_v_f_high) >= __pyx_v_self->train_min_gap_size); + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1784 - * - * free(sent_links) - * free(f_links_low) # <<<<<<<<<<<<<< - * free(f_links_high) - * free(e_links_low) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1654 + * if (f_back_high == f_high and + * f_sent_len - f_high >= self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): # <<<<<<<<<<<<<< + * f_x_high = f_high+self.train_min_gap_size + * met_constraints = 1 */ - free(__pyx_v_f_links_low); + __pyx_t_18 = (!__pyx_v_self->tight_phrases); + if (!__pyx_t_18) { + __pyx_t_8 = ((__pyx_v_f_links_low[__pyx_v_f_high]) != -1); + if (__pyx_t_8) { + __pyx_t_20 = ((__pyx_v_f_links_low[__pyx_v_f_back_low]) != -1); + __pyx_t_19 = __pyx_t_20; + } else { + __pyx_t_19 = __pyx_t_8; + } + __pyx_t_8 = __pyx_t_19; + } else { + __pyx_t_8 = __pyx_t_18; + } + __pyx_t_18 = __pyx_t_8; + } else { + __pyx_t_18 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_18; + } else { + __pyx_t_7 = __pyx_t_9; + } + if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1785 - * free(sent_links) - * free(f_links_low) - * free(f_links_high) # <<<<<<<<<<<<<< - * free(e_links_low) - * free(e_links_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1655 + * f_sent_len - f_high >= self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): + * f_x_high = f_high+self.train_min_gap_size # <<<<<<<<<<<<<< + * met_constraints = 1 + * if self.tight_phrases: */ - free(__pyx_v_f_links_high); + __pyx_v_f_x_high = (__pyx_v_f_high + __pyx_v_self->train_min_gap_size); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1786 - * free(f_links_low) - * free(f_links_high) - * free(e_links_low) # <<<<<<<<<<<<<< - * free(e_links_high) - * free(f_gap_low) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1656 + * ((not self.tight_phrases) or (f_links_low[f_high] != -1 and f_links_low[f_back_low] != -1))): + * f_x_high = f_high+self.train_min_gap_size + * met_constraints = 1 # <<<<<<<<<<<<<< + * if self.tight_phrases: + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: */ - free(__pyx_v_e_links_low); + __pyx_v_met_constraints = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1787 - * free(f_links_high) - * free(e_links_low) - * free(e_links_high) # <<<<<<<<<<<<<< - * free(f_gap_low) - * free(f_gap_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1657 + * f_x_high = f_high+self.train_min_gap_size + * met_constraints = 1 + * if self.tight_phrases: # <<<<<<<<<<<<<< + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + * f_x_high = f_x_high + 1 */ - free(__pyx_v_e_links_high); + if (__pyx_v_self->tight_phrases) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1788 - * free(e_links_low) - * free(e_links_high) - * free(f_gap_low) # <<<<<<<<<<<<<< - * free(f_gap_high) - * free(e_gap_low) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1658 + * met_constraints = 1 + * if self.tight_phrases: + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: # <<<<<<<<<<<<<< + * f_x_high = f_x_high + 1 + * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: */ - free(__pyx_v_f_gap_low); + while (1) { + __pyx_t_7 = (__pyx_v_f_x_high <= __pyx_v_f_sent_len); + if (__pyx_t_7) { + __pyx_t_9 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) == -1); + __pyx_t_18 = __pyx_t_9; + } else { + __pyx_t_18 = __pyx_t_7; + } + if (!__pyx_t_18) break; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1789 - * free(e_links_high) - * free(f_gap_low) - * free(f_gap_high) # <<<<<<<<<<<<<< - * free(e_gap_low) - * free(e_gap_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1659 + * if self.tight_phrases: + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + * f_x_high = f_x_high + 1 # <<<<<<<<<<<<<< + * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: + * met_constraints = 0 */ - free(__pyx_v_f_gap_high); + __pyx_v_f_x_high = (__pyx_v_f_x_high + 1); + } + goto __pyx_L80; + } + __pyx_L80:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1790 - * free(f_gap_low) - * free(f_gap_high) - * free(e_gap_low) # <<<<<<<<<<<<<< - * free(e_gap_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1660 + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + * f_x_high = f_x_high + 1 + * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: # <<<<<<<<<<<<<< + * met_constraints = 0 * */ - free(__pyx_v_e_gap_low); + __pyx_t_18 = (__pyx_v_f_x_high > __pyx_v_f_sent_len); + if (!__pyx_t_18) { + __pyx_t_7 = ((__pyx_v_f_x_high - __pyx_v_f_back_low) > __pyx_v_self->train_max_initial_size); + __pyx_t_9 = __pyx_t_7; + } else { + __pyx_t_9 = __pyx_t_18; + } + if (__pyx_t_9) { - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1791 - * free(f_gap_high) - * free(e_gap_low) - * free(e_gap_high) # <<<<<<<<<<<<<< + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1661 + * f_x_high = f_x_high + 1 + * if f_x_high > f_sent_len or f_x_high - f_back_low > self.train_max_initial_size: + * met_constraints = 0 # <<<<<<<<<<<<<< * - * return extracts + * if (met_constraints and */ - free(__pyx_v_e_gap_high); + __pyx_v_met_constraints = 0; + goto __pyx_L83; + } + __pyx_L83:; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1793 - * free(e_gap_high) + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1663 + * met_constraints = 0 * - * return extracts # <<<<<<<<<<<<<< + * if (met_constraints and # <<<<<<<<<<<<<< + * self.find_fixpoint(f_back_low, f_x_high, + * f_links_low, f_links_high, e_links_low, e_links_high, */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_extracts); - __pyx_r = __pyx_v_extracts; - goto __pyx_L0; + if (__pyx_v_met_constraints) { - __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_10); - __Pyx_XDECREF(__pyx_t_14); - __Pyx_XDECREF(__pyx_t_15); - __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.extract", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_extracts); - __Pyx_XDECREF(__pyx_v_phrase_list); - __Pyx_XDECREF((PyObject *)__pyx_v_fphr_arr); - __Pyx_XDECREF((PyObject *)__pyx_v_fphr); - __Pyx_XDECREF(__pyx_v_reason_for_failure); - __Pyx_XDECREF(__pyx_v_sofar); - __Pyx_XDECREF(__pyx_v_als); - __Pyx_XDECREF(__pyx_v_al); - __Pyx_XDECREF(__pyx_v_phrase2); - __Pyx_XDECREF(__pyx_v_eindexes); - __Pyx_XDECREF(__pyx_v_als1); - __Pyx_XDECREF(__pyx_v_als2); - __Pyx_XDECREF(__pyx_v_als3); - __Pyx_XDECREF(__pyx_v_als4); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_3_sa_Phrase __pyx_vtable_3_sa_Phrase; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1664 + * + * if (met_constraints and + * self.find_fixpoint(f_back_low, f_x_high, # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + */ + __pyx_t_15 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1668 + * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 1, 1, 1, 0, 1, 1, 0) and + * ((not self.tight_phrases) or f_links_low[f_x_high-1] != -1) and + */ + if (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_back_low, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 0, 1, 1, 0)) { + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1670 + * self.train_max_initial_size, self.train_max_initial_size, + * 1, 1, 1, 0, 1, 1, 0) and + * ((not self.tight_phrases) or f_links_low[f_x_high-1] != -1) and # <<<<<<<<<<<<<< + * self.find_fixpoint(f_high, f_x_high, + * f_links_low, f_links_high, e_links_low, e_links_high, + */ + __pyx_t_9 = (!__pyx_v_self->tight_phrases); + if (!__pyx_t_9) { + __pyx_t_18 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) != -1); + __pyx_t_7 = __pyx_t_18; + } else { + __pyx_t_7 = __pyx_t_9; + } + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1671 + * 1, 1, 1, 0, 1, 1, 0) and + * ((not self.tight_phrases) or f_links_low[f_x_high-1] != -1) and + * self.find_fixpoint(f_high, f_x_high, # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * -1, -1, e_gap_low+gap_start+num_gaps, e_gap_high+gap_start+num_gaps, + */ + __pyx_t_14 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1671; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1676 + * f_gap_low+gap_start+num_gaps, f_gap_high+gap_start+num_gaps, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() + */ + __pyx_t_9 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_high, __pyx_t_14, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, ((__pyx_v_e_gap_low + __pyx_v_gap_start) + __pyx_v_num_gaps), ((__pyx_v_e_gap_high + __pyx_v_gap_start) + __pyx_v_num_gaps), ((__pyx_v_f_gap_low + __pyx_v_gap_start) + __pyx_v_num_gaps), ((__pyx_v_f_gap_high + __pyx_v_gap_start) + __pyx_v_num_gaps), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + } else { + __pyx_t_9 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_9; + } else { + __pyx_t_7 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_back_low, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 1, 0, 1, 1, 0); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } + __pyx_t_9 = __pyx_t_7; + } else { + __pyx_t_9 = __pyx_v_met_constraints; + } + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1678 + * self.train_max_initial_size, self.train_max_initial_size, + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() # <<<<<<<<<<<<<< + * i = 1 + * self.findexes.reset() + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_clear(__pyx_v_fphr_arr); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1679 + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() + * i = 1 # <<<<<<<<<<<<<< + * self.findexes.reset() + * if f_back_low < f_low: + */ + __pyx_v_i = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1680 + * fphr_arr._clear() + * i = 1 + * self.findexes.reset() # <<<<<<<<<<<<<< + * if f_back_low < f_low: + * fphr_arr._append(sym_setindex(self.category, i)) + */ + __pyx_t_15 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_14 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1681 + * i = 1 + * self.findexes.reset() + * if f_back_low < f_low: # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 + */ + __pyx_t_9 = (__pyx_v_f_back_low < __pyx_v_f_low); + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1682 + * self.findexes.reset() + * if f_back_low < f_low: + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * i = i+1 + * self.findexes.append(sym_setindex(self.category, i)) + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1683 + * if f_back_low < f_low: + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) + * self.findexes.extend(self.findexes1) + */ + __pyx_v_i = (__pyx_v_i + 1); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1684 + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: + */ + __pyx_t_14 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_15 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + goto __pyx_L85; + } + __pyx_L85:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1685 + * i = i+1 + * self.findexes.append(sym_setindex(self.category, i)) + * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): + */ + __pyx_t_15 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); + PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_self->findexes1)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); + __pyx_t_1 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1685; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1686 + * self.findexes.append(sym_setindex(self.category, i)) + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) + */ + __pyx_t_3 = __pyx_v_phrase->n; + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1687 + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i + 1 + */ + __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); + if (__pyx_t_4) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1688 + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * i = i + 1 + * else: + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1689 + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i + 1 # <<<<<<<<<<<<<< + * else: + * fphr_arr._append(phrase.syms[j]) + */ + __pyx_v_i = (__pyx_v_i + 1); + goto __pyx_L88; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1691 + * i = i + 1 + * else: + * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); + } + __pyx_L88:; + } + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1692 + * else: + * fphr_arr._append(phrase.syms[j]) + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) + * fphr = Phrase(fphr_arr) + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1693 + * fphr_arr._append(phrase.syms[j]) + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * fphr = Phrase(fphr_arr) + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low+gap_start, e_gap_high+gap_start, e_links_low, num_gaps+1, + */ + __pyx_t_1 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_14 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1693; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1694 + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) + * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low+gap_start, e_gap_high+gap_start, e_links_low, num_gaps+1, + * f_x_low, f_x_high, f_gap_low+gap_start, f_gap_high+gap_start, f_links_low, + */ + __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1694; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); + PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_fphr_arr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1694; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_fphr)); + __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1697 + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low+gap_start, e_gap_high+gap_start, e_links_low, num_gaps+1, + * f_x_low, f_x_high, f_gap_low+gap_start, f_gap_high+gap_start, f_links_low, + * matching.sent_id, e_sent_len, e_sent_start) # <<<<<<<<<<<<<< + * if len(phrase_list) > 0: + * pair_count = 1.0 / len(phrase_list) + */ + __pyx_t_1 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_x_low, __pyx_v_e_x_high, (__pyx_v_e_gap_low + __pyx_v_gap_start), (__pyx_v_e_gap_high + __pyx_v_gap_start), __pyx_v_e_links_low, (__pyx_v_num_gaps + 1), __pyx_v_f_x_low, __pyx_v_f_x_high, (__pyx_v_f_gap_low + __pyx_v_gap_start), (__pyx_v_f_gap_high + __pyx_v_gap_start), __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1695; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_v_phrase_list); + __pyx_v_phrase_list = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1698 + * f_x_low, f_x_high, f_gap_low+gap_start, f_gap_high+gap_start, f_links_low, + * matching.sent_id, e_sent_len, e_sent_start) + * if len(phrase_list) > 0: # <<<<<<<<<<<<<< + * pair_count = 1.0 / len(phrase_list) + * else: + */ + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1698; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = (__pyx_t_13 > 0); + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1699 + * matching.sent_id, e_sent_len, e_sent_start) + * if len(phrase_list) > 0: + * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< + * else: + * pair_count = 0 + */ + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_13 == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_pair_count = (1.0 / __pyx_t_13); + goto __pyx_L89; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1701 + * pair_count = 1.0 / len(phrase_list) + * else: + * pair_count = 0 # <<<<<<<<<<<<<< + * for phrase2, eindexes in phrase_list: + * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + */ + __pyx_v_pair_count = 0.0; + } + __pyx_L89:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1702 + * else: + * pair_count = 0 + * for phrase2, eindexes in phrase_list: # <<<<<<<<<<<<<< + * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als3))) + */ + if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { + __pyx_t_1 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_1); __pyx_t_13 = 0; + __pyx_t_16 = NULL; + } else { + __pyx_t_13 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_16 = Py_TYPE(__pyx_t_1)->tp_iternext; + } + for (;;) { + if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_14 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_14); __pyx_t_13++; + #else + __pyx_t_14 = PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_14 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_13); __Pyx_INCREF(__pyx_t_14); __pyx_t_13++; + #else + __pyx_t_14 = PySequence_ITEM(__pyx_t_1, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_14 = __pyx_t_16(__pyx_t_1); + if (unlikely(!__pyx_t_14)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_14); + } + if ((likely(PyTuple_CheckExact(__pyx_t_14))) || (PyList_CheckExact(__pyx_t_14))) { + PyObject* sequence = __pyx_t_14; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_15 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_15 = PyList_GET_ITEM(sequence, 0); + __pyx_t_2 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_15); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_15 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_10 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; + index = 0; __pyx_t_15 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_15)) goto __pyx_L92_unpacking_failed; + __Pyx_GOTREF(__pyx_t_15); + index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L92_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = NULL; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L93_unpacking_done; + __pyx_L92_unpacking_failed:; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_17 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1702; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L93_unpacking_done:; + } + __Pyx_XDECREF(__pyx_v_phrase2); + __pyx_v_phrase2 = __pyx_t_15; + __pyx_t_15 = 0; + __Pyx_XDECREF(__pyx_v_eindexes); + __pyx_v_eindexes = __pyx_t_2; + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1703 + * pair_count = 0 + * for phrase2, eindexes in phrase_list: + * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< + * extracts.append((fphr, phrase2, pair_count, tuple(als3))) + * if (num_gaps < self.max_nonterminals - 1 and + */ + __pyx_t_14 = ((PyObject *)__pyx_v_self->findexes); + __Pyx_INCREF(__pyx_t_14); + __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_14, __pyx_v_eindexes)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1703; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_als3)); + __pyx_v_als3 = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1704 + * for phrase2, eindexes in phrase_list: + * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als3))) # <<<<<<<<<<<<<< + * if (num_gaps < self.max_nonterminals - 1 and + * phrase_len+1 < self.max_length and + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_INCREF(((PyObject *)__pyx_v_als3)); + PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_als3)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_als3)); + __pyx_t_15 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; + __pyx_t_14 = PyTuple_New(4); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); + PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_v_fphr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); + __Pyx_INCREF(__pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_v_phrase2); + __Pyx_GIVEREF(__pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_15); + __Pyx_GIVEREF(__pyx_t_15); + __pyx_t_2 = 0; + __pyx_t_15 = 0; + __pyx_t_15 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_14)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + goto __pyx_L84; + } + __pyx_L84:; + goto __pyx_L79; + } + __pyx_L79:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1705 + * als3 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als3))) + * if (num_gaps < self.max_nonterminals - 1 and # <<<<<<<<<<<<<< + * phrase_len+1 < self.max_length and + * f_back_high == f_high and + */ + __pyx_t_9 = (__pyx_v_num_gaps < (__pyx_v_self->max_nonterminals - 1)); + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1706 + * extracts.append((fphr, phrase2, pair_count, tuple(als3))) + * if (num_gaps < self.max_nonterminals - 1 and + * phrase_len+1 < self.max_length and # <<<<<<<<<<<<<< + * f_back_high == f_high and + * f_back_low == f_low and + */ + __pyx_t_7 = ((__pyx_v_phrase_len + 1) < __pyx_v_self->max_length); + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1707 + * if (num_gaps < self.max_nonterminals - 1 and + * phrase_len+1 < self.max_length and + * f_back_high == f_high and # <<<<<<<<<<<<<< + * f_back_low == f_low and + * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and + */ + __pyx_t_18 = (__pyx_v_f_back_high == __pyx_v_f_high); + if (__pyx_t_18) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1708 + * phrase_len+1 < self.max_length and + * f_back_high == f_high and + * f_back_low == f_low and # <<<<<<<<<<<<<< + * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and + * f_low >= self.train_min_gap_size and + */ + __pyx_t_8 = (__pyx_v_f_back_low == __pyx_v_f_low); + if (__pyx_t_8) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1709 + * f_back_high == f_high and + * f_back_low == f_low and + * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and # <<<<<<<<<<<<<< + * f_low >= self.train_min_gap_size and + * f_high <= f_sent_len - self.train_min_gap_size and + */ + __pyx_t_19 = (((__pyx_v_f_back_high - __pyx_v_f_back_low) + (2 * __pyx_v_self->train_min_gap_size)) <= __pyx_v_self->train_max_initial_size); + if (__pyx_t_19) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1710 + * f_back_low == f_low and + * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and + * f_low >= self.train_min_gap_size and # <<<<<<<<<<<<<< + * f_high <= f_sent_len - self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): + */ + __pyx_t_20 = (__pyx_v_f_low >= __pyx_v_self->train_min_gap_size); + if (__pyx_t_20) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1711 + * f_back_high - f_back_low + (2*self.train_min_gap_size) <= self.train_max_initial_size and + * f_low >= self.train_min_gap_size and + * f_high <= f_sent_len - self.train_min_gap_size and # <<<<<<<<<<<<<< + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): + * + */ + __pyx_t_21 = (__pyx_v_f_high <= (__pyx_v_f_sent_len - __pyx_v_self->train_min_gap_size)); + if (__pyx_t_21) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1712 + * f_low >= self.train_min_gap_size and + * f_high <= f_sent_len - self.train_min_gap_size and + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): # <<<<<<<<<<<<<< + * + * met_constraints = 1 + */ + __pyx_t_22 = (!__pyx_v_self->tight_phrases); + if (!__pyx_t_22) { + __pyx_t_23 = ((__pyx_v_f_links_low[(__pyx_v_f_low - 1)]) != -1); + if (__pyx_t_23) { + __pyx_t_24 = ((__pyx_v_f_links_low[__pyx_v_f_high]) != -1); + __pyx_t_25 = __pyx_t_24; + } else { + __pyx_t_25 = __pyx_t_23; + } + __pyx_t_23 = __pyx_t_25; + } else { + __pyx_t_23 = __pyx_t_22; + } + __pyx_t_22 = __pyx_t_23; + } else { + __pyx_t_22 = __pyx_t_21; + } + __pyx_t_21 = __pyx_t_22; + } else { + __pyx_t_21 = __pyx_t_20; + } + __pyx_t_20 = __pyx_t_21; + } else { + __pyx_t_20 = __pyx_t_19; + } + __pyx_t_19 = __pyx_t_20; + } else { + __pyx_t_19 = __pyx_t_8; + } + __pyx_t_8 = __pyx_t_19; + } else { + __pyx_t_8 = __pyx_t_18; + } + __pyx_t_18 = __pyx_t_8; + } else { + __pyx_t_18 = __pyx_t_7; + } + __pyx_t_7 = __pyx_t_18; + } else { + __pyx_t_7 = __pyx_t_9; + } + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1714 + * ((not self.tight_phrases) or (f_links_low[f_low-1] != -1 and f_links_low[f_high] != -1))): + * + * met_constraints = 1 # <<<<<<<<<<<<<< + * f_x_low = f_low-self.train_min_gap_size + * if self.tight_phrases: + */ + __pyx_v_met_constraints = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1715 + * + * met_constraints = 1 + * f_x_low = f_low-self.train_min_gap_size # <<<<<<<<<<<<<< + * if self.tight_phrases: + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + */ + __pyx_v_f_x_low = (__pyx_v_f_low - __pyx_v_self->train_min_gap_size); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1716 + * met_constraints = 1 + * f_x_low = f_low-self.train_min_gap_size + * if self.tight_phrases: # <<<<<<<<<<<<<< + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + * f_x_low = f_x_low - 1 + */ + if (__pyx_v_self->tight_phrases) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1717 + * f_x_low = f_low-self.train_min_gap_size + * if self.tight_phrases: + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: # <<<<<<<<<<<<<< + * f_x_low = f_x_low - 1 + * if f_x_low < 0: + */ + while (1) { + __pyx_t_7 = (__pyx_v_f_x_low >= 0); + if (__pyx_t_7) { + __pyx_t_9 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) == -1); + __pyx_t_18 = __pyx_t_9; + } else { + __pyx_t_18 = __pyx_t_7; + } + if (!__pyx_t_18) break; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1718 + * if self.tight_phrases: + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + * f_x_low = f_x_low - 1 # <<<<<<<<<<<<<< + * if f_x_low < 0: + * met_constraints = 0 + */ + __pyx_v_f_x_low = (__pyx_v_f_x_low - 1); + } + goto __pyx_L95; + } + __pyx_L95:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1719 + * while f_x_low >= 0 and f_links_low[f_x_low] == -1: + * f_x_low = f_x_low - 1 + * if f_x_low < 0: # <<<<<<<<<<<<<< + * met_constraints = 0 + * + */ + __pyx_t_18 = (__pyx_v_f_x_low < 0); + if (__pyx_t_18) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1720 + * f_x_low = f_x_low - 1 + * if f_x_low < 0: + * met_constraints = 0 # <<<<<<<<<<<<<< + * + * f_x_high = f_high+self.train_min_gap_size + */ + __pyx_v_met_constraints = 0; + goto __pyx_L98; + } + __pyx_L98:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1722 + * met_constraints = 0 + * + * f_x_high = f_high+self.train_min_gap_size # <<<<<<<<<<<<<< + * if self.tight_phrases: + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + */ + __pyx_v_f_x_high = (__pyx_v_f_high + __pyx_v_self->train_min_gap_size); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1723 + * + * f_x_high = f_high+self.train_min_gap_size + * if self.tight_phrases: # <<<<<<<<<<<<<< + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + * f_x_high = f_x_high + 1 + */ + if (__pyx_v_self->tight_phrases) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1724 + * f_x_high = f_high+self.train_min_gap_size + * if self.tight_phrases: + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: # <<<<<<<<<<<<<< + * f_x_high = f_x_high + 1 + * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: + */ + while (1) { + __pyx_t_18 = (__pyx_v_f_x_high <= __pyx_v_f_sent_len); + if (__pyx_t_18) { + __pyx_t_7 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) == -1); + __pyx_t_9 = __pyx_t_7; + } else { + __pyx_t_9 = __pyx_t_18; + } + if (!__pyx_t_9) break; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1725 + * if self.tight_phrases: + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + * f_x_high = f_x_high + 1 # <<<<<<<<<<<<<< + * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: + * met_constraints = 0 + */ + __pyx_v_f_x_high = (__pyx_v_f_x_high + 1); + } + goto __pyx_L99; + } + __pyx_L99:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1726 + * while f_x_high <= f_sent_len and f_links_low[f_x_high-1] == -1: + * f_x_high = f_x_high + 1 + * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: # <<<<<<<<<<<<<< + * met_constraints = 0 + * + */ + __pyx_t_9 = (__pyx_v_f_x_high > __pyx_v_f_sent_len); + if (!__pyx_t_9) { + __pyx_t_18 = ((__pyx_v_f_x_high - __pyx_v_f_x_low) > __pyx_v_self->train_max_initial_size); + __pyx_t_7 = __pyx_t_18; + } else { + __pyx_t_7 = __pyx_t_9; + } + if (__pyx_t_7) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1727 + * f_x_high = f_x_high + 1 + * if f_x_high > f_sent_len or f_x_high - f_x_low > self.train_max_initial_size: + * met_constraints = 0 # <<<<<<<<<<<<<< + * + * if (met_constraints and + */ + __pyx_v_met_constraints = 0; + goto __pyx_L102; + } + __pyx_L102:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1729 + * met_constraints = 0 + * + * if (met_constraints and # <<<<<<<<<<<<<< + * self.find_fixpoint(f_x_low, f_x_high, + * f_links_low, f_links_high, e_links_low, e_links_high, + */ + if (__pyx_v_met_constraints) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1730 + * + * if (met_constraints and + * self.find_fixpoint(f_x_low, f_x_high, # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + */ + __pyx_t_1 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1734 + * e_low, e_high, &e_x_low, &e_x_high, &f_x_low, &f_x_high, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 1, 1, 2, 1, 1, 1, 1) and + * ((not self.tight_phrases) or (f_links_low[f_x_low] != -1 and f_links_low[f_x_high-1] != -1)) and + */ + if (((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 2, 1, 1, 1, 1)) { + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1736 + * self.train_max_initial_size, self.train_max_initial_size, + * 1, 1, 2, 1, 1, 1, 1) and + * ((not self.tight_phrases) or (f_links_low[f_x_low] != -1 and f_links_low[f_x_high-1] != -1)) and # <<<<<<<<<<<<<< + * self.find_fixpoint(f_x_low, f_low, + * f_links_low, f_links_high, e_links_low, e_links_high, + */ + __pyx_t_7 = (!__pyx_v_self->tight_phrases); + if (!__pyx_t_7) { + __pyx_t_9 = ((__pyx_v_f_links_low[__pyx_v_f_x_low]) != -1); + if (__pyx_t_9) { + __pyx_t_18 = ((__pyx_v_f_links_low[(__pyx_v_f_x_high - 1)]) != -1); + __pyx_t_8 = __pyx_t_18; + } else { + __pyx_t_8 = __pyx_t_9; + } + __pyx_t_9 = __pyx_t_8; + } else { + __pyx_t_9 = __pyx_t_7; + } + if (__pyx_t_9) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1737 + * 1, 1, 2, 1, 1, 1, 1) and + * ((not self.tight_phrases) or (f_links_low[f_x_low] != -1 and f_links_low[f_x_high-1] != -1)) and + * self.find_fixpoint(f_x_low, f_low, # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, + */ + __pyx_t_15 = PyInt_FromLong(__pyx_v_f_low); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1741 + * -1, -1, e_gap_low, e_gap_high, f_gap_low, f_gap_high, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 0, 0, 0, 0, 0, 0, 0) and + * self.find_fixpoint(f_high, f_x_high, + */ + __pyx_t_3 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + if (__pyx_t_3) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1743 + * self.train_max_initial_size, self.train_max_initial_size, + * 0, 0, 0, 0, 0, 0, 0) and + * self.find_fixpoint(f_high, f_x_high, # <<<<<<<<<<<<<< + * f_links_low, f_links_high, e_links_low, e_links_high, + * -1, -1, e_gap_low+1+num_gaps, e_gap_high+1+num_gaps, + */ + __pyx_t_15 = PyInt_FromLong(__pyx_v_f_x_high); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1743; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1748 + * f_gap_low+1+num_gaps, f_gap_high+1+num_gaps, + * f_sent_len, e_sent_len, + * self.train_max_initial_size, self.train_max_initial_size, # <<<<<<<<<<<<<< + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() + */ + __pyx_t_4 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_high, __pyx_t_15, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, -1, -1, ((__pyx_v_e_gap_low + 1) + __pyx_v_num_gaps), ((__pyx_v_e_gap_high + 1) + __pyx_v_num_gaps), ((__pyx_v_f_gap_low + 1) + __pyx_v_num_gaps), ((__pyx_v_f_gap_high + 1) + __pyx_v_num_gaps), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 0, 0, 0, 0, 0, 0, 0); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_7 = __pyx_t_4; + } else { + __pyx_t_7 = __pyx_t_3; + } + __pyx_t_8 = __pyx_t_7; + } else { + __pyx_t_8 = __pyx_t_9; + } + __pyx_t_9 = __pyx_t_8; + } else { + __pyx_t_9 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->find_fixpoint(__pyx_v_self, __pyx_v_f_x_low, __pyx_t_1, __pyx_v_f_links_low, __pyx_v_f_links_high, __pyx_v_e_links_low, __pyx_v_e_links_high, __pyx_v_e_low, __pyx_v_e_high, (&__pyx_v_e_x_low), (&__pyx_v_e_x_high), (&__pyx_v_f_x_low), (&__pyx_v_f_x_high), __pyx_v_f_sent_len, __pyx_v_e_sent_len, __pyx_v_self->train_max_initial_size, __pyx_v_self->train_max_initial_size, 1, 1, 2, 1, 1, 1, 1); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __pyx_t_8 = __pyx_t_9; + } else { + __pyx_t_8 = __pyx_v_met_constraints; + } + if (__pyx_t_8) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1750 + * self.train_max_initial_size, self.train_max_initial_size, + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() # <<<<<<<<<<<<<< + * i = 1 + * self.findexes.reset() + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_clear(__pyx_v_fphr_arr); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1751 + * 0, 0, 0, 0, 0, 0, 0)): + * fphr_arr._clear() + * i = 1 # <<<<<<<<<<<<<< + * self.findexes.reset() + * self.findexes.append(sym_setindex(self.category, i)) + */ + __pyx_v_i = 1; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1752 + * fphr_arr._clear() + * i = 1 + * self.findexes.reset() # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) + * fphr_arr._append(sym_setindex(self.category, i)) + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__reset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_15 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1752; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1753 + * i = 1 + * self.findexes.reset() + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 + */ + __pyx_t_15 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __pyx_t_1 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_15); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1754 + * self.findexes.reset() + * self.findexes.append(sym_setindex(self.category, i)) + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * i = i+1 + * self.findexes.extend(self.findexes1) + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1755 + * self.findexes.append(sym_setindex(self.category, i)) + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 # <<<<<<<<<<<<<< + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: + */ + __pyx_v_i = (__pyx_v_i + 1); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1756 + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i+1 + * self.findexes.extend(self.findexes1) # <<<<<<<<<<<<<< + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): + */ + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self->findexes), __pyx_n_s__extend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_v_self->findexes1)); + PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_self->findexes1)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_self->findexes1)); + __pyx_t_14 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1756; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1757 + * i = i+1 + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: # <<<<<<<<<<<<<< + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) + */ + __pyx_t_3 = __pyx_v_phrase->n; + for (__pyx_v_j = 0; __pyx_v_j < __pyx_t_3; __pyx_v_j++) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1758 + * self.findexes.extend(self.findexes1) + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i + 1 + */ + __pyx_t_4 = __pyx_f_3_sa_sym_isvar((__pyx_v_phrase->syms[__pyx_v_j])); + if (__pyx_t_4) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1759 + * for j from 0 <= j < phrase.n: + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * i = i + 1 + * else: + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1760 + * if sym_isvar(phrase.syms[j]): + * fphr_arr._append(sym_setindex(self.category, i)) + * i = i + 1 # <<<<<<<<<<<<<< + * else: + * fphr_arr._append(phrase.syms[j]) + */ + __pyx_v_i = (__pyx_v_i + 1); + goto __pyx_L106; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1762 + * i = i + 1 + * else: + * fphr_arr._append(phrase.syms[j]) # <<<<<<<<<<<<<< + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, (__pyx_v_phrase->syms[__pyx_v_j])); + } + __pyx_L106:; + } + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1763 + * else: + * fphr_arr._append(phrase.syms[j]) + * fphr_arr._append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * self.findexes.append(sym_setindex(self.category, i)) + * fphr = Phrase(fphr_arr) + */ + ((struct __pyx_vtabstruct_3_sa_IntList *)__pyx_v_fphr_arr->__pyx_vtab)->_append(__pyx_v_fphr_arr, __pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1764 + * fphr_arr._append(phrase.syms[j]) + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) # <<<<<<<<<<<<<< + * fphr = Phrase(fphr_arr) + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+2, + */ + __pyx_t_14 = PyInt_FromLong(__pyx_f_3_sa_sym_setindex(__pyx_v_self->category, __pyx_v_i)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_15 = __Pyx_PyObject_Append(((PyObject *)__pyx_v_self->findexes), __pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1764; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1765 + * fphr_arr._append(sym_setindex(self.category, i)) + * self.findexes.append(sym_setindex(self.category, i)) + * fphr = Phrase(fphr_arr) # <<<<<<<<<<<<<< + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+2, + * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, + */ + __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_v_fphr_arr)); + PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_fphr_arr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr_arr)); + __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_Phrase)), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1765; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_DECREF(((PyObject *)__pyx_v_fphr)); + __pyx_v_fphr = ((struct __pyx_obj_3_sa_Phrase *)__pyx_t_14); + __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1768 + * phrase_list = self.extract_phrases(e_x_low, e_x_high, e_gap_low, e_gap_high, e_links_low, num_gaps+2, + * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, + * matching.sent_id, e_sent_len, e_sent_start) # <<<<<<<<<<<<<< + * if len(phrase_list) > 0: + * pair_count = 1.0 / len(phrase_list) + */ + __pyx_t_14 = ((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->extract_phrases(__pyx_v_self, __pyx_v_e_x_low, __pyx_v_e_x_high, __pyx_v_e_gap_low, __pyx_v_e_gap_high, __pyx_v_e_links_low, (__pyx_v_num_gaps + 2), __pyx_v_f_x_low, __pyx_v_f_x_high, __pyx_v_f_gap_low, __pyx_v_f_gap_high, __pyx_v_f_links_low, __pyx_v_matching->sent_id, __pyx_v_e_sent_len, __pyx_v_e_sent_start); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1766; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_v_phrase_list); + __pyx_v_phrase_list = __pyx_t_14; + __pyx_t_14 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1769 + * f_x_low, f_x_high, f_gap_low, f_gap_high, f_links_low, + * matching.sent_id, e_sent_len, e_sent_start) + * if len(phrase_list) > 0: # <<<<<<<<<<<<<< + * pair_count = 1.0 / len(phrase_list) + * else: + */ + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1769; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = (__pyx_t_13 > 0); + if (__pyx_t_8) { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1770 + * matching.sent_id, e_sent_len, e_sent_start) + * if len(phrase_list) > 0: + * pair_count = 1.0 / len(phrase_list) # <<<<<<<<<<<<<< + * else: + * pair_count = 0 + */ + __pyx_t_13 = PyObject_Length(__pyx_v_phrase_list); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(__pyx_t_13 == 0)) { + PyErr_Format(PyExc_ZeroDivisionError, "float division"); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1770; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __pyx_v_pair_count = (1.0 / __pyx_t_13); + goto __pyx_L107; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1772 + * pair_count = 1.0 / len(phrase_list) + * else: + * pair_count = 0 # <<<<<<<<<<<<<< + * for phrase2, eindexes in phrase_list: + * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + */ + __pyx_v_pair_count = 0.0; + } + __pyx_L107:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1773 + * else: + * pair_count = 0 + * for phrase2, eindexes in phrase_list: # <<<<<<<<<<<<<< + * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als4))) + */ + if (PyList_CheckExact(__pyx_v_phrase_list) || PyTuple_CheckExact(__pyx_v_phrase_list)) { + __pyx_t_14 = __pyx_v_phrase_list; __Pyx_INCREF(__pyx_t_14); __pyx_t_13 = 0; + __pyx_t_16 = NULL; + } else { + __pyx_t_13 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_v_phrase_list); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_14); + __pyx_t_16 = Py_TYPE(__pyx_t_14)->tp_iternext; + } + for (;;) { + if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_14)) { + if (__pyx_t_13 >= PyList_GET_SIZE(__pyx_t_14)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_15 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; + #else + __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_14)) { + if (__pyx_t_13 >= PyTuple_GET_SIZE(__pyx_t_14)) break; + #if CYTHON_COMPILING_IN_CPYTHON + __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_13); __Pyx_INCREF(__pyx_t_15); __pyx_t_13++; + #else + __pyx_t_15 = PySequence_ITEM(__pyx_t_14, __pyx_t_13); __pyx_t_13++; if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + #endif + } else { + __pyx_t_15 = __pyx_t_16(__pyx_t_14); + if (unlikely(!__pyx_t_15)) { + if (PyErr_Occurred()) { + if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); + else {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + break; + } + __Pyx_GOTREF(__pyx_t_15); + } + if ((likely(PyTuple_CheckExact(__pyx_t_15))) || (PyList_CheckExact(__pyx_t_15))) { + PyObject* sequence = __pyx_t_15; + #if CYTHON_COMPILING_IN_CPYTHON + Py_ssize_t size = Py_SIZE(sequence); + #else + Py_ssize_t size = PySequence_Size(sequence); + #endif + if (unlikely(size != 2)) { + if (size > 2) __Pyx_RaiseTooManyValuesError(2); + else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + #if CYTHON_COMPILING_IN_CPYTHON + if (likely(PyTuple_CheckExact(sequence))) { + __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); + __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); + } else { + __pyx_t_1 = PyList_GET_ITEM(sequence, 0); + __pyx_t_2 = PyList_GET_ITEM(sequence, 1); + } + __Pyx_INCREF(__pyx_t_1); + __Pyx_INCREF(__pyx_t_2); + #else + __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #endif + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + } else + { + Py_ssize_t index = -1; + __pyx_t_10 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_10); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __pyx_t_17 = Py_TYPE(__pyx_t_10)->tp_iternext; + index = 0; __pyx_t_1 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L110_unpacking_failed; + __Pyx_GOTREF(__pyx_t_1); + index = 1; __pyx_t_2 = __pyx_t_17(__pyx_t_10); if (unlikely(!__pyx_t_2)) goto __pyx_L110_unpacking_failed; + __Pyx_GOTREF(__pyx_t_2); + if (__Pyx_IternextUnpackEndCheck(__pyx_t_17(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_17 = NULL; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + goto __pyx_L111_unpacking_done; + __pyx_L110_unpacking_failed:; + __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; + __pyx_t_17 = NULL; + if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); + {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_L111_unpacking_done:; + } + __Pyx_XDECREF(__pyx_v_phrase2); + __pyx_v_phrase2 = __pyx_t_1; + __pyx_t_1 = 0; + __Pyx_XDECREF(__pyx_v_eindexes); + __pyx_v_eindexes = __pyx_t_2; + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1774 + * pair_count = 0 + * for phrase2, eindexes in phrase_list: + * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) # <<<<<<<<<<<<<< + * extracts.append((fphr, phrase2, pair_count, tuple(als4))) + * else: + */ + __pyx_t_15 = ((PyObject *)__pyx_v_self->findexes); + __Pyx_INCREF(__pyx_t_15); + __pyx_t_2 = ((PyObject *)((struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory *)__pyx_v_self->__pyx_vtab)->create_alignments(__pyx_v_self, __pyx_v_sent_links, __pyx_v_num_links, __pyx_t_15, __pyx_v_eindexes)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_als4)); + __pyx_v_als4 = ((struct __pyx_obj_3_sa_IntList *)__pyx_t_2); + __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1775 + * for phrase2, eindexes in phrase_list: + * als4 = self.create_alignments(sent_links,num_links,self.findexes,eindexes) + * extracts.append((fphr, phrase2, pair_count, tuple(als4))) # <<<<<<<<<<<<<< + * else: + * reason_for_failure = "Unable to extract basic phrase" + */ + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_pair_count); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_v_als4)); + PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_als4)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_als4)); + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyTuple_Type))), ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __pyx_t_15 = PyTuple_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_15); + __Pyx_INCREF(((PyObject *)__pyx_v_fphr)); + PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_v_fphr)); + __Pyx_GIVEREF(((PyObject *)__pyx_v_fphr)); + __Pyx_INCREF(__pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_v_phrase2); + __Pyx_GIVEREF(__pyx_v_phrase2); + PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_2); + __Pyx_GIVEREF(__pyx_t_2); + PyTuple_SET_ITEM(__pyx_t_15, 3, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_2 = 0; + __pyx_t_1 = 0; + __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_extracts, ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0; + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + } + __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0; + goto __pyx_L103; + } + __pyx_L103:; + goto __pyx_L94; + } + __pyx_L94:; + goto __pyx_L63; + } + __pyx_L63:; + goto __pyx_L51; + } + __pyx_L51:; + goto __pyx_L34; + } + /*else*/ { + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1777 + * extracts.append((fphr, phrase2, pair_count, tuple(als4))) + * else: + * reason_for_failure = "Unable to extract basic phrase" # <<<<<<<<<<<<<< + * + * free(sent_links) + */ + __Pyx_INCREF(((PyObject *)__pyx_kp_s_135)); + __Pyx_DECREF(__pyx_v_reason_for_failure); + __pyx_v_reason_for_failure = ((PyObject *)__pyx_kp_s_135); + } + __pyx_L34:; + goto __pyx_L33; + } + __pyx_L33:; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1779 + * reason_for_failure = "Unable to extract basic phrase" + * + * free(sent_links) # <<<<<<<<<<<<<< + * free(f_links_low) + * free(f_links_high) + */ + free(__pyx_v_sent_links); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1780 + * + * free(sent_links) + * free(f_links_low) # <<<<<<<<<<<<<< + * free(f_links_high) + * free(e_links_low) + */ + free(__pyx_v_f_links_low); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1781 + * free(sent_links) + * free(f_links_low) + * free(f_links_high) # <<<<<<<<<<<<<< + * free(e_links_low) + * free(e_links_high) + */ + free(__pyx_v_f_links_high); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1782 + * free(f_links_low) + * free(f_links_high) + * free(e_links_low) # <<<<<<<<<<<<<< + * free(e_links_high) + * free(f_gap_low) + */ + free(__pyx_v_e_links_low); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1783 + * free(f_links_high) + * free(e_links_low) + * free(e_links_high) # <<<<<<<<<<<<<< + * free(f_gap_low) + * free(f_gap_high) + */ + free(__pyx_v_e_links_high); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1784 + * free(e_links_low) + * free(e_links_high) + * free(f_gap_low) # <<<<<<<<<<<<<< + * free(f_gap_high) + * free(e_gap_low) + */ + free(__pyx_v_f_gap_low); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1785 + * free(e_links_high) + * free(f_gap_low) + * free(f_gap_high) # <<<<<<<<<<<<<< + * free(e_gap_low) + * free(e_gap_high) + */ + free(__pyx_v_f_gap_high); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1786 + * free(f_gap_low) + * free(f_gap_high) + * free(e_gap_low) # <<<<<<<<<<<<<< + * free(e_gap_high) + * + */ + free(__pyx_v_e_gap_low); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1787 + * free(f_gap_high) + * free(e_gap_low) + * free(e_gap_high) # <<<<<<<<<<<<<< + * + * return extracts + */ + free(__pyx_v_e_gap_high); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1789 + * free(e_gap_high) + * + * return extracts # <<<<<<<<<<<<<< + */ + __Pyx_XDECREF(__pyx_r); + __Pyx_INCREF(__pyx_v_extracts); + __pyx_r = __pyx_v_extracts; + 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_10); + __Pyx_XDECREF(__pyx_t_14); + __Pyx_XDECREF(__pyx_t_15); + __Pyx_AddTraceback("_sa.HieroCachingRuleFactory.extract", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = 0; + __pyx_L0:; + __Pyx_XDECREF(__pyx_v_extracts); + __Pyx_XDECREF(__pyx_v_phrase_list); + __Pyx_XDECREF((PyObject *)__pyx_v_fphr_arr); + __Pyx_XDECREF((PyObject *)__pyx_v_fphr); + __Pyx_XDECREF(__pyx_v_reason_for_failure); + __Pyx_XDECREF(__pyx_v_sofar); + __Pyx_XDECREF(__pyx_v_als); + __Pyx_XDECREF(__pyx_v_al); + __Pyx_XDECREF(__pyx_v_phrase2); + __Pyx_XDECREF(__pyx_v_eindexes); + __Pyx_XDECREF((PyObject *)__pyx_v_als1); + __Pyx_XDECREF((PyObject *)__pyx_v_als2); + __Pyx_XDECREF((PyObject *)__pyx_v_als3); + __Pyx_XDECREF((PyObject *)__pyx_v_als4); + __Pyx_XGIVEREF(__pyx_r); + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} +static struct __pyx_vtabstruct_3_sa_FloatList __pyx_vtable_3_sa_FloatList; + +static PyObject *__pyx_tp_new_3_sa_FloatList(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_FloatList *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_FloatList *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_FloatList; + if (__pyx_pw_3_sa_9FloatList_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_FloatList(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_9FloatList_3__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} +static PyObject *__pyx_sq_item_3_sa_FloatList(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_3_sa_FloatList(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_pw_3_sa_9FloatList_7__setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyMethodDef __pyx_methods_3_sa_FloatList[] = { + {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_3_sa_9FloatList_11append, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_3_sa_9FloatList_13write, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_3_sa_9FloatList_15read, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_FloatList = { + 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_FloatList = { + __pyx_pw_3_sa_9FloatList_9__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_3_sa_FloatList, /*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_FloatList = { + __pyx_pw_3_sa_9FloatList_9__len__, /*mp_length*/ + __pyx_pw_3_sa_9FloatList_5__getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_3_sa_FloatList, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_FloatList = { + #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_3_sa_FloatList = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.FloatList"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_FloatList), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_FloatList, /*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_FloatList, /*tp_as_number*/ + &__pyx_tp_as_sequence_FloatList, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_FloatList, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_FloatList, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_FloatList, /*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_3_sa_FloatList, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_3_sa_IntList __pyx_vtable_3_sa_IntList; + +static PyObject *__pyx_tp_new_3_sa_IntList(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_IntList *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_IntList *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_IntList; + if (__pyx_pw_3_sa_7IntList_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_IntList(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_7IntList_15__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} +static PyObject *__pyx_sq_item_3_sa_IntList(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static int __pyx_mp_ass_subscript_3_sa_IntList(PyObject *o, PyObject *i, PyObject *v) { + if (v) { + return __pyx_pw_3_sa_7IntList_22__setitem__(o, i, v); + } + else { + PyErr_Format(PyExc_NotImplementedError, + "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name); + return -1; + } +} + +static PyMethodDef __pyx_methods_3_sa_IntList[] = { + {__Pyx_NAMESTR("index"), (PyCFunction)__pyx_pw_3_sa_7IntList_5index, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("partition"), (PyCFunction)__pyx_pw_3_sa_7IntList_7partition, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("_doquicksort"), (PyCFunction)__pyx_pw_3_sa_7IntList_9_doquicksort, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("sort"), (PyCFunction)__pyx_pw_3_sa_7IntList_11sort, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("reset"), (PyCFunction)__pyx_pw_3_sa_7IntList_13reset, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getSize"), (PyCFunction)__pyx_pw_3_sa_7IntList_26getSize, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_3_sa_7IntList_28append, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("extend"), (PyCFunction)__pyx_pw_3_sa_7IntList_30extend, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_3_sa_7IntList_32write, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_3_sa_7IntList_34read, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_IntList = { + 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_IntList = { + __pyx_pw_3_sa_7IntList_24__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_3_sa_IntList, /*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_IntList = { + __pyx_pw_3_sa_7IntList_24__len__, /*mp_length*/ + __pyx_pw_3_sa_7IntList_20__getitem__, /*mp_subscript*/ + __pyx_mp_ass_subscript_3_sa_IntList, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_IntList = { + #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_3_sa_IntList = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.IntList"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_IntList), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_IntList, /*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_IntList, /*tp_as_number*/ + &__pyx_tp_as_sequence_IntList, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_IntList, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_3_sa_7IntList_3__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_IntList, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pw_3_sa_7IntList_17__iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_IntList, /*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_3_sa_IntList, /*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_3_sa_FeatureVector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa_FeatureVector *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_FeatureVector *)o); + p->names = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->values = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_13FeatureVector_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_FeatureVector(PyObject *o) { + struct __pyx_obj_3_sa_FeatureVector *p = (struct __pyx_obj_3_sa_FeatureVector *)o; + Py_XDECREF(((PyObject *)p->names)); + Py_XDECREF(((PyObject *)p->values)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_3_sa_FeatureVector(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_FeatureVector *p = (struct __pyx_obj_3_sa_FeatureVector *)o; + if (p->names) { + e = (*v)(((PyObject*)p->names), a); if (e) return e; + } + if (p->values) { + e = (*v)(((PyObject*)p->values), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_FeatureVector(PyObject *o) { + struct __pyx_obj_3_sa_FeatureVector *p = (struct __pyx_obj_3_sa_FeatureVector *)o; + PyObject* tmp; + tmp = ((PyObject*)p->names); + p->names = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->values); + p->values = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_FeatureVector[] = { + {__Pyx_NAMESTR("set"), (PyCFunction)__pyx_pw_3_sa_13FeatureVector_3set, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_FeatureVector = { + 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_FeatureVector = { + 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_FeatureVector = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_FeatureVector = { + #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_3_sa_FeatureVector = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.FeatureVector"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_FeatureVector), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_FeatureVector, /*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_FeatureVector, /*tp_as_number*/ + &__pyx_tp_as_sequence_FeatureVector, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_FeatureVector, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_3_sa_13FeatureVector_8__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_FeatureVector, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa_FeatureVector, /*tp_traverse*/ + __pyx_tp_clear_3_sa_FeatureVector, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pw_3_sa_13FeatureVector_5__iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_FeatureVector, /*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_3_sa_FeatureVector, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_3_sa_Phrase __pyx_vtable_3_sa_Phrase; + +static PyObject *__pyx_tp_new_3_sa_Phrase(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_Phrase *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_Phrase *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_Phrase; + if (__pyx_pw_3_sa_6Phrase_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_Phrase(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_6Phrase_3__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} +static PyObject *__pyx_sq_item_3_sa_Phrase(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyObject *__pyx_getprop_3_sa_6Phrase_words(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_6Phrase_5words_1__get__(o); +} + +static PyMethodDef __pyx_methods_3_sa_Phrase[] = { + {__Pyx_NAMESTR("handle"), (PyCFunction)__pyx_pw_3_sa_6Phrase_7handle, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3_sa_6Phrase_6handle)}, + {__Pyx_NAMESTR("strhandle"), (PyCFunction)__pyx_pw_3_sa_6Phrase_9strhandle, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("arity"), (PyCFunction)__pyx_pw_3_sa_6Phrase_11arity, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getvarpos"), (PyCFunction)__pyx_pw_3_sa_6Phrase_13getvarpos, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getvar"), (PyCFunction)__pyx_pw_3_sa_6Phrase_15getvar, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("clen"), (PyCFunction)__pyx_pw_3_sa_6Phrase_17clen, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getchunk"), (PyCFunction)__pyx_pw_3_sa_6Phrase_19getchunk, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("subst"), (PyCFunction)__pyx_pw_3_sa_6Phrase_32subst, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_3_sa_Phrase[] = { + {(char *)"words", __pyx_getprop_3_sa_6Phrase_words, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_Phrase = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_divide*/ + #endif + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_coerce*/ + #endif + 0, /*nb_int*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_long*/ + #else + 0, /*reserved*/ + #endif + 0, /*nb_float*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_oct*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*nb_hex*/ + #endif + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_inplace_divide*/ + #endif + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ + #if PY_VERSION_HEX >= 0x02050000 + 0, /*nb_index*/ + #endif +}; + +static PySequenceMethods __pyx_tp_as_sequence_Phrase = { + __pyx_pw_3_sa_6Phrase_25__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + __pyx_sq_item_3_sa_Phrase, /*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_Phrase = { + __pyx_pw_3_sa_6Phrase_25__len__, /*mp_length*/ + __pyx_pw_3_sa_6Phrase_27__getitem__, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_Phrase = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + #if PY_VERSION_HEX >= 0x02060000 + 0, /*bf_getbuffer*/ + #endif + #if PY_VERSION_HEX >= 0x02060000 + 0, /*bf_releasebuffer*/ + #endif +}; + +static PyTypeObject __pyx_type_3_sa_Phrase = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.Phrase"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Phrase), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_Phrase, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + __pyx_pw_3_sa_6Phrase_21__cmp__, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + &__pyx_tp_as_number_Phrase, /*tp_as_number*/ + &__pyx_tp_as_sequence_Phrase, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Phrase, /*tp_as_mapping*/ + __pyx_pw_3_sa_6Phrase_23__hash__, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_3_sa_6Phrase_5__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_Phrase, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + __pyx_pw_3_sa_6Phrase_29__iter__, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_Phrase, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_3_sa_Phrase, /*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_3_sa_Phrase, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; + +static PyObject *__pyx_tp_new_3_sa_Rule(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_Rule *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_Rule *)o); + p->f = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); + p->e = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); + p->scores = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); Py_INCREF(Py_None); + p->word_alignments = Py_None; Py_INCREF(Py_None); + if (__pyx_pw_3_sa_4Rule_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_Rule(PyObject *o) { + struct __pyx_obj_3_sa_Rule *p = (struct __pyx_obj_3_sa_Rule *)o; + Py_XDECREF(((PyObject *)p->f)); + Py_XDECREF(((PyObject *)p->e)); + Py_XDECREF(((PyObject *)p->scores)); + Py_XDECREF(p->word_alignments); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_3_sa_Rule(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_Rule *p = (struct __pyx_obj_3_sa_Rule *)o; + if (p->f) { + e = (*v)(((PyObject*)p->f), a); if (e) return e; + } + if (p->e) { + e = (*v)(((PyObject*)p->e), a); if (e) return e; + } + if (p->scores) { + e = (*v)(((PyObject*)p->scores), a); if (e) return e; + } + if (p->word_alignments) { + e = (*v)(p->word_alignments, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_Rule(PyObject *o) { + struct __pyx_obj_3_sa_Rule *p = (struct __pyx_obj_3_sa_Rule *)o; + PyObject* tmp; + tmp = ((PyObject*)p->f); + p->f = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->e); + p->e = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->scores); + p->scores = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->word_alignments); + p->word_alignments = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_3_sa_4Rule_f(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_4Rule_1f_1__get__(o); +} + +static PyObject *__pyx_getprop_3_sa_4Rule_e(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_4Rule_1e_1__get__(o); +} + +static PyMethodDef __pyx_methods_3_sa_Rule[] = { + {__Pyx_NAMESTR("fmerge"), (PyCFunction)__pyx_pw_3_sa_4Rule_7fmerge, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("arity"), (PyCFunction)__pyx_pw_3_sa_4Rule_9arity, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("alignments"), (PyCFunction)__pyx_pw_3_sa_4Rule_13alignments, METH_NOARGS, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static struct PyGetSetDef __pyx_getsets_3_sa_Rule[] = { + {(char *)"f", __pyx_getprop_3_sa_4Rule_f, 0, 0, 0}, + {(char *)"e", __pyx_getprop_3_sa_4Rule_e, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_Rule = { + 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_Rule = { + 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_Rule = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_Rule = { + #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_3_sa_Rule = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.Rule"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Rule), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_Rule, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + __pyx_pw_3_sa_4Rule_5__cmp__, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + &__pyx_tp_as_number_Rule, /*tp_as_number*/ + &__pyx_tp_as_sequence_Rule, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Rule, /*tp_as_mapping*/ + __pyx_pw_3_sa_4Rule_3__hash__, /*tp_hash*/ + 0, /*tp_call*/ + __pyx_pw_3_sa_4Rule_11__str__, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_Rule, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa_Rule, /*tp_traverse*/ + __pyx_tp_clear_3_sa_Rule, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_Rule, /*tp_methods*/ + 0, /*tp_members*/ + __pyx_getsets_3_sa_Rule, /*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_3_sa_Rule, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_3_sa_StringMap __pyx_vtable_3_sa_StringMap; + +static PyObject *__pyx_tp_new_3_sa_StringMap(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa_StringMap *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_StringMap *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_StringMap; + if (__pyx_pw_3_sa_9StringMap_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_StringMap(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_9StringMap_3__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + (*Py_TYPE(o)->tp_free)(o); +} + +static PyMethodDef __pyx_methods_3_sa_StringMap[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_StringMap = { + 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_StringMap = { + 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_StringMap = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_StringMap = { + #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_3_sa_StringMap = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.StringMap"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_StringMap), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_StringMap, /*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_StringMap, /*tp_as_number*/ + &__pyx_tp_as_sequence_StringMap, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_StringMap, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_StringMap, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + 0, /*tp_doc*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_StringMap, /*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_3_sa_StringMap, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_3_sa_DataArray __pyx_vtable_3_sa_DataArray; + +static PyObject *__pyx_tp_new_3_sa_DataArray(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_DataArray *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_DataArray *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_DataArray; + p->word2id = Py_None; Py_INCREF(Py_None); + p->id2word = Py_None; Py_INCREF(Py_None); + p->data = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->sent_id = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_9DataArray_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_DataArray(PyObject *o) { + struct __pyx_obj_3_sa_DataArray *p = (struct __pyx_obj_3_sa_DataArray *)o; + Py_XDECREF(p->word2id); + Py_XDECREF(p->id2word); + Py_XDECREF(((PyObject *)p->data)); + Py_XDECREF(((PyObject *)p->sent_id)); + Py_XDECREF(((PyObject *)p->sent_index)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_3_sa_DataArray(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_DataArray *p = (struct __pyx_obj_3_sa_DataArray *)o; + if (p->word2id) { + e = (*v)(p->word2id, a); if (e) return e; + } + if (p->id2word) { + e = (*v)(p->id2word, a); if (e) return e; + } + if (p->data) { + e = (*v)(((PyObject*)p->data), a); if (e) return e; + } + if (p->sent_id) { + e = (*v)(((PyObject*)p->sent_id), a); if (e) return e; + } + if (p->sent_index) { + e = (*v)(((PyObject*)p->sent_index), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_DataArray(PyObject *o) { + struct __pyx_obj_3_sa_DataArray *p = (struct __pyx_obj_3_sa_DataArray *)o; + PyObject* tmp; + tmp = ((PyObject*)p->word2id); + p->word2id = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->id2word); + p->id2word = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->data); + p->data = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sent_id); + p->sent_id = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sent_index); + p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_DataArray[] = { + {__Pyx_NAMESTR("getSentId"), (PyCFunction)__pyx_pw_3_sa_9DataArray_5getSentId, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getSent"), (PyCFunction)__pyx_pw_3_sa_9DataArray_7getSent, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getSentPos"), (PyCFunction)__pyx_pw_3_sa_9DataArray_9getSentPos, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_id"), (PyCFunction)__pyx_pw_3_sa_9DataArray_11get_id, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_word"), (PyCFunction)__pyx_pw_3_sa_9DataArray_13get_word, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_9DataArray_15write_text, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_9DataArray_17read_text, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_bitext"), (PyCFunction)__pyx_pw_3_sa_9DataArray_19read_bitext, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_text_data"), (PyCFunction)__pyx_pw_3_sa_9DataArray_21read_text_data, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_9DataArray_23read_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_9DataArray_25write_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_enhanced_handle"), (PyCFunction)__pyx_pw_3_sa_9DataArray_27write_enhanced_handle, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_9DataArray_29write_enhanced, METH_O, __Pyx_DOCSTR(0)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_DataArray = { + 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_DataArray = { + __pyx_pw_3_sa_9DataArray_3__len__, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping_DataArray = { + __pyx_pw_3_sa_9DataArray_3__len__, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_DataArray = { + #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_3_sa_DataArray = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.DataArray"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_DataArray), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_DataArray, /*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_DataArray, /*tp_as_number*/ + &__pyx_tp_as_sequence_DataArray, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_DataArray, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_DataArray, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa_DataArray, /*tp_traverse*/ + __pyx_tp_clear_3_sa_DataArray, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_DataArray, /*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_3_sa_DataArray, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_3_sa_Alignment __pyx_vtable_3_sa_Alignment; + +static PyObject *__pyx_tp_new_3_sa_Alignment(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_Alignment *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_Alignment *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_Alignment; + p->links = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_9Alignment_5__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_Alignment(PyObject *o) { + struct __pyx_obj_3_sa_Alignment *p = (struct __pyx_obj_3_sa_Alignment *)o; + Py_XDECREF(((PyObject *)p->links)); + Py_XDECREF(((PyObject *)p->sent_index)); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_3_sa_Alignment(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_Alignment *p = (struct __pyx_obj_3_sa_Alignment *)o; + if (p->links) { + e = (*v)(((PyObject*)p->links), a); if (e) return e; + } + if (p->sent_index) { + e = (*v)(((PyObject*)p->sent_index), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_Alignment(PyObject *o) { + struct __pyx_obj_3_sa_Alignment *p = (struct __pyx_obj_3_sa_Alignment *)o; + PyObject* tmp; + tmp = ((PyObject*)p->links); + p->links = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sent_index); + p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_Alignment[] = { + {__Pyx_NAMESTR("unlink"), (PyCFunction)__pyx_pw_3_sa_9Alignment_1unlink, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_9Alignment_unlink)}, + {__Pyx_NAMESTR("get_sent_links"), (PyCFunction)__pyx_pw_3_sa_9Alignment_3get_sent_links, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_9Alignment_7read_text, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_9Alignment_9read_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_9Alignment_11write_text, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_9Alignment_13write_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_9Alignment_15write_enhanced, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("alignment"), (PyCFunction)__pyx_pw_3_sa_9Alignment_17alignment, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_9Alignment_16alignment)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_Alignment = { + 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_Alignment = { + 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_Alignment = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_Alignment = { + #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_3_sa_Alignment = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.Alignment"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Alignment), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_Alignment, /*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_Alignment, /*tp_as_number*/ + &__pyx_tp_as_sequence_Alignment, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Alignment, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_Alignment, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa_Alignment, /*tp_traverse*/ + __pyx_tp_clear_3_sa_Alignment, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_Alignment, /*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_3_sa_Alignment, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; +static struct __pyx_vtabstruct_3_sa_BiLex __pyx_vtable_3_sa_BiLex; + +static PyObject *__pyx_tp_new_3_sa_BiLex(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_BiLex *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa_BiLex *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_BiLex; + p->col1 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); + p->col2 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); + p->f_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->e_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->id2eword = Py_None; Py_INCREF(Py_None); + p->id2fword = Py_None; Py_INCREF(Py_None); + p->eword2id = Py_None; Py_INCREF(Py_None); + p->fword2id = Py_None; Py_INCREF(Py_None); + if (__pyx_pw_3_sa_5BiLex_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } + return o; +} + +static void __pyx_tp_dealloc_3_sa_BiLex(PyObject *o) { + struct __pyx_obj_3_sa_BiLex *p = (struct __pyx_obj_3_sa_BiLex *)o; + Py_XDECREF(((PyObject *)p->col1)); + Py_XDECREF(((PyObject *)p->col2)); + Py_XDECREF(((PyObject *)p->f_index)); + Py_XDECREF(((PyObject *)p->e_index)); + Py_XDECREF(p->id2eword); + Py_XDECREF(p->id2fword); + Py_XDECREF(p->eword2id); + Py_XDECREF(p->fword2id); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_3_sa_BiLex(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_BiLex *p = (struct __pyx_obj_3_sa_BiLex *)o; + if (p->col1) { + e = (*v)(((PyObject*)p->col1), a); if (e) return e; + } + if (p->col2) { + e = (*v)(((PyObject*)p->col2), a); if (e) return e; + } + if (p->f_index) { + e = (*v)(((PyObject*)p->f_index), a); if (e) return e; + } + if (p->e_index) { + e = (*v)(((PyObject*)p->e_index), a); if (e) return e; + } + if (p->id2eword) { + e = (*v)(p->id2eword, a); if (e) return e; + } + if (p->id2fword) { + e = (*v)(p->id2fword, a); if (e) return e; + } + if (p->eword2id) { + e = (*v)(p->eword2id, a); if (e) return e; + } + if (p->fword2id) { + e = (*v)(p->fword2id, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_BiLex(PyObject *o) { + struct __pyx_obj_3_sa_BiLex *p = (struct __pyx_obj_3_sa_BiLex *)o; + PyObject* tmp; + tmp = ((PyObject*)p->col1); + p->col1 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->col2); + p->col2 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->f_index); + p->f_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->e_index); + p->e_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->id2eword); + p->id2eword = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->id2fword); + p->id2fword = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->eword2id); + p->eword2id = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->fword2id); + p->fword2id = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_BiLex[] = { + {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_5BiLex_3write_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_5BiLex_5read_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_e_id"), (PyCFunction)__pyx_pw_3_sa_5BiLex_7get_e_id, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_f_id"), (PyCFunction)__pyx_pw_3_sa_5BiLex_9get_f_id, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_5BiLex_11read_text, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_5BiLex_13write_enhanced, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_score"), (PyCFunction)__pyx_pw_3_sa_5BiLex_15get_score, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_5BiLex_17write_text, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_5BiLex_16write_text)}, + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_BiLex = { + 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_BiLex = { + 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_BiLex = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer_BiLex = { + #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 PyObject *__pyx_tp_new_3_sa_Phrase(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_Phrase *p; +static PyTypeObject __pyx_type_3_sa_BiLex = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.BiLex"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_BiLex), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa_BiLex, /*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_BiLex, /*tp_as_number*/ + &__pyx_tp_as_sequence_BiLex, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_BiLex, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer_BiLex, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa_BiLex, /*tp_traverse*/ + __pyx_tp_clear_3_sa_BiLex, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_BiLex, /*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_3_sa_BiLex, /*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_3_sa_BitSetIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_Phrase *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_Phrase; - if (__pyx_pw_3_sa_6Phrase_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } return o; } -static void __pyx_tp_dealloc_3_sa_Phrase(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_6Phrase_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } +static void __pyx_tp_dealloc_3_sa_BitSetIterator(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } -static PyObject *__pyx_sq_item_3_sa_Phrase(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} - -static PyObject *__pyx_getprop_3_sa_6Phrase_words(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_6Phrase_5words_1__get__(o); -} -static PyMethodDef __pyx_methods_3_sa_Phrase[] = { - {__Pyx_NAMESTR("handle"), (PyCFunction)__pyx_pw_3_sa_6Phrase_7handle, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_3_sa_6Phrase_6handle)}, - {__Pyx_NAMESTR("strhandle"), (PyCFunction)__pyx_pw_3_sa_6Phrase_9strhandle, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("arity"), (PyCFunction)__pyx_pw_3_sa_6Phrase_11arity, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getvarpos"), (PyCFunction)__pyx_pw_3_sa_6Phrase_13getvarpos, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getvar"), (PyCFunction)__pyx_pw_3_sa_6Phrase_15getvar, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("clen"), (PyCFunction)__pyx_pw_3_sa_6Phrase_17clen, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getchunk"), (PyCFunction)__pyx_pw_3_sa_6Phrase_19getchunk, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("subst"), (PyCFunction)__pyx_pw_3_sa_6Phrase_32subst, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_3_sa_BitSetIterator[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_3_sa_14BitSetIterator_1__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_3_sa_Phrase[] = { - {(char *)"words", __pyx_getprop_3_sa_6Phrase_words, 0, 0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Phrase = { +static PyNumberMethods __pyx_tp_as_number_BitSetIterator = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -54224,11 +57885,11 @@ static PyNumberMethods __pyx_tp_as_number_Phrase = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_Phrase = { - __pyx_pw_3_sa_6Phrase_25__len__, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_BitSetIterator = { + 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ - __pyx_sq_item_3_sa_Phrase, /*sq_item*/ + 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ @@ -54237,13 +57898,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Phrase = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_Phrase = { - __pyx_pw_3_sa_6Phrase_25__len__, /*mp_length*/ - __pyx_pw_3_sa_6Phrase_27__getitem__, /*mp_subscript*/ +static PyMappingMethods __pyx_tp_as_mapping_BitSetIterator = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_Phrase = { +static PyBufferProcs __pyx_tp_as_buffer_BitSetIterator = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -54264,41 +57925,41 @@ static PyBufferProcs __pyx_tp_as_buffer_Phrase = { #endif }; -static PyTypeObject __pyx_type_3_sa_Phrase = { +static PyTypeObject __pyx_type_3_sa_BitSetIterator = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.Phrase"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_Phrase), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.BitSetIterator"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_BitSetIterator), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_Phrase, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_BitSetIterator, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 - __pyx_pw_3_sa_6Phrase_21__cmp__, /*tp_compare*/ + 0, /*tp_compare*/ #else 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_Phrase, /*tp_as_number*/ - &__pyx_tp_as_sequence_Phrase, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Phrase, /*tp_as_mapping*/ - __pyx_pw_3_sa_6Phrase_23__hash__, /*tp_hash*/ + &__pyx_tp_as_number_BitSetIterator, /*tp_as_number*/ + &__pyx_tp_as_sequence_BitSetIterator, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_BitSetIterator, /*tp_as_mapping*/ + 0, /*tp_hash*/ 0, /*tp_call*/ - __pyx_pw_3_sa_6Phrase_5__str__, /*tp_str*/ + 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Phrase, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_BitSetIterator, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - __pyx_pw_3_sa_6Phrase_29__iter__, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_3_sa_Phrase, /*tp_methods*/ + 0, /*tp_iter*/ + __pyx_pw_3_sa_14BitSetIterator_1__next__, /*tp_iternext*/ + __pyx_methods_3_sa_BitSetIterator, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_3_sa_Phrase, /*tp_getset*/ + 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -54306,7 +57967,7 @@ static PyTypeObject __pyx_type_3_sa_Phrase = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_Phrase, /*tp_new*/ + __pyx_tp_new_3_sa_BitSetIterator, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -54320,132 +57981,37 @@ static PyTypeObject __pyx_type_3_sa_Phrase = { #endif }; -static PyObject *__pyx_tp_new_3_sa_Rule(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_Rule *p; +static PyObject *__pyx_tp_new_3_sa_BitSet(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_Rule *)o); - p->f = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); - p->e = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); - p->word_alignments = Py_None; Py_INCREF(Py_None); - if (__pyx_pw_3_sa_4Rule_1__cinit__(o, a, k) < 0) { + if (__pyx_pw_3_sa_6BitSet_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_Rule(PyObject *o) { - struct __pyx_obj_3_sa_Rule *p = (struct __pyx_obj_3_sa_Rule *)o; +static void __pyx_tp_dealloc_3_sa_BitSet(PyObject *o) { { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); - __pyx_pw_3_sa_4Rule_3__dealloc__(o); + __pyx_pw_3_sa_6BitSet_3__dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } - Py_XDECREF(((PyObject *)p->f)); - Py_XDECREF(((PyObject *)p->e)); - Py_XDECREF(p->word_alignments); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_Rule(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_3_sa_Rule *p = (struct __pyx_obj_3_sa_Rule *)o; - if (p->f) { - e = (*v)(((PyObject*)p->f), a); if (e) return e; - } - if (p->e) { - e = (*v)(((PyObject*)p->e), a); if (e) return e; - } - if (p->word_alignments) { - e = (*v)(p->word_alignments, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_3_sa_Rule(PyObject *o) { - struct __pyx_obj_3_sa_Rule *p = (struct __pyx_obj_3_sa_Rule *)o; - PyObject* tmp; - tmp = ((PyObject*)p->f); - p->f = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->e); - p->e = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->word_alignments); - p->word_alignments = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyObject *__pyx_getprop_3_sa_4Rule_scores(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_4Rule_6scores_1__get__(o); -} - -static int __pyx_setprop_3_sa_4Rule_scores(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_4Rule_6scores_3__set__(o, v); - } - else { - PyErr_SetString(PyExc_NotImplementedError, "__del__"); - return -1; - } -} - -static PyObject *__pyx_getprop_3_sa_4Rule_lhs(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_4Rule_3lhs_1__get__(o); -} - -static int __pyx_setprop_3_sa_4Rule_lhs(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_4Rule_3lhs_3__set__(o, v); - } - else { - PyErr_SetString(PyExc_NotImplementedError, "__del__"); - return -1; - } -} - -static PyObject *__pyx_getprop_3_sa_4Rule_f(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_4Rule_1f_1__get__(o); -} - -static PyObject *__pyx_getprop_3_sa_4Rule_e(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_4Rule_1e_1__get__(o); -} - -static PyObject *__pyx_getprop_3_sa_4Rule_word_alignments(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_4Rule_15word_alignments_1__get__(o); -} - -static int __pyx_setprop_3_sa_4Rule_word_alignments(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_4Rule_15word_alignments_3__set__(o, v); - } - else { - return __pyx_pw_3_sa_4Rule_15word_alignments_5__del__(o); - } -} - -static PyMethodDef __pyx_methods_3_sa_Rule[] = { - {__Pyx_NAMESTR("fmerge"), (PyCFunction)__pyx_pw_3_sa_4Rule_11fmerge, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("arity"), (PyCFunction)__pyx_pw_3_sa_4Rule_13arity, METH_NOARGS, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_3_sa_BitSet[] = { + {__Pyx_NAMESTR("insert"), (PyCFunction)__pyx_pw_3_sa_6BitSet_7insert, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("findsucc"), (PyCFunction)__pyx_pw_3_sa_6BitSet_9findsucc, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("min"), (PyCFunction)__pyx_pw_3_sa_6BitSet_13min, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("max"), (PyCFunction)__pyx_pw_3_sa_6BitSet_15max, METH_NOARGS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_3_sa_Rule[] = { - {(char *)"scores", __pyx_getprop_3_sa_4Rule_scores, __pyx_setprop_3_sa_4Rule_scores, 0, 0}, - {(char *)"lhs", __pyx_getprop_3_sa_4Rule_lhs, __pyx_setprop_3_sa_4Rule_lhs, 0, 0}, - {(char *)"f", __pyx_getprop_3_sa_4Rule_f, 0, 0, 0}, - {(char *)"e", __pyx_getprop_3_sa_4Rule_e, 0, 0, 0}, - {(char *)"word_alignments", __pyx_getprop_3_sa_4Rule_word_alignments, __pyx_setprop_3_sa_4Rule_word_alignments, 0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Rule = { +static PyNumberMethods __pyx_tp_as_number_BitSet = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -54481,7 +58047,7 @@ static PyNumberMethods __pyx_tp_as_number_Rule = { #if PY_MAJOR_VERSION < 3 0, /*nb_hex*/ #endif - __pyx_pw_3_sa_4Rule_9__iadd__, /*nb_inplace_add*/ + 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ 0, /*nb_inplace_multiply*/ #if PY_MAJOR_VERSION < 3 @@ -54503,26 +58069,26 @@ static PyNumberMethods __pyx_tp_as_number_Rule = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_Rule = { - 0, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_BitSet = { + __pyx_pw_3_sa_6BitSet_17__len__, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ + __pyx_pw_3_sa_6BitSet_19__contains__, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_Rule = { - 0, /*mp_length*/ +static PyMappingMethods __pyx_tp_as_mapping_BitSet = { + __pyx_pw_3_sa_6BitSet_17__len__, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_Rule = { +static PyBufferProcs __pyx_tp_as_buffer_BitSet = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -54543,41 +58109,41 @@ static PyBufferProcs __pyx_tp_as_buffer_Rule = { #endif }; -static PyTypeObject __pyx_type_3_sa_Rule = { +static PyTypeObject __pyx_type_3_sa_BitSet = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.Rule"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_Rule), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.BitSet"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_BitSet), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_Rule, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_BitSet, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ #if PY_MAJOR_VERSION < 3 - __pyx_pw_3_sa_4Rule_7__cmp__, /*tp_compare*/ + 0, /*tp_compare*/ #else 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_Rule, /*tp_as_number*/ - &__pyx_tp_as_sequence_Rule, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Rule, /*tp_as_mapping*/ - __pyx_pw_3_sa_4Rule_5__hash__, /*tp_hash*/ + &__pyx_tp_as_number_BitSet, /*tp_as_number*/ + &__pyx_tp_as_sequence_BitSet, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_BitSet, /*tp_as_mapping*/ + 0, /*tp_hash*/ 0, /*tp_call*/ - __pyx_pw_3_sa_4Rule_15__str__, /*tp_str*/ + __pyx_pw_3_sa_6BitSet_11__str__, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Rule, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + &__pyx_tp_as_buffer_BitSet, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_Rule, /*tp_traverse*/ - __pyx_tp_clear_3_sa_Rule, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ + __pyx_pw_3_sa_6BitSet_5__iter__, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_Rule, /*tp_methods*/ + __pyx_methods_3_sa_BitSet, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_3_sa_Rule, /*tp_getset*/ + 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -54585,7 +58151,7 @@ static PyTypeObject __pyx_type_3_sa_Rule = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_Rule, /*tp_new*/ + __pyx_tp_new_3_sa_BitSet, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -54598,59 +58164,23 @@ static PyTypeObject __pyx_type_3_sa_Rule = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_FloatList __pyx_vtable_3_sa_FloatList; -static PyObject *__pyx_tp_new_3_sa_FloatList(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_FloatList *p; +static PyObject *__pyx_tp_new_3_sa_VEBIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_FloatList *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_FloatList; - if (__pyx_pw_3_sa_9FloatList_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } return o; } -static void __pyx_tp_dealloc_3_sa_FloatList(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_9FloatList_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } +static void __pyx_tp_dealloc_3_sa_VEBIterator(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } -static PyObject *__pyx_sq_item_3_sa_FloatList(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} - -static int __pyx_mp_ass_subscript_3_sa_FloatList(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_pw_3_sa_9FloatList_7__setitem__(o, i, v); - } - else { - PyErr_Format(PyExc_NotImplementedError, - "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name); - return -1; - } -} -static PyMethodDef __pyx_methods_3_sa_FloatList[] = { - {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_3_sa_9FloatList_11append, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_3_sa_9FloatList_13write, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_3_sa_9FloatList_15read, METH_O, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_3_sa_VEBIterator[] = { + {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_3_sa_11VEBIterator_1__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_FloatList = { +static PyNumberMethods __pyx_tp_as_number_VEBIterator = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -54708,11 +58238,11 @@ static PyNumberMethods __pyx_tp_as_number_FloatList = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_FloatList = { - __pyx_pw_3_sa_9FloatList_9__len__, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_VEBIterator = { + 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ - __pyx_sq_item_3_sa_FloatList, /*sq_item*/ + 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ @@ -54721,13 +58251,13 @@ static PySequenceMethods __pyx_tp_as_sequence_FloatList = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_FloatList = { - __pyx_pw_3_sa_9FloatList_9__len__, /*mp_length*/ - __pyx_pw_3_sa_9FloatList_5__getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_3_sa_FloatList, /*mp_ass_subscript*/ +static PyMappingMethods __pyx_tp_as_mapping_VEBIterator = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_FloatList = { +static PyBufferProcs __pyx_tp_as_buffer_VEBIterator = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -54748,12 +58278,12 @@ static PyBufferProcs __pyx_tp_as_buffer_FloatList = { #endif }; -static PyTypeObject __pyx_type_3_sa_FloatList = { +static PyTypeObject __pyx_type_3_sa_VEBIterator = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.FloatList"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_FloatList), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.VEBIterator"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_VEBIterator), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_FloatList, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_VEBIterator, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -54763,15 +58293,15 @@ static PyTypeObject __pyx_type_3_sa_FloatList = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_FloatList, /*tp_as_number*/ - &__pyx_tp_as_sequence_FloatList, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_FloatList, /*tp_as_mapping*/ + &__pyx_tp_as_number_VEBIterator, /*tp_as_number*/ + &__pyx_tp_as_sequence_VEBIterator, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_VEBIterator, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_FloatList, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_VEBIterator, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ @@ -54779,8 +58309,8 @@ static PyTypeObject __pyx_type_3_sa_FloatList = { 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_3_sa_FloatList, /*tp_methods*/ + __pyx_pw_3_sa_11VEBIterator_1__next__, /*tp_iternext*/ + __pyx_methods_3_sa_VEBIterator, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -54790,7 +58320,7 @@ static PyTypeObject __pyx_type_3_sa_FloatList = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_FloatList, /*tp_new*/ + __pyx_tp_new_3_sa_VEBIterator, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -54803,66 +58333,40 @@ static PyTypeObject __pyx_type_3_sa_FloatList = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_IntList __pyx_vtable_3_sa_IntList; +static struct __pyx_vtabstruct_3_sa_VEB __pyx_vtable_3_sa_VEB; -static PyObject *__pyx_tp_new_3_sa_IntList(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_IntList *p; +static PyObject *__pyx_tp_new_3_sa_VEB(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_VEB *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_IntList *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_IntList; - if (__pyx_pw_3_sa_7IntList_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_VEB *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_VEB; + if (__pyx_pw_3_sa_3VEB_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_IntList(PyObject *o) { +static void __pyx_tp_dealloc_3_sa_VEB(PyObject *o) { { PyObject *etype, *eval, *etb; PyErr_Fetch(&etype, &eval, &etb); ++Py_REFCNT(o); - __pyx_pw_3_sa_7IntList_15__dealloc__(o); + __pyx_pw_3_sa_3VEB_3__dealloc__(o); if (PyErr_Occurred()) PyErr_WriteUnraisable(o); --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } (*Py_TYPE(o)->tp_free)(o); } -static PyObject *__pyx_sq_item_3_sa_IntList(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} - -static int __pyx_mp_ass_subscript_3_sa_IntList(PyObject *o, PyObject *i, PyObject *v) { - if (v) { - return __pyx_pw_3_sa_7IntList_19__setitem__(o, i, v); - } - else { - PyErr_Format(PyExc_NotImplementedError, - "Subscript deletion not supported by %s", Py_TYPE(o)->tp_name); - return -1; - } -} -static PyMethodDef __pyx_methods_3_sa_IntList[] = { - {__Pyx_NAMESTR("index"), (PyCFunction)__pyx_pw_3_sa_7IntList_5index, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("partition"), (PyCFunction)__pyx_pw_3_sa_7IntList_7partition, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("_doquicksort"), (PyCFunction)__pyx_pw_3_sa_7IntList_9_doquicksort, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("sort"), (PyCFunction)__pyx_pw_3_sa_7IntList_11sort, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("reset"), (PyCFunction)__pyx_pw_3_sa_7IntList_13reset, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getSize"), (PyCFunction)__pyx_pw_3_sa_7IntList_23getSize, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("append"), (PyCFunction)__pyx_pw_3_sa_7IntList_25append, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("extend"), (PyCFunction)__pyx_pw_3_sa_7IntList_27extend, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pw_3_sa_7IntList_29write, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pw_3_sa_7IntList_31read, METH_O, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_3_sa_VEB[] = { + {__Pyx_NAMESTR("insert"), (PyCFunction)__pyx_pw_3_sa_3VEB_7insert, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("findsucc"), (PyCFunction)__pyx_pw_3_sa_3VEB_9findsucc, METH_O, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_IntList = { +static PyNumberMethods __pyx_tp_as_number_VEB = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -54920,26 +58424,26 @@ static PyNumberMethods __pyx_tp_as_number_IntList = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_IntList = { - __pyx_pw_3_sa_7IntList_21__len__, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_VEB = { + __pyx_pw_3_sa_3VEB_11__len__, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ - __pyx_sq_item_3_sa_IntList, /*sq_item*/ + 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ + __pyx_pw_3_sa_3VEB_13__contains__, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_IntList = { - __pyx_pw_3_sa_7IntList_21__len__, /*mp_length*/ - __pyx_pw_3_sa_7IntList_17__getitem__, /*mp_subscript*/ - __pyx_mp_ass_subscript_3_sa_IntList, /*mp_ass_subscript*/ +static PyMappingMethods __pyx_tp_as_mapping_VEB = { + __pyx_pw_3_sa_3VEB_11__len__, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_IntList = { +static PyBufferProcs __pyx_tp_as_buffer_VEB = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -54960,12 +58464,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IntList = { #endif }; -static PyTypeObject __pyx_type_3_sa_IntList = { +static PyTypeObject __pyx_type_3_sa_VEB = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.IntList"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_IntList), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.VEB"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_VEB), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_IntList, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_VEB, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -54975,24 +58479,24 @@ static PyTypeObject __pyx_type_3_sa_IntList = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_IntList, /*tp_as_number*/ - &__pyx_tp_as_sequence_IntList, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_IntList, /*tp_as_mapping*/ + &__pyx_tp_as_number_VEB, /*tp_as_number*/ + &__pyx_tp_as_sequence_VEB, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_VEB, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - __pyx_pw_3_sa_7IntList_3__str__, /*tp_str*/ + 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_IntList, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_VEB, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ 0, /*tp_traverse*/ 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ + __pyx_pw_3_sa_3VEB_5__iter__, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_IntList, /*tp_methods*/ + __pyx_methods_3_sa_VEB, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -55002,7 +58506,7 @@ static PyTypeObject __pyx_type_3_sa_IntList = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_IntList, /*tp_new*/ + __pyx_tp_new_3_sa_VEB, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -55015,38 +58519,57 @@ static PyTypeObject __pyx_type_3_sa_IntList = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_StringMap __pyx_vtable_3_sa_StringMap; -static PyObject *__pyx_tp_new_3_sa_StringMap(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa_StringMap *p; +static PyObject *__pyx_tp_new_3_sa_LCP(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_LCP *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_StringMap *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_StringMap; - if (__pyx_pw_3_sa_9StringMap_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { + p = ((struct __pyx_obj_3_sa_LCP *)o); + p->sa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); + p->lcp = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_3LCP_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_StringMap(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_9StringMap_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } +static void __pyx_tp_dealloc_3_sa_LCP(PyObject *o) { + struct __pyx_obj_3_sa_LCP *p = (struct __pyx_obj_3_sa_LCP *)o; + Py_XDECREF(((PyObject *)p->sa)); + Py_XDECREF(((PyObject *)p->lcp)); (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_3_sa_StringMap[] = { +static int __pyx_tp_traverse_3_sa_LCP(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_LCP *p = (struct __pyx_obj_3_sa_LCP *)o; + if (p->sa) { + e = (*v)(((PyObject*)p->sa), a); if (e) return e; + } + if (p->lcp) { + e = (*v)(((PyObject*)p->lcp), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_LCP(PyObject *o) { + struct __pyx_obj_3_sa_LCP *p = (struct __pyx_obj_3_sa_LCP *)o; + PyObject* tmp; + tmp = ((PyObject*)p->sa); + p->sa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->lcp); + p->lcp = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_LCP[] = { + {__Pyx_NAMESTR("compute_stats"), (PyCFunction)__pyx_pw_3_sa_3LCP_3compute_stats, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_3LCP_2compute_stats)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_StringMap = { +static PyNumberMethods __pyx_tp_as_number_LCP = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -55104,7 +58627,7 @@ static PyNumberMethods __pyx_tp_as_number_StringMap = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_StringMap = { +static PySequenceMethods __pyx_tp_as_sequence_LCP = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -55117,13 +58640,13 @@ static PySequenceMethods __pyx_tp_as_sequence_StringMap = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_StringMap = { +static PyMappingMethods __pyx_tp_as_mapping_LCP = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_StringMap = { +static PyBufferProcs __pyx_tp_as_buffer_LCP = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -55144,12 +58667,12 @@ static PyBufferProcs __pyx_tp_as_buffer_StringMap = { #endif }; -static PyTypeObject __pyx_type_3_sa_StringMap = { +static PyTypeObject __pyx_type_3_sa_LCP = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.StringMap"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_StringMap), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.LCP"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_LCP), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_StringMap, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_LCP, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -55159,24 +58682,24 @@ static PyTypeObject __pyx_type_3_sa_StringMap = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_StringMap, /*tp_as_number*/ - &__pyx_tp_as_sequence_StringMap, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_StringMap, /*tp_as_mapping*/ + &__pyx_tp_as_number_LCP, /*tp_as_number*/ + &__pyx_tp_as_sequence_LCP, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_LCP, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_StringMap, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + &__pyx_tp_as_buffer_LCP, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_3_sa_LCP, /*tp_traverse*/ + __pyx_tp_clear_3_sa_LCP, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_StringMap, /*tp_methods*/ + __pyx_methods_3_sa_LCP, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -55186,7 +58709,7 @@ static PyTypeObject __pyx_type_3_sa_StringMap = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_StringMap, /*tp_new*/ + __pyx_tp_new_3_sa_LCP, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -55199,95 +58722,89 @@ static PyTypeObject __pyx_type_3_sa_StringMap = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_DataArray __pyx_vtable_3_sa_DataArray; +static struct __pyx_vtabstruct_3_sa_Alphabet __pyx_vtable_3_sa_Alphabet; -static PyObject *__pyx_tp_new_3_sa_DataArray(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_DataArray *p; +static PyObject *__pyx_tp_new_3_sa_Alphabet(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa_Alphabet *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_DataArray *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_DataArray; - p->word2id = Py_None; Py_INCREF(Py_None); - p->id2word = Py_None; Py_INCREF(Py_None); - p->data = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->sent_id = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_9DataArray_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_Alphabet *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_Alphabet; + p->terminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); + p->nonterminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); + p->id2sym = ((PyObject*)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_8Alphabet_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_DataArray(PyObject *o) { - struct __pyx_obj_3_sa_DataArray *p = (struct __pyx_obj_3_sa_DataArray *)o; - Py_XDECREF(p->word2id); - Py_XDECREF(p->id2word); - Py_XDECREF(((PyObject *)p->data)); - Py_XDECREF(((PyObject *)p->sent_id)); - Py_XDECREF(((PyObject *)p->sent_index)); +static void __pyx_tp_dealloc_3_sa_Alphabet(PyObject *o) { + struct __pyx_obj_3_sa_Alphabet *p = (struct __pyx_obj_3_sa_Alphabet *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_8Alphabet_3__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->terminals)); + Py_XDECREF(((PyObject *)p->nonterminals)); + Py_XDECREF(((PyObject *)p->id2sym)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_DataArray(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa_Alphabet(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_DataArray *p = (struct __pyx_obj_3_sa_DataArray *)o; - if (p->word2id) { - e = (*v)(p->word2id, a); if (e) return e; - } - if (p->id2word) { - e = (*v)(p->id2word, a); if (e) return e; - } - if (p->data) { - e = (*v)(((PyObject*)p->data), a); if (e) return e; + struct __pyx_obj_3_sa_Alphabet *p = (struct __pyx_obj_3_sa_Alphabet *)o; + if (p->terminals) { + e = (*v)(((PyObject*)p->terminals), a); if (e) return e; } - if (p->sent_id) { - e = (*v)(((PyObject*)p->sent_id), a); if (e) return e; + if (p->nonterminals) { + e = (*v)(((PyObject*)p->nonterminals), a); if (e) return e; } - if (p->sent_index) { - e = (*v)(((PyObject*)p->sent_index), a); if (e) return e; + if (p->id2sym) { + e = (*v)(p->id2sym, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_DataArray(PyObject *o) { - struct __pyx_obj_3_sa_DataArray *p = (struct __pyx_obj_3_sa_DataArray *)o; +static int __pyx_tp_clear_3_sa_Alphabet(PyObject *o) { + struct __pyx_obj_3_sa_Alphabet *p = (struct __pyx_obj_3_sa_Alphabet *)o; PyObject* tmp; - tmp = ((PyObject*)p->word2id); - p->word2id = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->id2word); - p->id2word = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->data); - p->data = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->terminals); + p->terminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->sent_id); - p->sent_id = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->nonterminals); + p->nonterminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->sent_index); - p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->id2sym); + p->id2sym = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_DataArray[] = { - {__Pyx_NAMESTR("getSentId"), (PyCFunction)__pyx_pw_3_sa_9DataArray_5getSentId, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getSent"), (PyCFunction)__pyx_pw_3_sa_9DataArray_7getSent, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getSentPos"), (PyCFunction)__pyx_pw_3_sa_9DataArray_9getSentPos, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_id"), (PyCFunction)__pyx_pw_3_sa_9DataArray_11get_id, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_word"), (PyCFunction)__pyx_pw_3_sa_9DataArray_13get_word, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_9DataArray_15write_text, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_9DataArray_17read_text, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_bitext"), (PyCFunction)__pyx_pw_3_sa_9DataArray_19read_bitext, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_text_data"), (PyCFunction)__pyx_pw_3_sa_9DataArray_21read_text_data, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_9DataArray_23read_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_9DataArray_25write_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_enhanced_handle"), (PyCFunction)__pyx_pw_3_sa_9DataArray_27write_enhanced_handle, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_9DataArray_29write_enhanced, METH_O, __Pyx_DOCSTR(0)}, +static PyObject *__pyx_getprop_3_sa_8Alphabet_terminals(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_8Alphabet_9terminals_1__get__(o); +} + +static PyObject *__pyx_getprop_3_sa_8Alphabet_nonterminals(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_8Alphabet_12nonterminals_1__get__(o); +} + +static PyMethodDef __pyx_methods_3_sa_Alphabet[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_DataArray = { +static struct PyGetSetDef __pyx_getsets_3_sa_Alphabet[] = { + {(char *)"terminals", __pyx_getprop_3_sa_8Alphabet_terminals, 0, 0, 0}, + {(char *)"nonterminals", __pyx_getprop_3_sa_8Alphabet_nonterminals, 0, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_Alphabet = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -55345,8 +58862,8 @@ static PyNumberMethods __pyx_tp_as_number_DataArray = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_DataArray = { - __pyx_pw_3_sa_9DataArray_3__len__, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_Alphabet = { + 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ @@ -55358,13 +58875,13 @@ static PySequenceMethods __pyx_tp_as_sequence_DataArray = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_DataArray = { - __pyx_pw_3_sa_9DataArray_3__len__, /*mp_length*/ +static PyMappingMethods __pyx_tp_as_mapping_Alphabet = { + 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_DataArray = { +static PyBufferProcs __pyx_tp_as_buffer_Alphabet = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -55385,12 +58902,12 @@ static PyBufferProcs __pyx_tp_as_buffer_DataArray = { #endif }; -static PyTypeObject __pyx_type_3_sa_DataArray = { +static PyTypeObject __pyx_type_3_sa_Alphabet = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.DataArray"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_DataArray), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.Alphabet"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Alphabet), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_DataArray, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_Alphabet, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -55400,26 +58917,26 @@ static PyTypeObject __pyx_type_3_sa_DataArray = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_DataArray, /*tp_as_number*/ - &__pyx_tp_as_sequence_DataArray, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_DataArray, /*tp_as_mapping*/ + &__pyx_tp_as_number_Alphabet, /*tp_as_number*/ + &__pyx_tp_as_sequence_Alphabet, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Alphabet, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_DataArray, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_Alphabet, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_DataArray, /*tp_traverse*/ - __pyx_tp_clear_3_sa_DataArray, /*tp_clear*/ + __pyx_tp_traverse_3_sa_Alphabet, /*tp_traverse*/ + __pyx_tp_clear_3_sa_Alphabet, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_DataArray, /*tp_methods*/ + __pyx_methods_3_sa_Alphabet, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_3_sa_Alphabet, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -55427,7 +58944,7 @@ static PyTypeObject __pyx_type_3_sa_DataArray = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_DataArray, /*tp_new*/ + __pyx_tp_new_3_sa_Alphabet, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -55440,66 +58957,41 @@ static PyTypeObject __pyx_type_3_sa_DataArray = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_Alignment __pyx_vtable_3_sa_Alignment; +static struct __pyx_vtabstruct_3_sa_TrieMap __pyx_vtable_3_sa_TrieMap; -static PyObject *__pyx_tp_new_3_sa_Alignment(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_Alignment *p; +static PyObject *__pyx_tp_new_3_sa_TrieMap(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_TrieMap *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_Alignment *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_Alignment; - p->links = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_9Alignment_5__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_TrieMap *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_TrieMap; + if (__pyx_pw_3_sa_7TrieMap_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_Alignment(PyObject *o) { - struct __pyx_obj_3_sa_Alignment *p = (struct __pyx_obj_3_sa_Alignment *)o; - Py_XDECREF(((PyObject *)p->links)); - Py_XDECREF(((PyObject *)p->sent_index)); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_3_sa_Alignment(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_3_sa_Alignment *p = (struct __pyx_obj_3_sa_Alignment *)o; - if (p->links) { - e = (*v)(((PyObject*)p->links), a); if (e) return e; - } - if (p->sent_index) { - e = (*v)(((PyObject*)p->sent_index), a); if (e) return e; +static void __pyx_tp_dealloc_3_sa_TrieMap(PyObject *o) { + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_7TrieMap_3__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); } - return 0; -} - -static int __pyx_tp_clear_3_sa_Alignment(PyObject *o) { - struct __pyx_obj_3_sa_Alignment *p = (struct __pyx_obj_3_sa_Alignment *)o; - PyObject* tmp; - tmp = ((PyObject*)p->links); - p->links = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->sent_index); - p->sent_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; + (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_3_sa_Alignment[] = { - {__Pyx_NAMESTR("unlink"), (PyCFunction)__pyx_pw_3_sa_9Alignment_1unlink, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_9Alignment_unlink)}, - {__Pyx_NAMESTR("get_sent_links"), (PyCFunction)__pyx_pw_3_sa_9Alignment_3get_sent_links, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_9Alignment_7read_text, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_9Alignment_9read_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_9Alignment_11write_text, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_9Alignment_13write_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_9Alignment_15write_enhanced, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("alignment"), (PyCFunction)__pyx_pw_3_sa_9Alignment_17alignment, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_9Alignment_16alignment)}, +static PyMethodDef __pyx_methods_3_sa_TrieMap[] = { + {__Pyx_NAMESTR("insert"), (PyCFunction)__pyx_pw_3_sa_7TrieMap_5insert, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("contains"), (PyCFunction)__pyx_pw_3_sa_7TrieMap_7contains, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("toMap"), (PyCFunction)__pyx_pw_3_sa_7TrieMap_9toMap, METH_O, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_Alignment = { +static PyNumberMethods __pyx_tp_as_number_TrieMap = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -55557,7 +59049,7 @@ static PyNumberMethods __pyx_tp_as_number_Alignment = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_Alignment = { +static PySequenceMethods __pyx_tp_as_sequence_TrieMap = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -55570,13 +59062,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Alignment = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_Alignment = { +static PyMappingMethods __pyx_tp_as_mapping_TrieMap = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_Alignment = { +static PyBufferProcs __pyx_tp_as_buffer_TrieMap = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -55597,12 +59089,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Alignment = { #endif }; -static PyTypeObject __pyx_type_3_sa_Alignment = { +static PyTypeObject __pyx_type_3_sa_TrieMap = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.Alignment"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_Alignment), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.TrieMap"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_TrieMap), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_Alignment, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_TrieMap, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -55612,24 +59104,24 @@ static PyTypeObject __pyx_type_3_sa_Alignment = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_Alignment, /*tp_as_number*/ - &__pyx_tp_as_sequence_Alignment, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Alignment, /*tp_as_mapping*/ + &__pyx_tp_as_number_TrieMap, /*tp_as_number*/ + &__pyx_tp_as_sequence_TrieMap, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_TrieMap, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Alignment, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + &__pyx_tp_as_buffer_TrieMap, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_Alignment, /*tp_traverse*/ - __pyx_tp_clear_3_sa_Alignment, /*tp_clear*/ + 0, /*tp_traverse*/ + 0, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_Alignment, /*tp_methods*/ + __pyx_methods_3_sa_TrieMap, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -55639,7 +59131,7 @@ static PyTypeObject __pyx_type_3_sa_Alignment = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_Alignment, /*tp_new*/ + __pyx_tp_new_3_sa_TrieMap, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -55652,114 +59144,61 @@ static PyTypeObject __pyx_type_3_sa_Alignment = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_BiLex __pyx_vtable_3_sa_BiLex; +static struct __pyx_vtabstruct_3_sa_Precomputation __pyx_vtable_3_sa_Precomputation; -static PyObject *__pyx_tp_new_3_sa_BiLex(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_BiLex *p; +static PyObject *__pyx_tp_new_3_sa_Precomputation(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_Precomputation *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_BiLex *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_BiLex; - p->col1 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); - p->col2 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); - p->f_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->e_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->id2eword = Py_None; Py_INCREF(Py_None); - p->id2fword = Py_None; Py_INCREF(Py_None); - p->eword2id = Py_None; Py_INCREF(Py_None); - p->fword2id = Py_None; Py_INCREF(Py_None); - if (__pyx_pw_3_sa_5BiLex_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_Precomputation *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_Precomputation; + p->precomputed_index = Py_None; Py_INCREF(Py_None); + p->precomputed_collocations = Py_None; Py_INCREF(Py_None); + if (__pyx_pw_3_sa_14Precomputation_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_BiLex(PyObject *o) { - struct __pyx_obj_3_sa_BiLex *p = (struct __pyx_obj_3_sa_BiLex *)o; - Py_XDECREF(((PyObject *)p->col1)); - Py_XDECREF(((PyObject *)p->col2)); - Py_XDECREF(((PyObject *)p->f_index)); - Py_XDECREF(((PyObject *)p->e_index)); - Py_XDECREF(p->id2eword); - Py_XDECREF(p->id2fword); - Py_XDECREF(p->eword2id); - Py_XDECREF(p->fword2id); +static void __pyx_tp_dealloc_3_sa_Precomputation(PyObject *o) { + struct __pyx_obj_3_sa_Precomputation *p = (struct __pyx_obj_3_sa_Precomputation *)o; + Py_XDECREF(p->precomputed_index); + Py_XDECREF(p->precomputed_collocations); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_BiLex(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa_Precomputation(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_BiLex *p = (struct __pyx_obj_3_sa_BiLex *)o; - if (p->col1) { - e = (*v)(((PyObject*)p->col1), a); if (e) return e; - } - if (p->col2) { - e = (*v)(((PyObject*)p->col2), a); if (e) return e; - } - if (p->f_index) { - e = (*v)(((PyObject*)p->f_index), a); if (e) return e; - } - if (p->e_index) { - e = (*v)(((PyObject*)p->e_index), a); if (e) return e; - } - if (p->id2eword) { - e = (*v)(p->id2eword, a); if (e) return e; - } - if (p->id2fword) { - e = (*v)(p->id2fword, a); if (e) return e; - } - if (p->eword2id) { - e = (*v)(p->eword2id, a); if (e) return e; + struct __pyx_obj_3_sa_Precomputation *p = (struct __pyx_obj_3_sa_Precomputation *)o; + if (p->precomputed_index) { + e = (*v)(p->precomputed_index, a); if (e) return e; } - if (p->fword2id) { - e = (*v)(p->fword2id, a); if (e) return e; + if (p->precomputed_collocations) { + e = (*v)(p->precomputed_collocations, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_BiLex(PyObject *o) { - struct __pyx_obj_3_sa_BiLex *p = (struct __pyx_obj_3_sa_BiLex *)o; +static int __pyx_tp_clear_3_sa_Precomputation(PyObject *o) { + struct __pyx_obj_3_sa_Precomputation *p = (struct __pyx_obj_3_sa_Precomputation *)o; PyObject* tmp; - tmp = ((PyObject*)p->col1); - p->col1 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->col2); - p->col2 = ((struct __pyx_obj_3_sa_FloatList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->f_index); - p->f_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->e_index); - p->e_index = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->id2eword); - p->id2eword = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->id2fword); - p->id2fword = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->eword2id); - p->eword2id = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->precomputed_index); + p->precomputed_index = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->fword2id); - p->fword2id = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->precomputed_collocations); + p->precomputed_collocations = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_BiLex[] = { - {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_5BiLex_3write_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_5BiLex_5read_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_e_id"), (PyCFunction)__pyx_pw_3_sa_5BiLex_7get_e_id, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_f_id"), (PyCFunction)__pyx_pw_3_sa_5BiLex_9get_f_id, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_5BiLex_11read_text, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_5BiLex_13write_enhanced, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_score"), (PyCFunction)__pyx_pw_3_sa_5BiLex_15get_score, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_5BiLex_17write_text, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_5BiLex_16write_text)}, +static PyMethodDef __pyx_methods_3_sa_Precomputation[] = { + {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_14Precomputation_3read_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_14Precomputation_5write_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("precompute"), (PyCFunction)__pyx_pw_3_sa_14Precomputation_7precompute, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_BiLex = { +static PyNumberMethods __pyx_tp_as_number_Precomputation = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -55817,7 +59256,7 @@ static PyNumberMethods __pyx_tp_as_number_BiLex = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_BiLex = { +static PySequenceMethods __pyx_tp_as_sequence_Precomputation = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -55830,13 +59269,13 @@ static PySequenceMethods __pyx_tp_as_sequence_BiLex = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_BiLex = { +static PyMappingMethods __pyx_tp_as_mapping_Precomputation = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_BiLex = { +static PyBufferProcs __pyx_tp_as_buffer_Precomputation = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -55857,12 +59296,12 @@ static PyBufferProcs __pyx_tp_as_buffer_BiLex = { #endif }; -static PyTypeObject __pyx_type_3_sa_BiLex = { +static PyTypeObject __pyx_type_3_sa_Precomputation = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.BiLex"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_BiLex), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.Precomputation"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Precomputation), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_BiLex, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_Precomputation, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -55872,24 +59311,24 @@ static PyTypeObject __pyx_type_3_sa_BiLex = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_BiLex, /*tp_as_number*/ - &__pyx_tp_as_sequence_BiLex, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_BiLex, /*tp_as_mapping*/ + &__pyx_tp_as_number_Precomputation, /*tp_as_number*/ + &__pyx_tp_as_sequence_Precomputation, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Precomputation, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_BiLex, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_Precomputation, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_BiLex, /*tp_traverse*/ - __pyx_tp_clear_3_sa_BiLex, /*tp_clear*/ + __pyx_tp_traverse_3_sa_Precomputation, /*tp_traverse*/ + __pyx_tp_clear_3_sa_Precomputation, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_BiLex, /*tp_methods*/ + __pyx_methods_3_sa_Precomputation, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -55899,7 +59338,7 @@ static PyTypeObject __pyx_type_3_sa_BiLex = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_BiLex, /*tp_new*/ + __pyx_tp_new_3_sa_Precomputation, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -55912,23 +59351,83 @@ static PyTypeObject __pyx_type_3_sa_BiLex = { 0, /*tp_version_tag*/ #endif }; +static struct __pyx_vtabstruct_3_sa_SuffixArray __pyx_vtable_3_sa_SuffixArray; -static PyObject *__pyx_tp_new_3_sa_BitSetIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { +static PyObject *__pyx_tp_new_3_sa_SuffixArray(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_SuffixArray *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; + p = ((struct __pyx_obj_3_sa_SuffixArray *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_SuffixArray; + p->darray = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->ha = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_11SuffixArray_1__cinit__(o, a, k) < 0) { + Py_DECREF(o); o = 0; + } return o; } -static void __pyx_tp_dealloc_3_sa_BitSetIterator(PyObject *o) { +static void __pyx_tp_dealloc_3_sa_SuffixArray(PyObject *o) { + struct __pyx_obj_3_sa_SuffixArray *p = (struct __pyx_obj_3_sa_SuffixArray *)o; + Py_XDECREF(((PyObject *)p->darray)); + Py_XDECREF(((PyObject *)p->sa)); + Py_XDECREF(((PyObject *)p->ha)); (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_3_sa_BitSetIterator[] = { - {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_3_sa_14BitSetIterator_1__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)}, +static int __pyx_tp_traverse_3_sa_SuffixArray(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_SuffixArray *p = (struct __pyx_obj_3_sa_SuffixArray *)o; + if (p->darray) { + e = (*v)(((PyObject*)p->darray), a); if (e) return e; + } + if (p->sa) { + e = (*v)(((PyObject*)p->sa), a); if (e) return e; + } + if (p->ha) { + e = (*v)(((PyObject*)p->ha), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_SuffixArray(PyObject *o) { + struct __pyx_obj_3_sa_SuffixArray *p = (struct __pyx_obj_3_sa_SuffixArray *)o; + PyObject* tmp; + tmp = ((PyObject*)p->darray); + p->darray = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->sa); + p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->ha); + p->ha = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} +static PyObject *__pyx_sq_item_3_sa_SuffixArray(PyObject *o, Py_ssize_t i) { + PyObject *r; + PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; + r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); + Py_DECREF(x); + return r; +} + +static PyMethodDef __pyx_methods_3_sa_SuffixArray[] = { + {__Pyx_NAMESTR("getSentId"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_5getSentId, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getSent"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_7getSent, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("getSentPos"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_9getSentPos, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_11read_text, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_11SuffixArray_10read_text)}, + {__Pyx_NAMESTR("q3sort"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_13q3sort, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_11SuffixArray_12q3sort)}, + {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_15write_text, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_17read_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_19write_binary, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_21write_enhanced, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("lookup"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_23lookup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_BitSetIterator = { +static PyNumberMethods __pyx_tp_as_number_SuffixArray = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -55986,11 +59485,11 @@ static PyNumberMethods __pyx_tp_as_number_BitSetIterator = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_BitSetIterator = { +static PySequenceMethods __pyx_tp_as_sequence_SuffixArray = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ - 0, /*sq_item*/ + __pyx_sq_item_3_sa_SuffixArray, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ @@ -55999,13 +59498,13 @@ static PySequenceMethods __pyx_tp_as_sequence_BitSetIterator = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_BitSetIterator = { +static PyMappingMethods __pyx_tp_as_mapping_SuffixArray = { 0, /*mp_length*/ - 0, /*mp_subscript*/ + __pyx_pw_3_sa_11SuffixArray_3__getitem__, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_BitSetIterator = { +static PyBufferProcs __pyx_tp_as_buffer_SuffixArray = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -56026,12 +59525,12 @@ static PyBufferProcs __pyx_tp_as_buffer_BitSetIterator = { #endif }; -static PyTypeObject __pyx_type_3_sa_BitSetIterator = { +static PyTypeObject __pyx_type_3_sa_SuffixArray = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.BitSetIterator"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_BitSetIterator), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.SuffixArray"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_SuffixArray), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_BitSetIterator, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_SuffixArray, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -56041,24 +59540,24 @@ static PyTypeObject __pyx_type_3_sa_BitSetIterator = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_BitSetIterator, /*tp_as_number*/ - &__pyx_tp_as_sequence_BitSetIterator, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_BitSetIterator, /*tp_as_mapping*/ + &__pyx_tp_as_number_SuffixArray, /*tp_as_number*/ + &__pyx_tp_as_sequence_SuffixArray, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_SuffixArray, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_BitSetIterator, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + &__pyx_tp_as_buffer_SuffixArray, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_3_sa_SuffixArray, /*tp_traverse*/ + __pyx_tp_clear_3_sa_SuffixArray, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ - __pyx_pw_3_sa_14BitSetIterator_1__next__, /*tp_iternext*/ - __pyx_methods_3_sa_BitSetIterator, /*tp_methods*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_SuffixArray, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -56068,7 +59567,7 @@ static PyTypeObject __pyx_type_3_sa_BitSetIterator = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_BitSetIterator, /*tp_new*/ + __pyx_tp_new_3_sa_SuffixArray, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -56081,38 +59580,47 @@ static PyTypeObject __pyx_type_3_sa_BitSetIterator = { 0, /*tp_version_tag*/ #endif }; +static struct __pyx_vtabstruct_3_sa_Scorer __pyx_vtable_3_sa_Scorer; -static PyObject *__pyx_tp_new_3_sa_BitSet(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { +static PyObject *__pyx_tp_new_3_sa_Scorer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa_Scorer *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - if (__pyx_pw_3_sa_6BitSet_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa_Scorer *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_Scorer; + p->models = Py_None; Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_3_sa_BitSet(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_6BitSet_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } +static void __pyx_tp_dealloc_3_sa_Scorer(PyObject *o) { + struct __pyx_obj_3_sa_Scorer *p = (struct __pyx_obj_3_sa_Scorer *)o; + Py_XDECREF(p->models); (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_3_sa_BitSet[] = { - {__Pyx_NAMESTR("insert"), (PyCFunction)__pyx_pw_3_sa_6BitSet_7insert, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("findsucc"), (PyCFunction)__pyx_pw_3_sa_6BitSet_9findsucc, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("min"), (PyCFunction)__pyx_pw_3_sa_6BitSet_13min, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("max"), (PyCFunction)__pyx_pw_3_sa_6BitSet_15max, METH_NOARGS, __Pyx_DOCSTR(0)}, +static int __pyx_tp_traverse_3_sa_Scorer(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_Scorer *p = (struct __pyx_obj_3_sa_Scorer *)o; + if (p->models) { + e = (*v)(p->models, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_Scorer(PyObject *o) { + struct __pyx_obj_3_sa_Scorer *p = (struct __pyx_obj_3_sa_Scorer *)o; + PyObject* tmp; + tmp = ((PyObject*)p->models); + p->models = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_Scorer[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_BitSet = { +static PyNumberMethods __pyx_tp_as_number_Scorer = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -56170,26 +59678,26 @@ static PyNumberMethods __pyx_tp_as_number_BitSet = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_BitSet = { - __pyx_pw_3_sa_6BitSet_17__len__, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_Scorer = { + 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ - __pyx_pw_3_sa_6BitSet_19__contains__, /*sq_contains*/ + 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_BitSet = { - __pyx_pw_3_sa_6BitSet_17__len__, /*mp_length*/ +static PyMappingMethods __pyx_tp_as_mapping_Scorer = { + 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_BitSet = { +static PyBufferProcs __pyx_tp_as_buffer_Scorer = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -56210,12 +59718,12 @@ static PyBufferProcs __pyx_tp_as_buffer_BitSet = { #endif }; -static PyTypeObject __pyx_type_3_sa_BitSet = { +static PyTypeObject __pyx_type_3_sa_Scorer = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.BitSet"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_BitSet), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.Scorer"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Scorer), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_BitSet, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_Scorer, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -56225,24 +59733,24 @@ static PyTypeObject __pyx_type_3_sa_BitSet = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_BitSet, /*tp_as_number*/ - &__pyx_tp_as_sequence_BitSet, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_BitSet, /*tp_as_mapping*/ + &__pyx_tp_as_number_Scorer, /*tp_as_number*/ + &__pyx_tp_as_sequence_Scorer, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Scorer, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ - __pyx_pw_3_sa_6BitSet_11__str__, /*tp_str*/ + 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_BitSet, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + &__pyx_tp_as_buffer_Scorer, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_3_sa_Scorer, /*tp_traverse*/ + __pyx_tp_clear_3_sa_Scorer, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - __pyx_pw_3_sa_6BitSet_5__iter__, /*tp_iter*/ + 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_BitSet, /*tp_methods*/ + __pyx_methods_3_sa_Scorer, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -56250,9 +59758,9 @@ static PyTypeObject __pyx_type_3_sa_BitSet = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_3_sa_6Scorer_1__init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_BitSet, /*tp_new*/ + __pyx_tp_new_3_sa_Scorer, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -56265,23 +59773,58 @@ static PyTypeObject __pyx_type_3_sa_BitSet = { 0, /*tp_version_tag*/ #endif }; +static struct __pyx_vtabstruct_3_sa_DefaultScorer __pyx_vtable_3_sa_DefaultScorer; -static PyObject *__pyx_tp_new_3_sa_VEBIterator(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - PyObject *o = (*t->tp_alloc)(t, 0); +static PyObject *__pyx_tp_new_3_sa_DefaultScorer(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_DefaultScorer *p; + PyObject *o = __pyx_tp_new_3_sa_Scorer(t, a, k); if (!o) return 0; + p = ((struct __pyx_obj_3_sa_DefaultScorer *)o); + p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_3_sa_Scorer*)__pyx_vtabptr_3_sa_DefaultScorer; + p->ttable = ((struct __pyx_obj_3_sa_BiLex *)Py_None); Py_INCREF(Py_None); return o; } -static void __pyx_tp_dealloc_3_sa_VEBIterator(PyObject *o) { - (*Py_TYPE(o)->tp_free)(o); +static void __pyx_tp_dealloc_3_sa_DefaultScorer(PyObject *o) { + struct __pyx_obj_3_sa_DefaultScorer *p = (struct __pyx_obj_3_sa_DefaultScorer *)o; + { + PyObject *etype, *eval, *etb; + PyErr_Fetch(&etype, &eval, &etb); + ++Py_REFCNT(o); + __pyx_pw_3_sa_13DefaultScorer_1__dealloc__(o); + if (PyErr_Occurred()) PyErr_WriteUnraisable(o); + --Py_REFCNT(o); + PyErr_Restore(etype, eval, etb); + } + Py_XDECREF(((PyObject *)p->ttable)); + __pyx_tp_dealloc_3_sa_Scorer(o); } -static PyMethodDef __pyx_methods_3_sa_VEBIterator[] = { - {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_3_sa_11VEBIterator_1__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)}, +static int __pyx_tp_traverse_3_sa_DefaultScorer(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_DefaultScorer *p = (struct __pyx_obj_3_sa_DefaultScorer *)o; + e = __pyx_tp_traverse_3_sa_Scorer(o, v, a); if (e) return e; + if (p->ttable) { + e = (*v)(((PyObject*)p->ttable), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_DefaultScorer(PyObject *o) { + struct __pyx_obj_3_sa_DefaultScorer *p = (struct __pyx_obj_3_sa_DefaultScorer *)o; + PyObject* tmp; + __pyx_tp_clear_3_sa_Scorer(o); + tmp = ((PyObject*)p->ttable); + p->ttable = ((struct __pyx_obj_3_sa_BiLex *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_DefaultScorer[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_VEBIterator = { +static PyNumberMethods __pyx_tp_as_number_DefaultScorer = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -56339,7 +59882,7 @@ static PyNumberMethods __pyx_tp_as_number_VEBIterator = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_VEBIterator = { +static PySequenceMethods __pyx_tp_as_sequence_DefaultScorer = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -56352,13 +59895,13 @@ static PySequenceMethods __pyx_tp_as_sequence_VEBIterator = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_VEBIterator = { +static PyMappingMethods __pyx_tp_as_mapping_DefaultScorer = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_VEBIterator = { +static PyBufferProcs __pyx_tp_as_buffer_DefaultScorer = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -56379,12 +59922,12 @@ static PyBufferProcs __pyx_tp_as_buffer_VEBIterator = { #endif }; -static PyTypeObject __pyx_type_3_sa_VEBIterator = { +static PyTypeObject __pyx_type_3_sa_DefaultScorer = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.VEBIterator"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_VEBIterator), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.DefaultScorer"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_DefaultScorer), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_VEBIterator, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_DefaultScorer, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -56394,24 +59937,24 @@ static PyTypeObject __pyx_type_3_sa_VEBIterator = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_VEBIterator, /*tp_as_number*/ - &__pyx_tp_as_sequence_VEBIterator, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_VEBIterator, /*tp_as_mapping*/ + &__pyx_tp_as_number_DefaultScorer, /*tp_as_number*/ + &__pyx_tp_as_sequence_DefaultScorer, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_DefaultScorer, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_VEBIterator, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + &__pyx_tp_as_buffer_DefaultScorer, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_3_sa_DefaultScorer, /*tp_traverse*/ + __pyx_tp_clear_3_sa_DefaultScorer, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ - __pyx_pw_3_sa_11VEBIterator_1__next__, /*tp_iternext*/ - __pyx_methods_3_sa_VEBIterator, /*tp_methods*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa_DefaultScorer, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -56419,9 +59962,9 @@ static PyTypeObject __pyx_type_3_sa_VEBIterator = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_3_sa_13DefaultScorer_3__init__, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_VEBIterator, /*tp_new*/ + __pyx_tp_new_3_sa_DefaultScorer, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -56434,40 +59977,66 @@ static PyTypeObject __pyx_type_3_sa_VEBIterator = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_VEB __pyx_vtable_3_sa_VEB; -static PyObject *__pyx_tp_new_3_sa_VEB(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_VEB *p; +static PyObject *__pyx_tp_new_3_sa_TrieNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa_TrieNode *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_VEB *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_VEB; - if (__pyx_pw_3_sa_3VEB_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_TrieNode *)o); + p->children = Py_None; Py_INCREF(Py_None); + if (__pyx_pw_3_sa_8TrieNode_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_VEB(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_3VEB_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } +static void __pyx_tp_dealloc_3_sa_TrieNode(PyObject *o) { + struct __pyx_obj_3_sa_TrieNode *p = (struct __pyx_obj_3_sa_TrieNode *)o; + Py_XDECREF(p->children); (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_3_sa_VEB[] = { - {__Pyx_NAMESTR("insert"), (PyCFunction)__pyx_pw_3_sa_3VEB_7insert, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("findsucc"), (PyCFunction)__pyx_pw_3_sa_3VEB_9findsucc, METH_O, __Pyx_DOCSTR(0)}, +static int __pyx_tp_traverse_3_sa_TrieNode(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_TrieNode *p = (struct __pyx_obj_3_sa_TrieNode *)o; + if (p->children) { + e = (*v)(p->children, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_TrieNode(PyObject *o) { + struct __pyx_obj_3_sa_TrieNode *p = (struct __pyx_obj_3_sa_TrieNode *)o; + PyObject* tmp; + tmp = ((PyObject*)p->children); + p->children = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyObject *__pyx_getprop_3_sa_8TrieNode_children(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_8TrieNode_8children_1__get__(o); +} + +static int __pyx_setprop_3_sa_8TrieNode_children(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_8TrieNode_8children_3__set__(o, v); + } + else { + return __pyx_pw_3_sa_8TrieNode_8children_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_3_sa_TrieNode[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_VEB = { +static struct PyGetSetDef __pyx_getsets_3_sa_TrieNode[] = { + {(char *)"children", __pyx_getprop_3_sa_8TrieNode_children, __pyx_setprop_3_sa_8TrieNode_children, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_TrieNode = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -56525,26 +60094,26 @@ static PyNumberMethods __pyx_tp_as_number_VEB = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_VEB = { - __pyx_pw_3_sa_3VEB_11__len__, /*sq_length*/ +static PySequenceMethods __pyx_tp_as_sequence_TrieNode = { + 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ - __pyx_pw_3_sa_3VEB_13__contains__, /*sq_contains*/ + 0, /*sq_contains*/ 0, /*sq_inplace_concat*/ 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_VEB = { - __pyx_pw_3_sa_3VEB_11__len__, /*mp_length*/ +static PyMappingMethods __pyx_tp_as_mapping_TrieNode = { + 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_VEB = { +static PyBufferProcs __pyx_tp_as_buffer_TrieNode = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -56565,12 +60134,12 @@ static PyBufferProcs __pyx_tp_as_buffer_VEB = { #endif }; -static PyTypeObject __pyx_type_3_sa_VEB = { +static PyTypeObject __pyx_type_3_sa_TrieNode = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.VEB"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_VEB), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.TrieNode"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_TrieNode), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_VEB, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_TrieNode, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -56580,26 +60149,26 @@ static PyTypeObject __pyx_type_3_sa_VEB = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_VEB, /*tp_as_number*/ - &__pyx_tp_as_sequence_VEB, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_VEB, /*tp_as_mapping*/ + &__pyx_tp_as_number_TrieNode, /*tp_as_number*/ + &__pyx_tp_as_sequence_TrieNode, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_TrieNode, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_VEB, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + &__pyx_tp_as_buffer_TrieNode, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_3_sa_TrieNode, /*tp_traverse*/ + __pyx_tp_clear_3_sa_TrieNode, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ - __pyx_pw_3_sa_3VEB_5__iter__, /*tp_iter*/ + 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_VEB, /*tp_methods*/ + __pyx_methods_3_sa_TrieNode, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_3_sa_TrieNode, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -56607,7 +60176,7 @@ static PyTypeObject __pyx_type_3_sa_VEB = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_VEB, /*tp_new*/ + __pyx_tp_new_3_sa_TrieNode, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -56621,56 +60190,111 @@ static PyTypeObject __pyx_type_3_sa_VEB = { #endif }; -static PyObject *__pyx_tp_new_3_sa_LCP(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_LCP *p; - PyObject *o = (*t->tp_alloc)(t, 0); +static PyObject *__pyx_tp_new_3_sa_ExtendedTrieNode(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_ExtendedTrieNode *p; + PyObject *o = __pyx_tp_new_3_sa_TrieNode(t, a, k); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_LCP *)o); - p->sa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); - p->lcp = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_3LCP_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_ExtendedTrieNode *)o); + p->phrase = Py_None; Py_INCREF(Py_None); + p->phrase_location = Py_None; Py_INCREF(Py_None); + p->suffix_link = Py_None; Py_INCREF(Py_None); + if (__pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_LCP(PyObject *o) { - struct __pyx_obj_3_sa_LCP *p = (struct __pyx_obj_3_sa_LCP *)o; - Py_XDECREF(((PyObject *)p->sa)); - Py_XDECREF(((PyObject *)p->lcp)); - (*Py_TYPE(o)->tp_free)(o); +static void __pyx_tp_dealloc_3_sa_ExtendedTrieNode(PyObject *o) { + struct __pyx_obj_3_sa_ExtendedTrieNode *p = (struct __pyx_obj_3_sa_ExtendedTrieNode *)o; + Py_XDECREF(p->phrase); + Py_XDECREF(p->phrase_location); + Py_XDECREF(p->suffix_link); + __pyx_tp_dealloc_3_sa_TrieNode(o); } -static int __pyx_tp_traverse_3_sa_LCP(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa_ExtendedTrieNode(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_LCP *p = (struct __pyx_obj_3_sa_LCP *)o; - if (p->sa) { - e = (*v)(((PyObject*)p->sa), a); if (e) return e; + struct __pyx_obj_3_sa_ExtendedTrieNode *p = (struct __pyx_obj_3_sa_ExtendedTrieNode *)o; + e = __pyx_tp_traverse_3_sa_TrieNode(o, v, a); if (e) return e; + if (p->phrase) { + e = (*v)(p->phrase, a); if (e) return e; } - if (p->lcp) { - e = (*v)(((PyObject*)p->lcp), a); if (e) return e; + if (p->phrase_location) { + e = (*v)(p->phrase_location, a); if (e) return e; + } + if (p->suffix_link) { + e = (*v)(p->suffix_link, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_LCP(PyObject *o) { - struct __pyx_obj_3_sa_LCP *p = (struct __pyx_obj_3_sa_LCP *)o; +static int __pyx_tp_clear_3_sa_ExtendedTrieNode(PyObject *o) { + struct __pyx_obj_3_sa_ExtendedTrieNode *p = (struct __pyx_obj_3_sa_ExtendedTrieNode *)o; PyObject* tmp; - tmp = ((PyObject*)p->sa); - p->sa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); + __pyx_tp_clear_3_sa_TrieNode(o); + tmp = ((PyObject*)p->phrase); + p->phrase = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->lcp); - p->lcp = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->phrase_location); + p->phrase_location = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->suffix_link); + p->suffix_link = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_LCP[] = { - {__Pyx_NAMESTR("compute_stats"), (PyCFunction)__pyx_pw_3_sa_3LCP_3compute_stats, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_3LCP_2compute_stats)}, +static PyObject *__pyx_getprop_3_sa_16ExtendedTrieNode_phrase(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_1__get__(o); +} + +static int __pyx_setprop_3_sa_16ExtendedTrieNode_phrase(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_3__set__(o, v); + } + else { + return __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_5__del__(o); + } +} + +static PyObject *__pyx_getprop_3_sa_16ExtendedTrieNode_phrase_location(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_1__get__(o); +} + +static int __pyx_setprop_3_sa_16ExtendedTrieNode_phrase_location(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_3__set__(o, v); + } + else { + return __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_5__del__(o); + } +} + +static PyObject *__pyx_getprop_3_sa_16ExtendedTrieNode_suffix_link(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_1__get__(o); +} + +static int __pyx_setprop_3_sa_16ExtendedTrieNode_suffix_link(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_3__set__(o, v); + } + else { + return __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_3_sa_ExtendedTrieNode[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_LCP = { +static struct PyGetSetDef __pyx_getsets_3_sa_ExtendedTrieNode[] = { + {(char *)"phrase", __pyx_getprop_3_sa_16ExtendedTrieNode_phrase, __pyx_setprop_3_sa_16ExtendedTrieNode_phrase, 0, 0}, + {(char *)"phrase_location", __pyx_getprop_3_sa_16ExtendedTrieNode_phrase_location, __pyx_setprop_3_sa_16ExtendedTrieNode_phrase_location, 0, 0}, + {(char *)"suffix_link", __pyx_getprop_3_sa_16ExtendedTrieNode_suffix_link, __pyx_setprop_3_sa_16ExtendedTrieNode_suffix_link, 0, 0}, + {0, 0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number_ExtendedTrieNode = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -56728,7 +60352,7 @@ static PyNumberMethods __pyx_tp_as_number_LCP = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_LCP = { +static PySequenceMethods __pyx_tp_as_sequence_ExtendedTrieNode = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -56741,13 +60365,13 @@ static PySequenceMethods __pyx_tp_as_sequence_LCP = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_LCP = { +static PyMappingMethods __pyx_tp_as_mapping_ExtendedTrieNode = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_LCP = { +static PyBufferProcs __pyx_tp_as_buffer_ExtendedTrieNode = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -56768,12 +60392,12 @@ static PyBufferProcs __pyx_tp_as_buffer_LCP = { #endif }; -static PyTypeObject __pyx_type_3_sa_LCP = { +static PyTypeObject __pyx_type_3_sa_ExtendedTrieNode = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.LCP"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_LCP), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.ExtendedTrieNode"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_ExtendedTrieNode), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_LCP, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_ExtendedTrieNode, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -56783,26 +60407,26 @@ static PyTypeObject __pyx_type_3_sa_LCP = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_LCP, /*tp_as_number*/ - &__pyx_tp_as_sequence_LCP, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_LCP, /*tp_as_mapping*/ + &__pyx_tp_as_number_ExtendedTrieNode, /*tp_as_number*/ + &__pyx_tp_as_sequence_ExtendedTrieNode, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_ExtendedTrieNode, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_LCP, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_ExtendedTrieNode, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_LCP, /*tp_traverse*/ - __pyx_tp_clear_3_sa_LCP, /*tp_clear*/ + __pyx_tp_traverse_3_sa_ExtendedTrieNode, /*tp_traverse*/ + __pyx_tp_clear_3_sa_ExtendedTrieNode, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_LCP, /*tp_methods*/ + __pyx_methods_3_sa_ExtendedTrieNode, /*tp_methods*/ 0, /*tp_members*/ - 0, /*tp_getset*/ + __pyx_getsets_3_sa_ExtendedTrieNode, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -56810,7 +60434,7 @@ static PyTypeObject __pyx_type_3_sa_LCP = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_LCP, /*tp_new*/ + __pyx_tp_new_3_sa_ExtendedTrieNode, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -56823,89 +60447,96 @@ static PyTypeObject __pyx_type_3_sa_LCP = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_Alphabet __pyx_vtable_3_sa_Alphabet; -static PyObject *__pyx_tp_new_3_sa_Alphabet(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa_Alphabet *p; +static PyObject *__pyx_tp_new_3_sa_TrieTable(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_TrieTable *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_Alphabet *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_Alphabet; - p->terminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); - p->nonterminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); - p->id2sym = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_8Alphabet_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { + p = ((struct __pyx_obj_3_sa_TrieTable *)o); + p->root = Py_None; Py_INCREF(Py_None); + if (__pyx_pw_3_sa_9TrieTable_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_Alphabet(PyObject *o) { - struct __pyx_obj_3_sa_Alphabet *p = (struct __pyx_obj_3_sa_Alphabet *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_8Alphabet_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(((PyObject *)p->terminals)); - Py_XDECREF(((PyObject *)p->nonterminals)); - Py_XDECREF(((PyObject *)p->id2sym)); +static void __pyx_tp_dealloc_3_sa_TrieTable(PyObject *o) { + struct __pyx_obj_3_sa_TrieTable *p = (struct __pyx_obj_3_sa_TrieTable *)o; + Py_XDECREF(p->root); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_Alphabet(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa_TrieTable(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_Alphabet *p = (struct __pyx_obj_3_sa_Alphabet *)o; - if (p->terminals) { - e = (*v)(((PyObject*)p->terminals), a); if (e) return e; - } - if (p->nonterminals) { - e = (*v)(((PyObject*)p->nonterminals), a); if (e) return e; - } - if (p->id2sym) { - e = (*v)(p->id2sym, a); if (e) return e; + struct __pyx_obj_3_sa_TrieTable *p = (struct __pyx_obj_3_sa_TrieTable *)o; + if (p->root) { + e = (*v)(p->root, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_Alphabet(PyObject *o) { - struct __pyx_obj_3_sa_Alphabet *p = (struct __pyx_obj_3_sa_Alphabet *)o; +static int __pyx_tp_clear_3_sa_TrieTable(PyObject *o) { + struct __pyx_obj_3_sa_TrieTable *p = (struct __pyx_obj_3_sa_TrieTable *)o; PyObject* tmp; - tmp = ((PyObject*)p->terminals); - p->terminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->nonterminals); - p->nonterminals = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->id2sym); - p->id2sym = ((PyObject*)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->root); + p->root = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyObject *__pyx_getprop_3_sa_8Alphabet_terminals(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_8Alphabet_9terminals_1__get__(o); +static PyObject *__pyx_getprop_3_sa_9TrieTable_extended(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_9TrieTable_8extended_1__get__(o); +} + +static int __pyx_setprop_3_sa_9TrieTable_extended(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_9TrieTable_8extended_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } +} + +static PyObject *__pyx_getprop_3_sa_9TrieTable_count(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_9TrieTable_5count_1__get__(o); +} + +static int __pyx_setprop_3_sa_9TrieTable_count(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_9TrieTable_5count_3__set__(o, v); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "__del__"); + return -1; + } } -static PyObject *__pyx_getprop_3_sa_8Alphabet_nonterminals(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_8Alphabet_12nonterminals_1__get__(o); +static PyObject *__pyx_getprop_3_sa_9TrieTable_root(PyObject *o, CYTHON_UNUSED void *x) { + return __pyx_pw_3_sa_9TrieTable_4root_1__get__(o); } -static PyMethodDef __pyx_methods_3_sa_Alphabet[] = { +static int __pyx_setprop_3_sa_9TrieTable_root(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { + if (v) { + return __pyx_pw_3_sa_9TrieTable_4root_3__set__(o, v); + } + else { + return __pyx_pw_3_sa_9TrieTable_4root_5__del__(o); + } +} + +static PyMethodDef __pyx_methods_3_sa_TrieTable[] = { {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_3_sa_Alphabet[] = { - {(char *)"terminals", __pyx_getprop_3_sa_8Alphabet_terminals, 0, 0, 0}, - {(char *)"nonterminals", __pyx_getprop_3_sa_8Alphabet_nonterminals, 0, 0, 0}, +static struct PyGetSetDef __pyx_getsets_3_sa_TrieTable[] = { + {(char *)"extended", __pyx_getprop_3_sa_9TrieTable_extended, __pyx_setprop_3_sa_9TrieTable_extended, 0, 0}, + {(char *)"count", __pyx_getprop_3_sa_9TrieTable_count, __pyx_setprop_3_sa_9TrieTable_count, 0, 0}, + {(char *)"root", __pyx_getprop_3_sa_9TrieTable_root, __pyx_setprop_3_sa_9TrieTable_root, 0, 0}, {0, 0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_Alphabet = { +static PyNumberMethods __pyx_tp_as_number_TrieTable = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -56963,7 +60594,7 @@ static PyNumberMethods __pyx_tp_as_number_Alphabet = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_Alphabet = { +static PySequenceMethods __pyx_tp_as_sequence_TrieTable = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -56976,13 +60607,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Alphabet = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_Alphabet = { +static PyMappingMethods __pyx_tp_as_mapping_TrieTable = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_Alphabet = { +static PyBufferProcs __pyx_tp_as_buffer_TrieTable = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -57003,12 +60634,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Alphabet = { #endif }; -static PyTypeObject __pyx_type_3_sa_Alphabet = { +static PyTypeObject __pyx_type_3_sa_TrieTable = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.Alphabet"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_Alphabet), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.TrieTable"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_TrieTable), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_Alphabet, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_TrieTable, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -57018,26 +60649,26 @@ static PyTypeObject __pyx_type_3_sa_Alphabet = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_Alphabet, /*tp_as_number*/ - &__pyx_tp_as_sequence_Alphabet, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Alphabet, /*tp_as_mapping*/ + &__pyx_tp_as_number_TrieTable, /*tp_as_number*/ + &__pyx_tp_as_sequence_TrieTable, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_TrieTable, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Alphabet, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_TrieTable, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_Alphabet, /*tp_traverse*/ - __pyx_tp_clear_3_sa_Alphabet, /*tp_clear*/ + __pyx_tp_traverse_3_sa_TrieTable, /*tp_traverse*/ + __pyx_tp_clear_3_sa_TrieTable, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_Alphabet, /*tp_methods*/ + __pyx_methods_3_sa_TrieTable, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_3_sa_Alphabet, /*tp_getset*/ + __pyx_getsets_3_sa_TrieTable, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -57045,7 +60676,7 @@ static PyTypeObject __pyx_type_3_sa_Alphabet = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_Alphabet, /*tp_new*/ + __pyx_tp_new_3_sa_TrieTable, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -57058,41 +60689,50 @@ static PyTypeObject __pyx_type_3_sa_Alphabet = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_TrieMap __pyx_vtable_3_sa_TrieMap; +static struct __pyx_vtabstruct_3_sa_PhraseLocation __pyx_vtable_3_sa_PhraseLocation; -static PyObject *__pyx_tp_new_3_sa_TrieMap(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_TrieMap *p; +static PyObject *__pyx_tp_new_3_sa_PhraseLocation(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_PhraseLocation *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_TrieMap *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_TrieMap; - if (__pyx_pw_3_sa_7TrieMap_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_PhraseLocation *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_PhraseLocation; + p->arr = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_14PhraseLocation_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_TrieMap(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++Py_REFCNT(o); - __pyx_pw_3_sa_7TrieMap_3__dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --Py_REFCNT(o); - PyErr_Restore(etype, eval, etb); - } +static void __pyx_tp_dealloc_3_sa_PhraseLocation(PyObject *o) { + struct __pyx_obj_3_sa_PhraseLocation *p = (struct __pyx_obj_3_sa_PhraseLocation *)o; + Py_XDECREF(((PyObject *)p->arr)); (*Py_TYPE(o)->tp_free)(o); } -static PyMethodDef __pyx_methods_3_sa_TrieMap[] = { - {__Pyx_NAMESTR("insert"), (PyCFunction)__pyx_pw_3_sa_7TrieMap_5insert, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("contains"), (PyCFunction)__pyx_pw_3_sa_7TrieMap_7contains, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("toMap"), (PyCFunction)__pyx_pw_3_sa_7TrieMap_9toMap, METH_O, __Pyx_DOCSTR(0)}, +static int __pyx_tp_traverse_3_sa_PhraseLocation(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa_PhraseLocation *p = (struct __pyx_obj_3_sa_PhraseLocation *)o; + if (p->arr) { + e = (*v)(((PyObject*)p->arr), a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa_PhraseLocation(PyObject *o) { + struct __pyx_obj_3_sa_PhraseLocation *p = (struct __pyx_obj_3_sa_PhraseLocation *)o; + PyObject* tmp; + tmp = ((PyObject*)p->arr); + p->arr = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa_PhraseLocation[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_TrieMap = { +static PyNumberMethods __pyx_tp_as_number_PhraseLocation = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -57150,7 +60790,7 @@ static PyNumberMethods __pyx_tp_as_number_TrieMap = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_TrieMap = { +static PySequenceMethods __pyx_tp_as_sequence_PhraseLocation = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -57163,13 +60803,13 @@ static PySequenceMethods __pyx_tp_as_sequence_TrieMap = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_TrieMap = { +static PyMappingMethods __pyx_tp_as_mapping_PhraseLocation = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_TrieMap = { +static PyBufferProcs __pyx_tp_as_buffer_PhraseLocation = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -57190,12 +60830,12 @@ static PyBufferProcs __pyx_tp_as_buffer_TrieMap = { #endif }; -static PyTypeObject __pyx_type_3_sa_TrieMap = { +static PyTypeObject __pyx_type_3_sa_PhraseLocation = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.TrieMap"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_TrieMap), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.PhraseLocation"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_PhraseLocation), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_TrieMap, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_PhraseLocation, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -57205,24 +60845,24 @@ static PyTypeObject __pyx_type_3_sa_TrieMap = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_TrieMap, /*tp_as_number*/ - &__pyx_tp_as_sequence_TrieMap, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_TrieMap, /*tp_as_mapping*/ + &__pyx_tp_as_number_PhraseLocation, /*tp_as_number*/ + &__pyx_tp_as_sequence_PhraseLocation, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_PhraseLocation, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_TrieMap, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/ + &__pyx_tp_as_buffer_PhraseLocation, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ + __pyx_tp_traverse_3_sa_PhraseLocation, /*tp_traverse*/ + __pyx_tp_clear_3_sa_PhraseLocation, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_TrieMap, /*tp_methods*/ + __pyx_methods_3_sa_PhraseLocation, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -57232,7 +60872,7 @@ static PyTypeObject __pyx_type_3_sa_TrieMap = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_TrieMap, /*tp_new*/ + __pyx_tp_new_3_sa_PhraseLocation, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -57245,61 +60885,49 @@ static PyTypeObject __pyx_type_3_sa_TrieMap = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_Precomputation __pyx_vtable_3_sa_Precomputation; -static PyObject *__pyx_tp_new_3_sa_Precomputation(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_Precomputation *p; +static PyObject *__pyx_tp_new_3_sa_Sampler(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_Sampler *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_Precomputation *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_Precomputation; - p->precomputed_index = Py_None; Py_INCREF(Py_None); - p->precomputed_collocations = Py_None; Py_INCREF(Py_None); - if (__pyx_pw_3_sa_14Precomputation_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_Sampler *)o); + p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_7Sampler_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_Precomputation(PyObject *o) { - struct __pyx_obj_3_sa_Precomputation *p = (struct __pyx_obj_3_sa_Precomputation *)o; - Py_XDECREF(p->precomputed_index); - Py_XDECREF(p->precomputed_collocations); +static void __pyx_tp_dealloc_3_sa_Sampler(PyObject *o) { + struct __pyx_obj_3_sa_Sampler *p = (struct __pyx_obj_3_sa_Sampler *)o; + Py_XDECREF(((PyObject *)p->sa)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_Precomputation(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa_Sampler(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_Precomputation *p = (struct __pyx_obj_3_sa_Precomputation *)o; - if (p->precomputed_index) { - e = (*v)(p->precomputed_index, a); if (e) return e; - } - if (p->precomputed_collocations) { - e = (*v)(p->precomputed_collocations, a); if (e) return e; + struct __pyx_obj_3_sa_Sampler *p = (struct __pyx_obj_3_sa_Sampler *)o; + if (p->sa) { + e = (*v)(((PyObject*)p->sa), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_Precomputation(PyObject *o) { - struct __pyx_obj_3_sa_Precomputation *p = (struct __pyx_obj_3_sa_Precomputation *)o; +static int __pyx_tp_clear_3_sa_Sampler(PyObject *o) { + struct __pyx_obj_3_sa_Sampler *p = (struct __pyx_obj_3_sa_Sampler *)o; PyObject* tmp; - tmp = ((PyObject*)p->precomputed_index); - p->precomputed_index = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->precomputed_collocations); - p->precomputed_collocations = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->sa); + p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_Precomputation[] = { - {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_14Precomputation_3read_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_14Precomputation_5write_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("precompute"), (PyCFunction)__pyx_pw_3_sa_14Precomputation_7precompute, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_3_sa_Sampler[] = { + {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_3_sa_7Sampler_3sample, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_7Sampler_2sample)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_Precomputation = { +static PyNumberMethods __pyx_tp_as_number_Sampler = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -57357,7 +60985,7 @@ static PyNumberMethods __pyx_tp_as_number_Precomputation = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_Precomputation = { +static PySequenceMethods __pyx_tp_as_sequence_Sampler = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -57370,13 +60998,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Precomputation = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_Precomputation = { +static PyMappingMethods __pyx_tp_as_mapping_Sampler = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_Precomputation = { +static PyBufferProcs __pyx_tp_as_buffer_Sampler = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -57397,12 +61025,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Precomputation = { #endif }; -static PyTypeObject __pyx_type_3_sa_Precomputation = { +static PyTypeObject __pyx_type_3_sa_Sampler = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.Precomputation"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_Precomputation), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.Sampler"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_Sampler), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_Precomputation, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_Sampler, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -57412,24 +61040,24 @@ static PyTypeObject __pyx_type_3_sa_Precomputation = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_Precomputation, /*tp_as_number*/ - &__pyx_tp_as_sequence_Precomputation, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Precomputation, /*tp_as_mapping*/ + &__pyx_tp_as_number_Sampler, /*tp_as_number*/ + &__pyx_tp_as_sequence_Sampler, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_Sampler, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Precomputation, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_Sampler, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_Precomputation, /*tp_traverse*/ - __pyx_tp_clear_3_sa_Precomputation, /*tp_clear*/ + __Pyx_DOCSTR("A Sampler implements a logic for choosing\n samples from a population range"), /*tp_doc*/ + __pyx_tp_traverse_3_sa_Sampler, /*tp_traverse*/ + __pyx_tp_clear_3_sa_Sampler, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_Precomputation, /*tp_methods*/ + __pyx_methods_3_sa_Sampler, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -57439,7 +61067,7 @@ static PyTypeObject __pyx_type_3_sa_Precomputation = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_Precomputation, /*tp_new*/ + __pyx_tp_new_3_sa_Sampler, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -57452,83 +61080,181 @@ static PyTypeObject __pyx_type_3_sa_Precomputation = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_SuffixArray __pyx_vtable_3_sa_SuffixArray; +static struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory __pyx_vtable_3_sa_HieroCachingRuleFactory; -static PyObject *__pyx_tp_new_3_sa_SuffixArray(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_SuffixArray *p; +static PyObject *__pyx_tp_new_3_sa_HieroCachingRuleFactory(PyTypeObject *t, PyObject *a, PyObject *k) { + struct __pyx_obj_3_sa_HieroCachingRuleFactory *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_SuffixArray *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_SuffixArray; - p->darray = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); - p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->ha = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_11SuffixArray_1__cinit__(o, a, k) < 0) { + p = ((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o); + p->__pyx_vtab = __pyx_vtabptr_3_sa_HieroCachingRuleFactory; + p->rules = ((struct __pyx_obj_3_sa_TrieTable *)Py_None); Py_INCREF(Py_None); + p->sampler = ((struct __pyx_obj_3_sa_Sampler *)Py_None); Py_INCREF(Py_None); + p->scorer = ((struct __pyx_obj_3_sa_Scorer *)Py_None); Py_INCREF(Py_None); + p->precomputed_index = Py_None; Py_INCREF(Py_None); + p->precomputed_collocations = Py_None; Py_INCREF(Py_None); + p->precompute_file = Py_None; Py_INCREF(Py_None); + p->max_rank = Py_None; Py_INCREF(Py_None); + p->prev_norm_prefix = Py_None; Py_INCREF(Py_None); + p->fsa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); + p->fda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + p->eda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + p->alignment = ((struct __pyx_obj_3_sa_Alignment *)Py_None); Py_INCREF(Py_None); + p->eid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->fid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->findexes = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + p->findexes1 = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + if (__pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(o, a, k) < 0) { Py_DECREF(o); o = 0; } return o; } -static void __pyx_tp_dealloc_3_sa_SuffixArray(PyObject *o) { - struct __pyx_obj_3_sa_SuffixArray *p = (struct __pyx_obj_3_sa_SuffixArray *)o; - Py_XDECREF(((PyObject *)p->darray)); - Py_XDECREF(((PyObject *)p->sa)); - Py_XDECREF(((PyObject *)p->ha)); +static void __pyx_tp_dealloc_3_sa_HieroCachingRuleFactory(PyObject *o) { + struct __pyx_obj_3_sa_HieroCachingRuleFactory *p = (struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o; + Py_XDECREF(((PyObject *)p->rules)); + Py_XDECREF(((PyObject *)p->sampler)); + Py_XDECREF(((PyObject *)p->scorer)); + Py_XDECREF(p->precomputed_index); + Py_XDECREF(p->precomputed_collocations); + Py_XDECREF(p->precompute_file); + Py_XDECREF(p->max_rank); + Py_XDECREF(p->prev_norm_prefix); + Py_XDECREF(((PyObject *)p->fsa)); + Py_XDECREF(((PyObject *)p->fda)); + Py_XDECREF(((PyObject *)p->eda)); + Py_XDECREF(((PyObject *)p->alignment)); + Py_XDECREF(((PyObject *)p->eid2symid)); + Py_XDECREF(((PyObject *)p->fid2symid)); + Py_XDECREF(((PyObject *)p->findexes)); + Py_XDECREF(((PyObject *)p->findexes1)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_SuffixArray(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa_HieroCachingRuleFactory(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_SuffixArray *p = (struct __pyx_obj_3_sa_SuffixArray *)o; - if (p->darray) { - e = (*v)(((PyObject*)p->darray), a); if (e) return e; + struct __pyx_obj_3_sa_HieroCachingRuleFactory *p = (struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o; + if (p->rules) { + e = (*v)(((PyObject*)p->rules), a); if (e) return e; } - if (p->sa) { - e = (*v)(((PyObject*)p->sa), a); if (e) return e; + if (p->sampler) { + e = (*v)(((PyObject*)p->sampler), a); if (e) return e; } - if (p->ha) { - e = (*v)(((PyObject*)p->ha), a); if (e) return e; + if (p->scorer) { + e = (*v)(((PyObject*)p->scorer), a); if (e) return e; + } + if (p->precomputed_index) { + e = (*v)(p->precomputed_index, a); if (e) return e; + } + if (p->precomputed_collocations) { + e = (*v)(p->precomputed_collocations, a); if (e) return e; + } + if (p->precompute_file) { + e = (*v)(p->precompute_file, a); if (e) return e; + } + if (p->max_rank) { + e = (*v)(p->max_rank, a); if (e) return e; + } + if (p->prev_norm_prefix) { + e = (*v)(p->prev_norm_prefix, a); if (e) return e; + } + if (p->fsa) { + e = (*v)(((PyObject*)p->fsa), a); if (e) return e; + } + if (p->fda) { + e = (*v)(((PyObject*)p->fda), a); if (e) return e; + } + if (p->eda) { + e = (*v)(((PyObject*)p->eda), a); if (e) return e; + } + if (p->alignment) { + e = (*v)(((PyObject*)p->alignment), a); if (e) return e; + } + if (p->eid2symid) { + e = (*v)(((PyObject*)p->eid2symid), a); if (e) return e; + } + if (p->fid2symid) { + e = (*v)(((PyObject*)p->fid2symid), a); if (e) return e; + } + if (p->findexes) { + e = (*v)(((PyObject*)p->findexes), a); if (e) return e; + } + if (p->findexes1) { + e = (*v)(((PyObject*)p->findexes1), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_SuffixArray(PyObject *o) { - struct __pyx_obj_3_sa_SuffixArray *p = (struct __pyx_obj_3_sa_SuffixArray *)o; +static int __pyx_tp_clear_3_sa_HieroCachingRuleFactory(PyObject *o) { + struct __pyx_obj_3_sa_HieroCachingRuleFactory *p = (struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o; PyObject* tmp; - tmp = ((PyObject*)p->darray); - p->darray = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->rules); + p->rules = ((struct __pyx_obj_3_sa_TrieTable *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->sa); - p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->sampler); + p->sampler = ((struct __pyx_obj_3_sa_Sampler *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->ha); - p->ha = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->scorer); + p->scorer = ((struct __pyx_obj_3_sa_Scorer *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->precomputed_index); + p->precomputed_index = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->precomputed_collocations); + p->precomputed_collocations = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->precompute_file); + p->precompute_file = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->max_rank); + p->max_rank = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->prev_norm_prefix); + p->prev_norm_prefix = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->fsa); + p->fsa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->fda); + p->fda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->eda); + p->eda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->alignment); + p->alignment = ((struct __pyx_obj_3_sa_Alignment *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->eid2symid); + p->eid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->fid2symid); + p->fid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->findexes); + p->findexes = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->findexes1); + p->findexes1 = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyObject *__pyx_sq_item_3_sa_SuffixArray(PyObject *o, Py_ssize_t i) { - PyObject *r; - PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0; - r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x); - Py_DECREF(x); - return r; -} -static PyMethodDef __pyx_methods_3_sa_SuffixArray[] = { - {__Pyx_NAMESTR("getSentId"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_5getSentId, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getSent"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_7getSent, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("getSentPos"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_9getSentPos, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_text"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_11read_text, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_11SuffixArray_10read_text)}, - {__Pyx_NAMESTR("q3sort"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_13q3sort, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_11SuffixArray_12q3sort)}, - {__Pyx_NAMESTR("write_text"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_15write_text, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("read_binary"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_17read_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_binary"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_19write_binary, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("write_enhanced"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_21write_enhanced, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("lookup"), (PyCFunction)__pyx_pw_3_sa_11SuffixArray_23lookup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, +static PyMethodDef __pyx_methods_3_sa_HieroCachingRuleFactory[] = { + {__Pyx_NAMESTR("configure"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_3configure, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_23HieroCachingRuleFactory_2configure)}, + {__Pyx_NAMESTR("pattern2phrase"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_5pattern2phrase, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("pattern2phrase_plus"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_7pattern2phrase_plus, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("precompute"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_9precompute, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_precomputed_collocation"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_11get_precomputed_collocation, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("advance"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_13advance, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_all_nodes_isteps_away"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_15get_all_nodes_isteps_away, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("reachable"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_17reachable, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("shortest"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_19shortest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("get_next_states"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_21get_next_states, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("input"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_23input, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_23HieroCachingRuleFactory_22input)}, {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_SuffixArray = { +static PyNumberMethods __pyx_tp_as_number_HieroCachingRuleFactory = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -57586,11 +61312,11 @@ static PyNumberMethods __pyx_tp_as_number_SuffixArray = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_SuffixArray = { +static PySequenceMethods __pyx_tp_as_sequence_HieroCachingRuleFactory = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ - __pyx_sq_item_3_sa_SuffixArray, /*sq_item*/ + 0, /*sq_item*/ 0, /*sq_slice*/ 0, /*sq_ass_item*/ 0, /*sq_ass_slice*/ @@ -57599,13 +61325,13 @@ static PySequenceMethods __pyx_tp_as_sequence_SuffixArray = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_SuffixArray = { +static PyMappingMethods __pyx_tp_as_mapping_HieroCachingRuleFactory = { 0, /*mp_length*/ - __pyx_pw_3_sa_11SuffixArray_3__getitem__, /*mp_subscript*/ + 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_SuffixArray = { +static PyBufferProcs __pyx_tp_as_buffer_HieroCachingRuleFactory = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -57626,12 +61352,12 @@ static PyBufferProcs __pyx_tp_as_buffer_SuffixArray = { #endif }; -static PyTypeObject __pyx_type_3_sa_SuffixArray = { +static PyTypeObject __pyx_type_3_sa_HieroCachingRuleFactory = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.SuffixArray"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_SuffixArray), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.HieroCachingRuleFactory"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa_HieroCachingRuleFactory), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_SuffixArray, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa_HieroCachingRuleFactory, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -57641,24 +61367,24 @@ static PyTypeObject __pyx_type_3_sa_SuffixArray = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_SuffixArray, /*tp_as_number*/ - &__pyx_tp_as_sequence_SuffixArray, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_SuffixArray, /*tp_as_mapping*/ + &__pyx_tp_as_number_HieroCachingRuleFactory, /*tp_as_number*/ + &__pyx_tp_as_sequence_HieroCachingRuleFactory, /*tp_as_sequence*/ + &__pyx_tp_as_mapping_HieroCachingRuleFactory, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_SuffixArray, /*tp_as_buffer*/ + &__pyx_tp_as_buffer_HieroCachingRuleFactory, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_SuffixArray, /*tp_traverse*/ - __pyx_tp_clear_3_sa_SuffixArray, /*tp_clear*/ + __Pyx_DOCSTR("This RuleFactory implements a caching \n method using TrieTable, which makes phrase\n generation somewhat speedier -- phrases only\n need to be extracted once (however, it is\n quite possible they need to be scored \n for each input sentence, for contextual models)"), /*tp_doc*/ + __pyx_tp_traverse_3_sa_HieroCachingRuleFactory, /*tp_traverse*/ + __pyx_tp_clear_3_sa_HieroCachingRuleFactory, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_SuffixArray, /*tp_methods*/ + __pyx_methods_3_sa_HieroCachingRuleFactory, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -57668,7 +61394,7 @@ static PyTypeObject __pyx_type_3_sa_SuffixArray = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_SuffixArray, /*tp_new*/ + __pyx_tp_new_3_sa_HieroCachingRuleFactory, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -57682,65 +61408,44 @@ static PyTypeObject __pyx_type_3_sa_SuffixArray = { #endif }; -static PyObject *__pyx_tp_new_3_sa_TrieNode(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa_TrieNode *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct____iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_TrieNode *)o); - p->children = Py_None; Py_INCREF(Py_None); - if (__pyx_pw_3_sa_8TrieNode_1__cinit__(o, __pyx_empty_tuple, NULL) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *)o); + p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_3_sa_TrieNode(PyObject *o) { - struct __pyx_obj_3_sa_TrieNode *p = (struct __pyx_obj_3_sa_TrieNode *)o; - Py_XDECREF(p->children); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct____iter__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *)o; + Py_XDECREF(((PyObject *)p->__pyx_v_self)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_TrieNode(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct____iter__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_TrieNode *p = (struct __pyx_obj_3_sa_TrieNode *)o; - if (p->children) { - e = (*v)(p->children, a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct____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_3_sa_TrieNode(PyObject *o) { - struct __pyx_obj_3_sa_TrieNode *p = (struct __pyx_obj_3_sa_TrieNode *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct____iter__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct____iter__ *)o; PyObject* tmp; - tmp = ((PyObject*)p->children); - p->children = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyObject *__pyx_getprop_3_sa_8TrieNode_children(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_8TrieNode_8children_1__get__(o); -} - -static int __pyx_setprop_3_sa_8TrieNode_children(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_8TrieNode_8children_3__set__(o, v); - } - else { - return __pyx_pw_3_sa_8TrieNode_8children_5__del__(o); - } -} - -static PyMethodDef __pyx_methods_3_sa_TrieNode[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct____iter__[] = { {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_3_sa_TrieNode[] = { - {(char *)"children", __pyx_getprop_3_sa_8TrieNode_children, __pyx_setprop_3_sa_8TrieNode_children, 0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_TrieNode = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct____iter__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -57798,7 +61503,7 @@ static PyNumberMethods __pyx_tp_as_number_TrieNode = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_TrieNode = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct____iter__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -57811,13 +61516,13 @@ static PySequenceMethods __pyx_tp_as_sequence_TrieNode = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_TrieNode = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct____iter__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_TrieNode = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct____iter__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -57838,12 +61543,12 @@ static PyBufferProcs __pyx_tp_as_buffer_TrieNode = { #endif }; -static PyTypeObject __pyx_type_3_sa_TrieNode = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct____iter__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.TrieNode"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_TrieNode), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct____iter__"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct____iter__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_TrieNode, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct____iter__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -57851,28 +61556,28 @@ static PyTypeObject __pyx_type_3_sa_TrieNode = { 0, /*tp_compare*/ #else 0, /*reserved*/ - #endif - 0, /*tp_repr*/ - &__pyx_tp_as_number_TrieNode, /*tp_as_number*/ - &__pyx_tp_as_sequence_TrieNode, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_TrieNode, /*tp_as_mapping*/ + #endif + 0, /*tp_repr*/ + &__pyx_tp_as_number___pyx_scope_struct____iter__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct____iter__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct____iter__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_TrieNode, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + &__pyx_tp_as_buffer___pyx_scope_struct____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_3_sa_TrieNode, /*tp_traverse*/ - __pyx_tp_clear_3_sa_TrieNode, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct____iter__, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct____iter__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_TrieNode, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct____iter__, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_3_sa_TrieNode, /*tp_getset*/ + 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -57880,7 +61585,7 @@ static PyTypeObject __pyx_type_3_sa_TrieNode = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_TrieNode, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct____iter__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -57894,111 +61599,44 @@ static PyTypeObject __pyx_type_3_sa_TrieNode = { #endif }; -static PyObject *__pyx_tp_new_3_sa_ExtendedTrieNode(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_ExtendedTrieNode *p; - PyObject *o = __pyx_tp_new_3_sa_TrieNode(t, a, k); +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_1_read_bitext(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *p; + PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_ExtendedTrieNode *)o); - p->phrase = Py_None; Py_INCREF(Py_None); - p->phrase_location = Py_None; Py_INCREF(Py_None); - p->suffix_link = Py_None; Py_INCREF(Py_None); - if (__pyx_pw_3_sa_16ExtendedTrieNode_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *)o); + p->__pyx_v_fp = 0; return o; } -static void __pyx_tp_dealloc_3_sa_ExtendedTrieNode(PyObject *o) { - struct __pyx_obj_3_sa_ExtendedTrieNode *p = (struct __pyx_obj_3_sa_ExtendedTrieNode *)o; - Py_XDECREF(p->phrase); - Py_XDECREF(p->phrase_location); - Py_XDECREF(p->suffix_link); - __pyx_tp_dealloc_3_sa_TrieNode(o); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_1_read_bitext(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *p = (struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *)o; + Py_XDECREF(p->__pyx_v_fp); + (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_ExtendedTrieNode(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_1_read_bitext(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_ExtendedTrieNode *p = (struct __pyx_obj_3_sa_ExtendedTrieNode *)o; - e = __pyx_tp_traverse_3_sa_TrieNode(o, v, a); if (e) return e; - if (p->phrase) { - e = (*v)(p->phrase, a); if (e) return e; - } - if (p->phrase_location) { - e = (*v)(p->phrase_location, a); if (e) return e; - } - if (p->suffix_link) { - e = (*v)(p->suffix_link, a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *p = (struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *)o; + if (p->__pyx_v_fp) { + e = (*v)(p->__pyx_v_fp, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_ExtendedTrieNode(PyObject *o) { - struct __pyx_obj_3_sa_ExtendedTrieNode *p = (struct __pyx_obj_3_sa_ExtendedTrieNode *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_1_read_bitext(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *p = (struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *)o; PyObject* tmp; - __pyx_tp_clear_3_sa_TrieNode(o); - tmp = ((PyObject*)p->phrase); - p->phrase = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->phrase_location); - p->phrase_location = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->suffix_link); - p->suffix_link = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_fp); + p->__pyx_v_fp = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyObject *__pyx_getprop_3_sa_16ExtendedTrieNode_phrase(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_1__get__(o); -} - -static int __pyx_setprop_3_sa_16ExtendedTrieNode_phrase(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_3__set__(o, v); - } - else { - return __pyx_pw_3_sa_16ExtendedTrieNode_6phrase_5__del__(o); - } -} - -static PyObject *__pyx_getprop_3_sa_16ExtendedTrieNode_phrase_location(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_1__get__(o); -} - -static int __pyx_setprop_3_sa_16ExtendedTrieNode_phrase_location(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_3__set__(o, v); - } - else { - return __pyx_pw_3_sa_16ExtendedTrieNode_15phrase_location_5__del__(o); - } -} - -static PyObject *__pyx_getprop_3_sa_16ExtendedTrieNode_suffix_link(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_1__get__(o); -} - -static int __pyx_setprop_3_sa_16ExtendedTrieNode_suffix_link(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_3__set__(o, v); - } - else { - return __pyx_pw_3_sa_16ExtendedTrieNode_11suffix_link_5__del__(o); - } -} - -static PyMethodDef __pyx_methods_3_sa_ExtendedTrieNode[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_1_read_bitext[] = { {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_3_sa_ExtendedTrieNode[] = { - {(char *)"phrase", __pyx_getprop_3_sa_16ExtendedTrieNode_phrase, __pyx_setprop_3_sa_16ExtendedTrieNode_phrase, 0, 0}, - {(char *)"phrase_location", __pyx_getprop_3_sa_16ExtendedTrieNode_phrase_location, __pyx_setprop_3_sa_16ExtendedTrieNode_phrase_location, 0, 0}, - {(char *)"suffix_link", __pyx_getprop_3_sa_16ExtendedTrieNode_suffix_link, __pyx_setprop_3_sa_16ExtendedTrieNode_suffix_link, 0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_ExtendedTrieNode = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1_read_bitext = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -58056,7 +61694,7 @@ static PyNumberMethods __pyx_tp_as_number_ExtendedTrieNode = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_ExtendedTrieNode = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_1_read_bitext = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -58069,13 +61707,13 @@ static PySequenceMethods __pyx_tp_as_sequence_ExtendedTrieNode = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_ExtendedTrieNode = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_1_read_bitext = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_ExtendedTrieNode = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1_read_bitext = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -58096,12 +61734,12 @@ static PyBufferProcs __pyx_tp_as_buffer_ExtendedTrieNode = { #endif }; -static PyTypeObject __pyx_type_3_sa_ExtendedTrieNode = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_1_read_bitext = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.ExtendedTrieNode"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_ExtendedTrieNode), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_1_read_bitext"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_ExtendedTrieNode, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_1_read_bitext, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -58111,26 +61749,26 @@ static PyTypeObject __pyx_type_3_sa_ExtendedTrieNode = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_ExtendedTrieNode, /*tp_as_number*/ - &__pyx_tp_as_sequence_ExtendedTrieNode, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_ExtendedTrieNode, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_1_read_bitext, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_1_read_bitext, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_1_read_bitext, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_ExtendedTrieNode, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + &__pyx_tp_as_buffer___pyx_scope_struct_1_read_bitext, /*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_3_sa_ExtendedTrieNode, /*tp_traverse*/ - __pyx_tp_clear_3_sa_ExtendedTrieNode, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_1_read_bitext, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_1_read_bitext, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_ExtendedTrieNode, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_1_read_bitext, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_3_sa_ExtendedTrieNode, /*tp_getset*/ + 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -58138,7 +61776,7 @@ static PyTypeObject __pyx_type_3_sa_ExtendedTrieNode = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_ExtendedTrieNode, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_1_read_bitext, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -58152,95 +61790,60 @@ static PyTypeObject __pyx_type_3_sa_ExtendedTrieNode = { #endif }; -static PyObject *__pyx_tp_new_3_sa_TrieTable(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_TrieTable *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_2_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_TrieTable *)o); - p->root = Py_None; Py_INCREF(Py_None); - if (__pyx_pw_3_sa_9TrieTable_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *)o); + p->__pyx_outer_scope = 0; + p->__pyx_v_line = 0; + p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_3_sa_TrieTable(PyObject *o) { - struct __pyx_obj_3_sa_TrieTable *p = (struct __pyx_obj_3_sa_TrieTable *)o; - Py_XDECREF(p->root); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_2_genexpr(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *)o; + Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); + Py_XDECREF(p->__pyx_v_line); + Py_XDECREF(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_TrieTable(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_2_genexpr(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_TrieTable *p = (struct __pyx_obj_3_sa_TrieTable *)o; - if (p->root) { - e = (*v)(p->root, a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *)o; + if (p->__pyx_outer_scope) { + e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; + } + if (p->__pyx_v_line) { + e = (*v)(p->__pyx_v_line, a); if (e) return e; + } + if (p->__pyx_t_0) { + e = (*v)(p->__pyx_t_0, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_TrieTable(PyObject *o) { - struct __pyx_obj_3_sa_TrieTable *p = (struct __pyx_obj_3_sa_TrieTable *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_2_genexpr(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr *)o; PyObject* tmp; - tmp = ((PyObject*)p->root); - p->root = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_outer_scope); + p->__pyx_outer_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_1_read_bitext *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_line); + p->__pyx_v_line = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_t_0); + p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyObject *__pyx_getprop_3_sa_9TrieTable_extended(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_9TrieTable_8extended_1__get__(o); -} - -static int __pyx_setprop_3_sa_9TrieTable_extended(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_9TrieTable_8extended_3__set__(o, v); - } - else { - PyErr_SetString(PyExc_NotImplementedError, "__del__"); - return -1; - } -} - -static PyObject *__pyx_getprop_3_sa_9TrieTable_count(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_9TrieTable_5count_1__get__(o); -} - -static int __pyx_setprop_3_sa_9TrieTable_count(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_9TrieTable_5count_3__set__(o, v); - } - else { - PyErr_SetString(PyExc_NotImplementedError, "__del__"); - return -1; - } -} - -static PyObject *__pyx_getprop_3_sa_9TrieTable_root(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_3_sa_9TrieTable_4root_1__get__(o); -} - -static int __pyx_setprop_3_sa_9TrieTable_root(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_3_sa_9TrieTable_4root_3__set__(o, v); - } - else { - return __pyx_pw_3_sa_9TrieTable_4root_5__del__(o); - } -} - -static PyMethodDef __pyx_methods_3_sa_TrieTable[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_2_genexpr[] = { {0, 0, 0, 0} }; -static struct PyGetSetDef __pyx_getsets_3_sa_TrieTable[] = { - {(char *)"extended", __pyx_getprop_3_sa_9TrieTable_extended, __pyx_setprop_3_sa_9TrieTable_extended, 0, 0}, - {(char *)"count", __pyx_getprop_3_sa_9TrieTable_count, __pyx_setprop_3_sa_9TrieTable_count, 0, 0}, - {(char *)"root", __pyx_getprop_3_sa_9TrieTable_root, __pyx_setprop_3_sa_9TrieTable_root, 0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_TrieTable = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2_genexpr = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -58298,7 +61901,7 @@ static PyNumberMethods __pyx_tp_as_number_TrieTable = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_TrieTable = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_2_genexpr = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -58311,13 +61914,13 @@ static PySequenceMethods __pyx_tp_as_sequence_TrieTable = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_TrieTable = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_2_genexpr = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_TrieTable = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2_genexpr = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -58338,12 +61941,12 @@ static PyBufferProcs __pyx_tp_as_buffer_TrieTable = { #endif }; -static PyTypeObject __pyx_type_3_sa_TrieTable = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_2_genexpr = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.TrieTable"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_TrieTable), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_2_genexpr"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_2_genexpr), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_TrieTable, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_2_genexpr, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -58353,26 +61956,26 @@ static PyTypeObject __pyx_type_3_sa_TrieTable = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_TrieTable, /*tp_as_number*/ - &__pyx_tp_as_sequence_TrieTable, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_TrieTable, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_2_genexpr, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_2_genexpr, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_2_genexpr, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_TrieTable, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + &__pyx_tp_as_buffer___pyx_scope_struct_2_genexpr, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa_TrieTable, /*tp_traverse*/ - __pyx_tp_clear_3_sa_TrieTable, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_2_genexpr, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_2_genexpr, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_TrieTable, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_2_genexpr, /*tp_methods*/ 0, /*tp_members*/ - __pyx_getsets_3_sa_TrieTable, /*tp_getset*/ + 0, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ @@ -58380,7 +61983,7 @@ static PyTypeObject __pyx_type_3_sa_TrieTable = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_TrieTable, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_2_genexpr, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -58393,50 +61996,85 @@ static PyTypeObject __pyx_type_3_sa_TrieTable = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_PhraseLocation __pyx_vtable_3_sa_PhraseLocation; -static PyObject *__pyx_tp_new_3_sa_PhraseLocation(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_PhraseLocation *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_3_compute_stats(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_PhraseLocation *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_PhraseLocation; - p->arr = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_14PhraseLocation_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *)o); + p->__pyx_v_ngram = 0; + p->__pyx_v_ngram_start = 0; + p->__pyx_v_ngram_starts = 0; + p->__pyx_v_run_start = 0; + p->__pyx_v_self = 0; + p->__pyx_v_veb = 0; return o; } -static void __pyx_tp_dealloc_3_sa_PhraseLocation(PyObject *o) { - struct __pyx_obj_3_sa_PhraseLocation *p = (struct __pyx_obj_3_sa_PhraseLocation *)o; - Py_XDECREF(((PyObject *)p->arr)); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_3_compute_stats(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *p = (struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *)o; + Py_XDECREF(((PyObject *)p->__pyx_v_ngram)); + Py_XDECREF(((PyObject *)p->__pyx_v_ngram_start)); + Py_XDECREF(((PyObject *)p->__pyx_v_ngram_starts)); + Py_XDECREF(((PyObject *)p->__pyx_v_run_start)); + Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_XDECREF(((PyObject *)p->__pyx_v_veb)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_PhraseLocation(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_3_compute_stats(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_PhraseLocation *p = (struct __pyx_obj_3_sa_PhraseLocation *)o; - if (p->arr) { - e = (*v)(((PyObject*)p->arr), a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *p = (struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *)o; + if (p->__pyx_v_ngram) { + e = (*v)(p->__pyx_v_ngram, a); if (e) return e; + } + if (p->__pyx_v_ngram_start) { + e = (*v)(((PyObject*)p->__pyx_v_ngram_start), a); if (e) return e; + } + if (p->__pyx_v_ngram_starts) { + e = (*v)(p->__pyx_v_ngram_starts, a); if (e) return e; + } + if (p->__pyx_v_run_start) { + e = (*v)(((PyObject*)p->__pyx_v_run_start), a); if (e) return e; + } + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; + } + if (p->__pyx_v_veb) { + e = (*v)(((PyObject*)p->__pyx_v_veb), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_PhraseLocation(PyObject *o) { - struct __pyx_obj_3_sa_PhraseLocation *p = (struct __pyx_obj_3_sa_PhraseLocation *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_3_compute_stats(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *p = (struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats *)o; PyObject* tmp; - tmp = ((PyObject*)p->arr); - p->arr = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_ngram); + p->__pyx_v_ngram = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_ngram_start); + p->__pyx_v_ngram_start = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_ngram_starts); + p->__pyx_v_ngram_starts = ((PyObject*)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_run_start); + p->__pyx_v_run_start = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_LCP *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_veb); + p->__pyx_v_veb = ((struct __pyx_obj_3_sa_VEB *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_PhraseLocation[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_3_compute_stats[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_PhraseLocation = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_3_compute_stats = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -58494,7 +62132,7 @@ static PyNumberMethods __pyx_tp_as_number_PhraseLocation = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_PhraseLocation = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_3_compute_stats = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -58507,13 +62145,13 @@ static PySequenceMethods __pyx_tp_as_sequence_PhraseLocation = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_PhraseLocation = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_3_compute_stats = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_PhraseLocation = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_3_compute_stats = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -58534,12 +62172,12 @@ static PyBufferProcs __pyx_tp_as_buffer_PhraseLocation = { #endif }; -static PyTypeObject __pyx_type_3_sa_PhraseLocation = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_3_compute_stats = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.PhraseLocation"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_PhraseLocation), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_3_compute_stats"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_3_compute_stats), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_PhraseLocation, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_3_compute_stats, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -58549,24 +62187,24 @@ static PyTypeObject __pyx_type_3_sa_PhraseLocation = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_PhraseLocation, /*tp_as_number*/ - &__pyx_tp_as_sequence_PhraseLocation, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_PhraseLocation, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_3_compute_stats, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_3_compute_stats, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_3_compute_stats, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_PhraseLocation, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + &__pyx_tp_as_buffer___pyx_scope_struct_3_compute_stats, /*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_3_sa_PhraseLocation, /*tp_traverse*/ - __pyx_tp_clear_3_sa_PhraseLocation, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_3_compute_stats, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_3_compute_stats, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_PhraseLocation, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_3_compute_stats, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -58576,7 +62214,7 @@ static PyTypeObject __pyx_type_3_sa_PhraseLocation = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_PhraseLocation, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_3_compute_stats, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -58590,48 +62228,44 @@ static PyTypeObject __pyx_type_3_sa_PhraseLocation = { #endif }; -static PyObject *__pyx_tp_new_3_sa_Sampler(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_Sampler *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_4___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_Sampler *)o); - p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_7Sampler_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *)o); + p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_3_sa_Sampler(PyObject *o) { - struct __pyx_obj_3_sa_Sampler *p = (struct __pyx_obj_3_sa_Sampler *)o; - Py_XDECREF(((PyObject *)p->sa)); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_4___iter__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *)o; + Py_XDECREF(((PyObject *)p->__pyx_v_self)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_Sampler(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_4___iter__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_Sampler *p = (struct __pyx_obj_3_sa_Sampler *)o; - if (p->sa) { - e = (*v)(((PyObject*)p->sa), a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_4___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_3_sa_Sampler(PyObject *o) { - struct __pyx_obj_3_sa_Sampler *p = (struct __pyx_obj_3_sa_Sampler *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_4___iter__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__ *)o; PyObject* tmp; - tmp = ((PyObject*)p->sa); - p->sa = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_Sampler[] = { - {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_3_sa_7Sampler_3sample, METH_O, __Pyx_DOCSTR(__pyx_doc_3_sa_7Sampler_2sample)}, +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_4___iter__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_Sampler = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_4___iter__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -58689,7 +62323,7 @@ static PyNumberMethods __pyx_tp_as_number_Sampler = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_Sampler = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_4___iter__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -58702,13 +62336,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Sampler = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_Sampler = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_4___iter__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_Sampler = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_4___iter__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -58729,12 +62363,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Sampler = { #endif }; -static PyTypeObject __pyx_type_3_sa_Sampler = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_4___iter__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.Sampler"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_Sampler), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_4___iter__"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_4___iter__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_Sampler, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_4___iter__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -58744,24 +62378,24 @@ static PyTypeObject __pyx_type_3_sa_Sampler = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_Sampler, /*tp_as_number*/ - &__pyx_tp_as_sequence_Sampler, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Sampler, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_4___iter__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_4___iter__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_4___iter__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Sampler, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("A Sampler implements a logic for choosing\n samples from a population range"), /*tp_doc*/ - __pyx_tp_traverse_3_sa_Sampler, /*tp_traverse*/ - __pyx_tp_clear_3_sa_Sampler, /*tp_clear*/ + &__pyx_tp_as_buffer___pyx_scope_struct_4___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_3_sa___pyx_scope_struct_4___iter__, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_4___iter__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_Sampler, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_4___iter__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -58771,7 +62405,7 @@ static PyTypeObject __pyx_type_3_sa_Sampler = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_Sampler, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_4___iter__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -58784,173 +62418,45 @@ static PyTypeObject __pyx_type_3_sa_Sampler = { 0, /*tp_version_tag*/ #endif }; -static struct __pyx_vtabstruct_3_sa_HieroCachingRuleFactory __pyx_vtable_3_sa_HieroCachingRuleFactory; -static PyObject *__pyx_tp_new_3_sa_HieroCachingRuleFactory(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_3_sa_HieroCachingRuleFactory *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_5___str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o); - p->__pyx_vtab = __pyx_vtabptr_3_sa_HieroCachingRuleFactory; - p->rules = ((struct __pyx_obj_3_sa_TrieTable *)Py_None); Py_INCREF(Py_None); - p->sampler = ((struct __pyx_obj_3_sa_Sampler *)Py_None); Py_INCREF(Py_None); - p->precomputed_index = Py_None; Py_INCREF(Py_None); - p->precomputed_collocations = Py_None; Py_INCREF(Py_None); - p->precompute_file = Py_None; Py_INCREF(Py_None); - p->max_rank = Py_None; Py_INCREF(Py_None); - p->prev_norm_prefix = Py_None; Py_INCREF(Py_None); - p->fsa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); - p->fda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); - p->eda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); - p->alignment = ((struct __pyx_obj_3_sa_Alignment *)Py_None); Py_INCREF(Py_None); - p->eid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->fid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->findexes = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - p->findexes1 = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_3_sa_23HieroCachingRuleFactory_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *)o); + p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_3_sa_HieroCachingRuleFactory(PyObject *o) { - struct __pyx_obj_3_sa_HieroCachingRuleFactory *p = (struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o; - Py_XDECREF(((PyObject *)p->rules)); - Py_XDECREF(((PyObject *)p->sampler)); - Py_XDECREF(p->precomputed_index); - Py_XDECREF(p->precomputed_collocations); - Py_XDECREF(p->precompute_file); - Py_XDECREF(p->max_rank); - Py_XDECREF(p->prev_norm_prefix); - Py_XDECREF(((PyObject *)p->fsa)); - Py_XDECREF(((PyObject *)p->fda)); - Py_XDECREF(((PyObject *)p->eda)); - Py_XDECREF(((PyObject *)p->alignment)); - Py_XDECREF(((PyObject *)p->eid2symid)); - Py_XDECREF(((PyObject *)p->fid2symid)); - Py_XDECREF(((PyObject *)p->findexes)); - Py_XDECREF(((PyObject *)p->findexes1)); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_5___str__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *)o; + Py_XDECREF(((PyObject *)p->__pyx_v_self)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa_HieroCachingRuleFactory(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_5___str__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa_HieroCachingRuleFactory *p = (struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o; - if (p->rules) { - e = (*v)(((PyObject*)p->rules), a); if (e) return e; - } - if (p->sampler) { - e = (*v)(((PyObject*)p->sampler), a); if (e) return e; - } - if (p->precomputed_index) { - e = (*v)(p->precomputed_index, a); if (e) return e; - } - if (p->precomputed_collocations) { - e = (*v)(p->precomputed_collocations, a); if (e) return e; - } - if (p->precompute_file) { - e = (*v)(p->precompute_file, a); if (e) return e; - } - if (p->max_rank) { - e = (*v)(p->max_rank, a); if (e) return e; - } - if (p->prev_norm_prefix) { - e = (*v)(p->prev_norm_prefix, a); if (e) return e; - } - if (p->fsa) { - e = (*v)(((PyObject*)p->fsa), a); if (e) return e; - } - if (p->fda) { - e = (*v)(((PyObject*)p->fda), a); if (e) return e; - } - if (p->eda) { - e = (*v)(((PyObject*)p->eda), a); if (e) return e; - } - if (p->alignment) { - e = (*v)(((PyObject*)p->alignment), a); if (e) return e; - } - if (p->eid2symid) { - e = (*v)(((PyObject*)p->eid2symid), a); if (e) return e; - } - if (p->fid2symid) { - e = (*v)(((PyObject*)p->fid2symid), a); if (e) return e; - } - if (p->findexes) { - e = (*v)(((PyObject*)p->findexes), a); if (e) return e; - } - if (p->findexes1) { - e = (*v)(((PyObject*)p->findexes1), a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *)o; + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa_HieroCachingRuleFactory(PyObject *o) { - struct __pyx_obj_3_sa_HieroCachingRuleFactory *p = (struct __pyx_obj_3_sa_HieroCachingRuleFactory *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_5___str__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *)o; PyObject* tmp; - tmp = ((PyObject*)p->rules); - p->rules = ((struct __pyx_obj_3_sa_TrieTable *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->sampler); - p->sampler = ((struct __pyx_obj_3_sa_Sampler *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->precomputed_index); - p->precomputed_index = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->precomputed_collocations); - p->precomputed_collocations = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->precompute_file); - p->precompute_file = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->max_rank); - p->max_rank = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->prev_norm_prefix); - p->prev_norm_prefix = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->fsa); - p->fsa = ((struct __pyx_obj_3_sa_SuffixArray *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->fda); - p->fda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->eda); - p->eda = ((struct __pyx_obj_3_sa_DataArray *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->alignment); - p->alignment = ((struct __pyx_obj_3_sa_Alignment *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->eid2symid); - p->eid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->fid2symid); - p->fid2symid = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->findexes); - p->findexes = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->findexes1); - p->findexes1 = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_Rule *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa_HieroCachingRuleFactory[] = { - {__Pyx_NAMESTR("configure"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_3configure, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_23HieroCachingRuleFactory_2configure)}, - {__Pyx_NAMESTR("pattern2phrase"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_5pattern2phrase, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("pattern2phrase_plus"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_7pattern2phrase_plus, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("precompute"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_9precompute, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_precomputed_collocation"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_11get_precomputed_collocation, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("advance"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_13advance, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_all_nodes_isteps_away"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_15get_all_nodes_isteps_away, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("reachable"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_17reachable, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("shortest"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_19shortest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("get_next_states"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_21get_next_states, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("input"), (PyCFunction)__pyx_pw_3_sa_23HieroCachingRuleFactory_23input, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_3_sa_23HieroCachingRuleFactory_22input)}, +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_5___str__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number_HieroCachingRuleFactory = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_5___str__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -59008,7 +62514,7 @@ static PyNumberMethods __pyx_tp_as_number_HieroCachingRuleFactory = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence_HieroCachingRuleFactory = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_5___str__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -59021,13 +62527,13 @@ static PySequenceMethods __pyx_tp_as_sequence_HieroCachingRuleFactory = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping_HieroCachingRuleFactory = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_5___str__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer_HieroCachingRuleFactory = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_5___str__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -59048,12 +62554,12 @@ static PyBufferProcs __pyx_tp_as_buffer_HieroCachingRuleFactory = { #endif }; -static PyTypeObject __pyx_type_3_sa_HieroCachingRuleFactory = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_5___str__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.HieroCachingRuleFactory"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa_HieroCachingRuleFactory), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_5___str__"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_5___str__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa_HieroCachingRuleFactory, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_5___str__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -59063,24 +62569,24 @@ static PyTypeObject __pyx_type_3_sa_HieroCachingRuleFactory = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number_HieroCachingRuleFactory, /*tp_as_number*/ - &__pyx_tp_as_sequence_HieroCachingRuleFactory, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_HieroCachingRuleFactory, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_5___str__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_5___str__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_5___str__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_HieroCachingRuleFactory, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - __Pyx_DOCSTR("This RuleFactory implements a caching \n method using TrieTable, which makes phrase\n generation somewhat speedier -- phrases only\n need to be extracted once (however, it is\n quite possible they need to be scored \n for each input sentence, for contextual models)"), /*tp_doc*/ - __pyx_tp_traverse_3_sa_HieroCachingRuleFactory, /*tp_traverse*/ - __pyx_tp_clear_3_sa_HieroCachingRuleFactory, /*tp_clear*/ + &__pyx_tp_as_buffer___pyx_scope_struct_5___str__, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_5___str__, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_5___str__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa_HieroCachingRuleFactory, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_5___str__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -59090,7 +62596,7 @@ static PyTypeObject __pyx_type_3_sa_HieroCachingRuleFactory = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa_HieroCachingRuleFactory, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_5___str__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -59104,44 +62610,60 @@ static PyTypeObject __pyx_type_3_sa_HieroCachingRuleFactory = { #endif }; -static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct__read_bitext(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_6_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *)o); - p->__pyx_v_fp = 0; + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *)o); + p->__pyx_outer_scope = 0; + p->__pyx_v_a = 0; + p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_3_sa___pyx_scope_struct__read_bitext(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *p = (struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *)o; - Py_XDECREF(p->__pyx_v_fp); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_6_genexpr(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *)o; + Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); + Py_XDECREF(p->__pyx_v_a); + Py_XDECREF(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa___pyx_scope_struct__read_bitext(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_6_genexpr(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *p = (struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *)o; - if (p->__pyx_v_fp) { - e = (*v)(p->__pyx_v_fp, a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *)o; + if (p->__pyx_outer_scope) { + e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; + } + if (p->__pyx_v_a) { + e = (*v)(p->__pyx_v_a, a); if (e) return e; + } + if (p->__pyx_t_0) { + e = (*v)(p->__pyx_t_0, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa___pyx_scope_struct__read_bitext(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *p = (struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_6_genexpr(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr *)o; PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_fp); - p->__pyx_v_fp = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_outer_scope); + p->__pyx_outer_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_5___str__ *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_a); + p->__pyx_v_a = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_t_0); + p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct__read_bitext[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_6_genexpr[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct__read_bitext = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_6_genexpr = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -59199,7 +62721,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct__read_bitext = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct__read_bitext = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_6_genexpr = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -59212,13 +62734,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct__read_bitext = 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct__read_bitext = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_6_genexpr = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct__read_bitext = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_6_genexpr = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -59239,12 +62761,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct__read_bitext = { #endif }; -static PyTypeObject __pyx_type_3_sa___pyx_scope_struct__read_bitext = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_6_genexpr = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.__pyx_scope_struct__read_bitext"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_6_genexpr"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_6_genexpr), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa___pyx_scope_struct__read_bitext, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_6_genexpr, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -59254,24 +62776,24 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct__read_bitext = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct__read_bitext, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct__read_bitext, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct__read_bitext, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_6_genexpr, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_6_genexpr, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_6_genexpr, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct__read_bitext, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_6_genexpr, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa___pyx_scope_struct__read_bitext, /*tp_traverse*/ - __pyx_tp_clear_3_sa___pyx_scope_struct__read_bitext, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_6_genexpr, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_6_genexpr, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa___pyx_scope_struct__read_bitext, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_6_genexpr, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -59281,7 +62803,7 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct__read_bitext = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa___pyx_scope_struct__read_bitext, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_6_genexpr, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -59295,33 +62817,33 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct__read_bitext = { #endif }; -static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_1_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_7_alignments(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *)o); - p->__pyx_outer_scope = 0; - p->__pyx_v_line = 0; + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *)o); + p->__pyx_v_point = 0; + p->__pyx_v_self = 0; p->__pyx_t_0 = 0; return o; } -static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_1_genexpr(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_line); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_7_alignments(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *p = (struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *)o; + Py_XDECREF(p->__pyx_v_point); + Py_XDECREF(((PyObject *)p->__pyx_v_self)); Py_XDECREF(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa___pyx_scope_struct_1_genexpr(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_7_alignments(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *)o; - if (p->__pyx_outer_scope) { - e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; + struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *p = (struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *)o; + if (p->__pyx_v_point) { + e = (*v)(p->__pyx_v_point, a); if (e) return e; } - if (p->__pyx_v_line) { - e = (*v)(p->__pyx_v_line, a); if (e) return e; + if (p->__pyx_v_self) { + e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } if (p->__pyx_t_0) { e = (*v)(p->__pyx_t_0, a); if (e) return e; @@ -59329,14 +62851,14 @@ static int __pyx_tp_traverse_3_sa___pyx_scope_struct_1_genexpr(PyObject *o, visi return 0; } -static int __pyx_tp_clear_3_sa___pyx_scope_struct_1_genexpr(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_7_alignments(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *p = (struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments *)o; PyObject* tmp; - tmp = ((PyObject*)p->__pyx_outer_scope); - p->__pyx_outer_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct__read_bitext *)Py_None); Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_point); + p->__pyx_v_point = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_line); - p->__pyx_v_line = Py_None; Py_INCREF(Py_None); + tmp = ((PyObject*)p->__pyx_v_self); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_Rule *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_t_0); p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); @@ -59344,11 +62866,11 @@ static int __pyx_tp_clear_3_sa___pyx_scope_struct_1_genexpr(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_1_genexpr[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_7_alignments[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1_genexpr = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_7_alignments = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -59406,7 +62928,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_1_genexpr = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_1_genexpr = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_7_alignments = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -59419,13 +62941,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_1_genexpr = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_1_genexpr = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_7_alignments = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1_genexpr = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_7_alignments = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -59446,12 +62968,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_1_genexpr = { #endif }; -static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_1_genexpr = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_7_alignments = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.__pyx_scope_struct_1_genexpr"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_1_genexpr), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_7_alignments"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_7_alignments), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa___pyx_scope_struct_1_genexpr, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_7_alignments, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -59461,24 +62983,24 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_1_genexpr = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_1_genexpr, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_1_genexpr, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_1_genexpr, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_7_alignments, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_7_alignments, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_7_alignments, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_1_genexpr, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_7_alignments, /*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_3_sa___pyx_scope_struct_1_genexpr, /*tp_traverse*/ - __pyx_tp_clear_3_sa___pyx_scope_struct_1_genexpr, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_7_alignments, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_7_alignments, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa___pyx_scope_struct_1_genexpr, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_7_alignments, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -59488,7 +63010,7 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_1_genexpr = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa___pyx_scope_struct_1_genexpr, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_7_alignments, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -59502,84 +63024,44 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_1_genexpr = { #endif }; -static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_2_compute_stats(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_8___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *)o); - p->__pyx_v_ngram = 0; - p->__pyx_v_ngram_start = 0; - p->__pyx_v_ngram_starts = 0; - p->__pyx_v_run_start = 0; + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *)o); p->__pyx_v_self = 0; - p->__pyx_v_veb = 0; return o; } -static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_2_compute_stats(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *p = (struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_ngram)); - Py_XDECREF(((PyObject *)p->__pyx_v_ngram_start)); - Py_XDECREF(((PyObject *)p->__pyx_v_ngram_starts)); - Py_XDECREF(((PyObject *)p->__pyx_v_run_start)); +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_8___iter__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *)o; Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(((PyObject *)p->__pyx_v_veb)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa___pyx_scope_struct_2_compute_stats(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_8___iter__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *p = (struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *)o; - if (p->__pyx_v_ngram) { - e = (*v)(p->__pyx_v_ngram, a); if (e) return e; - } - if (p->__pyx_v_ngram_start) { - e = (*v)(((PyObject*)p->__pyx_v_ngram_start), a); if (e) return e; - } - if (p->__pyx_v_ngram_starts) { - e = (*v)(p->__pyx_v_ngram_starts, a); if (e) return e; - } - if (p->__pyx_v_run_start) { - e = (*v)(((PyObject*)p->__pyx_v_run_start), a); if (e) return e; - } + struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } - if (p->__pyx_v_veb) { - e = (*v)(((PyObject*)p->__pyx_v_veb), a); if (e) return e; - } return 0; } -static int __pyx_tp_clear_3_sa___pyx_scope_struct_2_compute_stats(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *p = (struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_8___iter__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__ *)o; PyObject* tmp; - tmp = ((PyObject*)p->__pyx_v_ngram); - p->__pyx_v_ngram = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_ngram_start); - p->__pyx_v_ngram_start = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_ngram_starts); - p->__pyx_v_ngram_starts = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_run_start); - p->__pyx_v_run_start = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_3_sa_LCP *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_veb); - p->__pyx_v_veb = ((struct __pyx_obj_3_sa_VEB *)Py_None); Py_INCREF(Py_None); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_2_compute_stats[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_8___iter__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2_compute_stats = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_8___iter__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -59637,7 +63119,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_2_compute_stats = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_2_compute_stats = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_8___iter__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -59650,13 +63132,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_2_compute_stats 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_2_compute_stats = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_8___iter__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2_compute_stats = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_8___iter__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -59677,12 +63159,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_2_compute_stats = { #endif }; -static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_2_compute_stats = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_8___iter__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.__pyx_scope_struct_2_compute_stats"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_2_compute_stats), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_8___iter__"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_8___iter__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa___pyx_scope_struct_2_compute_stats, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_8___iter__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -59692,24 +63174,24 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_2_compute_stats = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_2_compute_stats, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_2_compute_stats, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_2_compute_stats, /*tp_as_mapping*/ + &__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*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_2_compute_stats, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_8___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_3_sa___pyx_scope_struct_2_compute_stats, /*tp_traverse*/ - __pyx_tp_clear_3_sa___pyx_scope_struct_2_compute_stats, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_8___iter__, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_8___iter__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa___pyx_scope_struct_2_compute_stats, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_8___iter__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -59719,7 +63201,7 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_2_compute_stats = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa___pyx_scope_struct_2_compute_stats, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_8___iter__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -59733,44 +63215,251 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_2_compute_stats = { #endif }; -static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_3___iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_9___str__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *)o); + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *)o); p->__pyx_v_self = 0; return o; } -static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_3___iter__(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *)o; +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_9___str__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *)o; Py_XDECREF(((PyObject *)p->__pyx_v_self)); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa___pyx_scope_struct_3___iter__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_9___str__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *)o; + struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *)o; if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; } return 0; } -static int __pyx_tp_clear_3_sa___pyx_scope_struct_3___iter__(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__ *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_9___str__(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *p = (struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_self); - p->__pyx_v_self = ((struct __pyx_obj_3_sa_Phrase *)Py_None); Py_INCREF(Py_None); + p->__pyx_v_self = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + return 0; +} + +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_9___str__[] = { + {0, 0, 0, 0} +}; + +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_9___str__ = { + 0, /*nb_add*/ + 0, /*nb_subtract*/ + 0, /*nb_multiply*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_divide*/ + #endif + 0, /*nb_remainder*/ + 0, /*nb_divmod*/ + 0, /*nb_power*/ + 0, /*nb_negative*/ + 0, /*nb_positive*/ + 0, /*nb_absolute*/ + 0, /*nb_nonzero*/ + 0, /*nb_invert*/ + 0, /*nb_lshift*/ + 0, /*nb_rshift*/ + 0, /*nb_and*/ + 0, /*nb_xor*/ + 0, /*nb_or*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_coerce*/ + #endif + 0, /*nb_int*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_long*/ + #else + 0, /*reserved*/ + #endif + 0, /*nb_float*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_oct*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*nb_hex*/ + #endif + 0, /*nb_inplace_add*/ + 0, /*nb_inplace_subtract*/ + 0, /*nb_inplace_multiply*/ + #if PY_MAJOR_VERSION < 3 + 0, /*nb_inplace_divide*/ + #endif + 0, /*nb_inplace_remainder*/ + 0, /*nb_inplace_power*/ + 0, /*nb_inplace_lshift*/ + 0, /*nb_inplace_rshift*/ + 0, /*nb_inplace_and*/ + 0, /*nb_inplace_xor*/ + 0, /*nb_inplace_or*/ + 0, /*nb_floor_divide*/ + 0, /*nb_true_divide*/ + 0, /*nb_inplace_floor_divide*/ + 0, /*nb_inplace_true_divide*/ + #if PY_VERSION_HEX >= 0x02050000 + 0, /*nb_index*/ + #endif +}; + +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_9___str__ = { + 0, /*sq_length*/ + 0, /*sq_concat*/ + 0, /*sq_repeat*/ + 0, /*sq_item*/ + 0, /*sq_slice*/ + 0, /*sq_ass_item*/ + 0, /*sq_ass_slice*/ + 0, /*sq_contains*/ + 0, /*sq_inplace_concat*/ + 0, /*sq_inplace_repeat*/ +}; + +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_9___str__ = { + 0, /*mp_length*/ + 0, /*mp_subscript*/ + 0, /*mp_ass_subscript*/ +}; + +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_9___str__ = { + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getreadbuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getwritebuffer*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getsegcount*/ + #endif + #if PY_MAJOR_VERSION < 3 + 0, /*bf_getcharbuffer*/ + #endif + #if PY_VERSION_HEX >= 0x02060000 + 0, /*bf_getbuffer*/ + #endif + #if PY_VERSION_HEX >= 0x02060000 + 0, /*bf_releasebuffer*/ + #endif +}; + +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_9___str__ = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("_sa.__pyx_scope_struct_9___str__"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_9___str__), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_9___str__, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + #if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ + #else + 0, /*reserved*/ + #endif + 0, /*tp_repr*/ + &__pyx_tp_as_number___pyx_scope_struct_9___str__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_9___str__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_9___str__, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + &__pyx_tp_as_buffer___pyx_scope_struct_9___str__, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ + 0, /*tp_doc*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_9___str__, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_9___str__, /*tp_clear*/ + 0, /*tp_richcompare*/ + 0, /*tp_weaklistoffset*/ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_methods_3_sa___pyx_scope_struct_9___str__, /*tp_methods*/ + 0, /*tp_members*/ + 0, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + 0, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + 0, /*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + __pyx_tp_new_3_sa___pyx_scope_struct_9___str__, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ + #if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ + #endif +}; + +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_10_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *p; + PyObject *o = (*t->tp_alloc)(t, 0); + if (!o) return 0; + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *)o); + p->__pyx_outer_scope = 0; + p->__pyx_v_feat = 0; + p->__pyx_t_0 = 0; + return o; +} + +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_10_genexpr(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *)o; + Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); + Py_XDECREF(p->__pyx_v_feat); + Py_XDECREF(p->__pyx_t_0); + (*Py_TYPE(o)->tp_free)(o); +} + +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_10_genexpr(PyObject *o, visitproc v, void *a) { + int e; + struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *)o; + if (p->__pyx_outer_scope) { + e = (*v)(((PyObject*)p->__pyx_outer_scope), a); if (e) return e; + } + if (p->__pyx_v_feat) { + e = (*v)(p->__pyx_v_feat, a); if (e) return e; + } + if (p->__pyx_t_0) { + e = (*v)(p->__pyx_t_0, a); if (e) return e; + } + return 0; +} + +static int __pyx_tp_clear_3_sa___pyx_scope_struct_10_genexpr(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *p = (struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr *)o; + PyObject* tmp; + tmp = ((PyObject*)p->__pyx_outer_scope); + p->__pyx_outer_scope = ((struct __pyx_obj_3_sa___pyx_scope_struct_9___str__ *)Py_None); Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_v_feat); + p->__pyx_v_feat = Py_None; Py_INCREF(Py_None); + Py_XDECREF(tmp); + tmp = ((PyObject*)p->__pyx_t_0); + p->__pyx_t_0 = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); return 0; } -static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_3___iter__[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_10_genexpr[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_3___iter__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_10_genexpr = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -59828,7 +63517,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_3___iter__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_3___iter__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_10_genexpr = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -59841,13 +63530,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_3___iter__ = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_3___iter__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_10_genexpr = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_3___iter__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_10_genexpr = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -59868,12 +63557,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_3___iter__ = { #endif }; -static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_3___iter__ = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_10_genexpr = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.__pyx_scope_struct_3___iter__"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_3___iter__), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_10_genexpr"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_10_genexpr), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa___pyx_scope_struct_3___iter__, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_10_genexpr, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -59883,24 +63572,24 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_3___iter__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_3___iter__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_3___iter__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_3___iter__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_10_genexpr, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_10_genexpr, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_10_genexpr, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_3___iter__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_10_genexpr, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_3_sa___pyx_scope_struct_3___iter__, /*tp_traverse*/ - __pyx_tp_clear_3_sa___pyx_scope_struct_3___iter__, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_10_genexpr, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_10_genexpr, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa___pyx_scope_struct_3___iter__, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_10_genexpr, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -59910,7 +63599,7 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_3___iter__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa___pyx_scope_struct_3___iter__, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_10_genexpr, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -59924,11 +63613,11 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_3___iter__ = { #endif }; -static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_4_input(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_3_sa___pyx_scope_struct_4_input *p; +static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_11_input(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_3_sa___pyx_scope_struct_11_input *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_3_sa___pyx_scope_struct_4_input *)o); + p = ((struct __pyx_obj_3_sa___pyx_scope_struct_11_input *)o); p->__pyx_v_alignment = 0; p->__pyx_v_als = 0; p->__pyx_v_alslist = 0; @@ -59942,8 +63631,6 @@ static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_4_input(PyTypeObject *t, C p->__pyx_v_extract_stop = 0; p->__pyx_v_extracts = 0; p->__pyx_v_f = 0; - p->__pyx_v_f_margin = 0; - p->__pyx_v_fals = 0; p->__pyx_v_fcount = 0; p->__pyx_v_fphrases = 0; p->__pyx_v_frontier = 0; @@ -59952,8 +63639,6 @@ static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_4_input(PyTypeObject *t, C p->__pyx_v_hiero_phrase = 0; p->__pyx_v_is_shadow_path = 0; p->__pyx_v_key = 0; - p->__pyx_v_model = 0; - p->__pyx_v_models = 0; p->__pyx_v_new_frontier = 0; p->__pyx_v_new_node = 0; p->__pyx_v_next_states = 0; @@ -59982,8 +63667,8 @@ static PyObject *__pyx_tp_new_3_sa___pyx_scope_struct_4_input(PyTypeObject *t, C return o; } -static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_4_input(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_4_input *p = (struct __pyx_obj_3_sa___pyx_scope_struct_4_input *)o; +static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_11_input(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_11_input *p = (struct __pyx_obj_3_sa___pyx_scope_struct_11_input *)o; Py_XDECREF(p->__pyx_v_alignment); Py_XDECREF(p->__pyx_v_als); Py_XDECREF(p->__pyx_v_alslist); @@ -59997,18 +63682,14 @@ static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_4_input(PyObject *o) { Py_XDECREF(p->__pyx_v_extract_stop); Py_XDECREF(((PyObject *)p->__pyx_v_extracts)); Py_XDECREF(p->__pyx_v_f); - Py_XDECREF(p->__pyx_v_f_margin); - Py_XDECREF(((PyObject *)p->__pyx_v_fals)); - Py_XDECREF(((PyObject *)p->__pyx_v_fcount)); - Py_XDECREF(((PyObject *)p->__pyx_v_fphrases)); + Py_XDECREF(p->__pyx_v_fcount); + Py_XDECREF(p->__pyx_v_fphrases); Py_XDECREF(((PyObject *)p->__pyx_v_frontier)); Py_XDECREF(p->__pyx_v_frontier_nodes); Py_XDECREF(p->__pyx_v_fwords); Py_XDECREF(((PyObject *)p->__pyx_v_hiero_phrase)); Py_XDECREF(p->__pyx_v_is_shadow_path); Py_XDECREF(((PyObject *)p->__pyx_v_key)); - Py_XDECREF(p->__pyx_v_model); - Py_XDECREF(p->__pyx_v_models); Py_XDECREF(((PyObject *)p->__pyx_v_new_frontier)); Py_XDECREF(p->__pyx_v_new_node); Py_XDECREF(((PyObject *)p->__pyx_v_next_states)); @@ -60037,9 +63718,9 @@ static void __pyx_tp_dealloc_3_sa___pyx_scope_struct_4_input(PyObject *o) { (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_3_sa___pyx_scope_struct_4_input(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_3_sa___pyx_scope_struct_11_input(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_3_sa___pyx_scope_struct_4_input *p = (struct __pyx_obj_3_sa___pyx_scope_struct_4_input *)o; + struct __pyx_obj_3_sa___pyx_scope_struct_11_input *p = (struct __pyx_obj_3_sa___pyx_scope_struct_11_input *)o; if (p->__pyx_v_alignment) { e = (*v)(p->__pyx_v_alignment, a); if (e) return e; } @@ -60079,12 +63760,6 @@ static int __pyx_tp_traverse_3_sa___pyx_scope_struct_4_input(PyObject *o, visitp if (p->__pyx_v_f) { e = (*v)(p->__pyx_v_f, a); if (e) return e; } - if (p->__pyx_v_f_margin) { - e = (*v)(p->__pyx_v_f_margin, a); if (e) return e; - } - if (p->__pyx_v_fals) { - e = (*v)(p->__pyx_v_fals, a); if (e) return e; - } if (p->__pyx_v_fcount) { e = (*v)(p->__pyx_v_fcount, a); if (e) return e; } @@ -60109,12 +63784,6 @@ static int __pyx_tp_traverse_3_sa___pyx_scope_struct_4_input(PyObject *o, visitp if (p->__pyx_v_key) { e = (*v)(p->__pyx_v_key, a); if (e) return e; } - if (p->__pyx_v_model) { - e = (*v)(p->__pyx_v_model, a); if (e) return e; - } - if (p->__pyx_v_models) { - e = (*v)(p->__pyx_v_models, a); if (e) return e; - } if (p->__pyx_v_new_frontier) { e = (*v)(p->__pyx_v_new_frontier, a); if (e) return e; } @@ -60152,7 +63821,7 @@ static int __pyx_tp_traverse_3_sa___pyx_scope_struct_4_input(PyObject *o, visitp e = (*v)(((PyObject*)p->__pyx_v_sample), a); if (e) return e; } if (p->__pyx_v_scores) { - e = (*v)(p->__pyx_v_scores, a); if (e) return e; + e = (*v)(((PyObject*)p->__pyx_v_scores), a); if (e) return e; } if (p->__pyx_v_self) { e = (*v)(((PyObject*)p->__pyx_v_self), a); if (e) return e; @@ -60193,8 +63862,8 @@ static int __pyx_tp_traverse_3_sa___pyx_scope_struct_4_input(PyObject *o, visitp return 0; } -static int __pyx_tp_clear_3_sa___pyx_scope_struct_4_input(PyObject *o) { - struct __pyx_obj_3_sa___pyx_scope_struct_4_input *p = (struct __pyx_obj_3_sa___pyx_scope_struct_4_input *)o; +static int __pyx_tp_clear_3_sa___pyx_scope_struct_11_input(PyObject *o) { + struct __pyx_obj_3_sa___pyx_scope_struct_11_input *p = (struct __pyx_obj_3_sa___pyx_scope_struct_11_input *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_alignment); p->__pyx_v_alignment = Py_None; Py_INCREF(Py_None); @@ -60235,17 +63904,11 @@ static int __pyx_tp_clear_3_sa___pyx_scope_struct_4_input(PyObject *o) { tmp = ((PyObject*)p->__pyx_v_f); p->__pyx_v_f = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_f_margin); - p->__pyx_v_f_margin = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_fals); - p->__pyx_v_fals = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_fcount); - p->__pyx_v_fcount = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->__pyx_v_fcount = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_fphrases); - p->__pyx_v_fphrases = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->__pyx_v_fphrases = Py_None; Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_frontier); p->__pyx_v_frontier = ((PyObject*)Py_None); Py_INCREF(Py_None); @@ -60265,12 +63928,6 @@ static int __pyx_tp_clear_3_sa___pyx_scope_struct_4_input(PyObject *o) { tmp = ((PyObject*)p->__pyx_v_key); p->__pyx_v_key = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_model); - p->__pyx_v_model = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->__pyx_v_models); - p->__pyx_v_models = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_new_frontier); p->__pyx_v_new_frontier = ((PyObject*)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); @@ -60308,7 +63965,7 @@ static int __pyx_tp_clear_3_sa___pyx_scope_struct_4_input(PyObject *o) { p->__pyx_v_sample = ((struct __pyx_obj_3_sa_IntList *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_scores); - p->__pyx_v_scores = ((PyObject*)Py_None); Py_INCREF(Py_None); + p->__pyx_v_scores = ((struct __pyx_obj_3_sa_FeatureVector *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_self); p->__pyx_v_self = ((struct __pyx_obj_3_sa_HieroCachingRuleFactory *)Py_None); Py_INCREF(Py_None); @@ -60349,11 +64006,11 @@ static int __pyx_tp_clear_3_sa___pyx_scope_struct_4_input(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_4_input[] = { +static PyMethodDef __pyx_methods_3_sa___pyx_scope_struct_11_input[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_4_input = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_11_input = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -60411,7 +64068,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_4_input = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_4_input = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_11_input = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -60424,13 +64081,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_4_input = { 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_4_input = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_11_input = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_4_input = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_11_input = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -60451,12 +64108,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_4_input = { #endif }; -static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_4_input = { +static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_11_input = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_sa.__pyx_scope_struct_4_input"), /*tp_name*/ - sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_4_input), /*tp_basicsize*/ + __Pyx_NAMESTR("_sa.__pyx_scope_struct_11_input"), /*tp_name*/ + sizeof(struct __pyx_obj_3_sa___pyx_scope_struct_11_input), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_3_sa___pyx_scope_struct_4_input, /*tp_dealloc*/ + __pyx_tp_dealloc_3_sa___pyx_scope_struct_11_input, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -60466,24 +64123,24 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_4_input = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_4_input, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_4_input, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_4_input, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_11_input, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_11_input, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_11_input, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_4_input, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_11_input, /*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_3_sa___pyx_scope_struct_4_input, /*tp_traverse*/ - __pyx_tp_clear_3_sa___pyx_scope_struct_4_input, /*tp_clear*/ + __pyx_tp_traverse_3_sa___pyx_scope_struct_11_input, /*tp_traverse*/ + __pyx_tp_clear_3_sa___pyx_scope_struct_11_input, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_3_sa___pyx_scope_struct_4_input, /*tp_methods*/ + __pyx_methods_3_sa___pyx_scope_struct_11_input, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -60493,7 +64150,7 @@ static PyTypeObject __pyx_type_3_sa___pyx_scope_struct_4_input = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_3_sa___pyx_scope_struct_4_input, /*tp_new*/ + __pyx_tp_new_3_sa___pyx_scope_struct_11_input, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -60527,13 +64184,11 @@ static struct PyModuleDef __pyx_moduledef = { static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0}, - {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0}, - {&__pyx_kp_s_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 1, 0}, - {&__pyx_n_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 1}, - {&__pyx_n_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 1}, - {&__pyx_kp_s_106, __pyx_k_106, sizeof(__pyx_k_106), 0, 0, 1, 0}, + {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0}, + {&__pyx_kp_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 0}, + {&__pyx_n_s_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 0, 1, 1}, + {&__pyx_n_s_106, __pyx_k_106, sizeof(__pyx_k_106), 0, 0, 1, 1}, {&__pyx_kp_s_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 0, 1, 0}, - {&__pyx_kp_s_109, __pyx_k_109, sizeof(__pyx_k_109), 0, 0, 1, 0}, {&__pyx_kp_s_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 0, 1, 0}, {&__pyx_kp_s_111, __pyx_k_111, sizeof(__pyx_k_111), 0, 0, 1, 0}, {&__pyx_kp_s_112, __pyx_k_112, sizeof(__pyx_k_112), 0, 0, 1, 0}, @@ -60543,12 +64198,12 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_116, __pyx_k_116, sizeof(__pyx_k_116), 0, 0, 1, 0}, {&__pyx_kp_s_117, __pyx_k_117, sizeof(__pyx_k_117), 0, 0, 1, 0}, {&__pyx_kp_s_118, __pyx_k_118, sizeof(__pyx_k_118), 0, 0, 1, 0}, - {&__pyx_n_s_119, __pyx_k_119, sizeof(__pyx_k_119), 0, 0, 1, 1}, + {&__pyx_kp_s_119, __pyx_k_119, sizeof(__pyx_k_119), 0, 0, 1, 0}, {&__pyx_kp_s_120, __pyx_k_120, sizeof(__pyx_k_120), 0, 0, 1, 0}, - {&__pyx_kp_s_121, __pyx_k_121, sizeof(__pyx_k_121), 0, 0, 1, 0}, - {&__pyx_n_s_123, __pyx_k_123, sizeof(__pyx_k_123), 0, 0, 1, 1}, - {&__pyx_kp_s_124, __pyx_k_124, sizeof(__pyx_k_124), 0, 0, 1, 0}, - {&__pyx_kp_s_125, __pyx_k_125, sizeof(__pyx_k_125), 0, 0, 1, 0}, + {&__pyx_n_s_121, __pyx_k_121, sizeof(__pyx_k_121), 0, 0, 1, 1}, + {&__pyx_kp_s_122, __pyx_k_122, sizeof(__pyx_k_122), 0, 0, 1, 0}, + {&__pyx_kp_s_123, __pyx_k_123, sizeof(__pyx_k_123), 0, 0, 1, 0}, + {&__pyx_n_s_125, __pyx_k_125, sizeof(__pyx_k_125), 0, 0, 1, 1}, {&__pyx_kp_s_126, __pyx_k_126, sizeof(__pyx_k_126), 0, 0, 1, 0}, {&__pyx_kp_s_127, __pyx_k_127, sizeof(__pyx_k_127), 0, 0, 1, 0}, {&__pyx_kp_s_128, __pyx_k_128, sizeof(__pyx_k_128), 0, 0, 1, 0}, @@ -60558,11 +64213,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_131, __pyx_k_131, sizeof(__pyx_k_131), 0, 0, 1, 0}, {&__pyx_kp_s_132, __pyx_k_132, sizeof(__pyx_k_132), 0, 0, 1, 0}, {&__pyx_kp_s_133, __pyx_k_133, sizeof(__pyx_k_133), 0, 0, 1, 0}, - {&__pyx_kp_s_136, __pyx_k_136, sizeof(__pyx_k_136), 0, 0, 1, 0}, - {&__pyx_kp_s_137, __pyx_k_137, sizeof(__pyx_k_137), 0, 0, 1, 0}, + {&__pyx_kp_s_134, __pyx_k_134, sizeof(__pyx_k_134), 0, 0, 1, 0}, + {&__pyx_kp_s_135, __pyx_k_135, sizeof(__pyx_k_135), 0, 0, 1, 0}, + {&__pyx_kp_s_138, __pyx_k_138, sizeof(__pyx_k_138), 0, 0, 1, 0}, + {&__pyx_kp_s_139, __pyx_k_139, sizeof(__pyx_k_139), 0, 0, 1, 0}, {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0}, - {&__pyx_kp_s_141, __pyx_k_141, sizeof(__pyx_k_141), 0, 0, 1, 0}, - {&__pyx_kp_s_142, __pyx_k_142, sizeof(__pyx_k_142), 0, 0, 1, 0}, + {&__pyx_kp_s_143, __pyx_k_143, sizeof(__pyx_k_143), 0, 0, 1, 0}, + {&__pyx_kp_s_144, __pyx_k_144, sizeof(__pyx_k_144), 0, 0, 1, 0}, {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0}, {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0}, @@ -60612,27 +64269,41 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0}, {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0}, {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0}, + {&__pyx_kp_s_99, __pyx_k_99, sizeof(__pyx_k_99), 0, 0, 1, 0}, {&__pyx_kp_s__0, __pyx_k__0, sizeof(__pyx_k__0), 0, 0, 1, 0}, {&__pyx_kp_s__1, __pyx_k__1, sizeof(__pyx_k__1), 0, 0, 1, 0}, + {&__pyx_n_s__CountEF, __pyx_k__CountEF, sizeof(__pyx_k__CountEF), 0, 0, 1, 1}, + {&__pyx_n_s__Counter, __pyx_k__Counter, sizeof(__pyx_k__Counter), 0, 0, 1, 1}, {&__pyx_n_s__END_OF_FILE, __pyx_k__END_OF_FILE, sizeof(__pyx_k__END_OF_FILE), 0, 0, 1, 1}, {&__pyx_n_s__END_OF_LINE, __pyx_k__END_OF_LINE, sizeof(__pyx_k__END_OF_LINE), 0, 0, 1, 1}, + {&__pyx_n_s__EgivenFCoherent, __pyx_k__EgivenFCoherent, sizeof(__pyx_k__EgivenFCoherent), 0, 0, 1, 1}, {&__pyx_n_s__Exception, __pyx_k__Exception, sizeof(__pyx_k__Exception), 0, 0, 1, 1}, {&__pyx_n_s__GzipFile, __pyx_k__GzipFile, sizeof(__pyx_k__GzipFile), 0, 0, 1, 1}, + {&__pyx_n_s__INCREMENT, __pyx_k__INCREMENT, sizeof(__pyx_k__INCREMENT), 0, 0, 1, 1}, + {&__pyx_n_s__INITIAL_CAPACITY, __pyx_k__INITIAL_CAPACITY, sizeof(__pyx_k__INITIAL_CAPACITY), 0, 0, 1, 1}, {&__pyx_n_s__IndexError, __pyx_k__IndexError, sizeof(__pyx_k__IndexError), 0, 0, 1, 1}, + {&__pyx_n_s__IsSingletonF, __pyx_k__IsSingletonF, sizeof(__pyx_k__IsSingletonF), 0, 0, 1, 1}, + {&__pyx_n_s__IsSingletonFE, __pyx_k__IsSingletonFE, sizeof(__pyx_k__IsSingletonFE), 0, 0, 1, 1}, + {&__pyx_n_s__MAXSCORE, __pyx_k__MAXSCORE, sizeof(__pyx_k__MAXSCORE), 0, 0, 1, 1}, + {&__pyx_n_s__MaxLexEgivenF, __pyx_k__MaxLexEgivenF, sizeof(__pyx_k__MaxLexEgivenF), 0, 0, 1, 1}, + {&__pyx_n_s__MaxLexFgivenE, __pyx_k__MaxLexFgivenE, sizeof(__pyx_k__MaxLexFgivenE), 0, 0, 1, 1}, + {&__pyx_n_s__NFEATURES, __pyx_k__NFEATURES, sizeof(__pyx_k__NFEATURES), 0, 0, 1, 1}, {&__pyx_n_s__NULL, __pyx_k__NULL, sizeof(__pyx_k__NULL), 0, 0, 1, 1}, {&__pyx_n_s__RUSAGE_SELF, __pyx_k__RUSAGE_SELF, sizeof(__pyx_k__RUSAGE_SELF), 0, 0, 1, 1}, + {&__pyx_n_s__SampleCountF, __pyx_k__SampleCountF, sizeof(__pyx_k__SampleCountF), 0, 0, 1, 1}, {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1}, {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1}, - {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1}, {&__pyx_n_s____enter__, __pyx_k____enter__, sizeof(__pyx_k____enter__), 0, 0, 1, 1}, {&__pyx_n_s____exit__, __pyx_k____exit__, sizeof(__pyx_k____exit__), 0, 0, 1, 1}, {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1}, + {&__pyx_n_s____name__, __pyx_k____name__, sizeof(__pyx_k____name__), 0, 0, 1, 1}, {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1}, {&__pyx_n_s___columns, __pyx_k___columns, sizeof(__pyx_k___columns), 0, 0, 1, 1}, {&__pyx_n_s___doquicksort, __pyx_k___doquicksort, sizeof(__pyx_k___doquicksort), 0, 0, 1, 1}, {&__pyx_n_s___sa, __pyx_k___sa, sizeof(__pyx_k___sa), 0, 0, 1, 1}, {&__pyx_n_s__advance, __pyx_k__advance, sizeof(__pyx_k__advance), 0, 0, 1, 1}, {&__pyx_n_s__alignment, __pyx_k__alignment, sizeof(__pyx_k__alignment), 0, 0, 1, 1}, + {&__pyx_n_s__alignments, __pyx_k__alignments, sizeof(__pyx_k__alignments), 0, 0, 1, 1}, {&__pyx_n_s__alphabet_size, __pyx_k__alphabet_size, sizeof(__pyx_k__alphabet_size), 0, 0, 1, 1}, {&__pyx_n_s__arity, __pyx_k__arity, sizeof(__pyx_k__arity), 0, 0, 1, 1}, {&__pyx_n_s__arr, __pyx_k__arr, sizeof(__pyx_k__arr), 0, 0, 1, 1}, @@ -60644,8 +64315,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__cmp, __pyx_k__cmp, sizeof(__pyx_k__cmp), 0, 0, 1, 1}, {&__pyx_n_s__col, __pyx_k__col, sizeof(__pyx_k__col), 0, 0, 1, 1}, {&__pyx_n_s__collect, __pyx_k__collect, sizeof(__pyx_k__collect), 0, 0, 1, 1}, + {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1}, {&__pyx_n_s__curr_idx, __pyx_k__curr_idx, sizeof(__pyx_k__curr_idx), 0, 0, 1, 1}, {&__pyx_n_s__debug, __pyx_k__debug, sizeof(__pyx_k__debug), 0, 0, 1, 1}, + {&__pyx_n_s__defaultdict, __pyx_k__defaultdict, sizeof(__pyx_k__defaultdict), 0, 0, 1, 1}, {&__pyx_n_s__dist, __pyx_k__dist, sizeof(__pyx_k__dist), 0, 0, 1, 1}, {&__pyx_n_s__e, __pyx_k__e, sizeof(__pyx_k__e), 0, 0, 1, 1}, {&__pyx_n_s__earray, __pyx_k__earray, sizeof(__pyx_k__earray), 0, 0, 1, 1}, @@ -60674,6 +64347,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__get_f_id, __pyx_k__get_f_id, sizeof(__pyx_k__get_f_id), 0, 0, 1, 1}, {&__pyx_n_s__get_id, __pyx_k__get_id, sizeof(__pyx_k__get_id), 0, 0, 1, 1}, {&__pyx_n_s__get_next_states, __pyx_k__get_next_states, sizeof(__pyx_k__get_next_states), 0, 0, 1, 1}, + {&__pyx_n_s__get_score, __pyx_k__get_score, sizeof(__pyx_k__get_score), 0, 0, 1, 1}, {&__pyx_n_s__get_word, __pyx_k__get_word, sizeof(__pyx_k__get_word), 0, 0, 1, 1}, {&__pyx_n_s__getchunk, __pyx_k__getchunk, sizeof(__pyx_k__getchunk), 0, 0, 1, 1}, {&__pyx_n_s__getrusage, __pyx_k__getrusage, sizeof(__pyx_k__getrusage), 0, 0, 1, 1}, @@ -60708,7 +64382,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__merge, __pyx_k__merge, sizeof(__pyx_k__merge), 0, 0, 1, 1}, {&__pyx_n_s__min_dist, __pyx_k__min_dist, sizeof(__pyx_k__min_dist), 0, 0, 1, 1}, {&__pyx_n_s__min_gap_size, __pyx_k__min_gap_size, sizeof(__pyx_k__min_gap_size), 0, 0, 1, 1}, - {&__pyx_n_s__models, __pyx_k__models, sizeof(__pyx_k__models), 0, 0, 1, 1}, + {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1}, {&__pyx_n_s__next_states, __pyx_k__next_states, sizeof(__pyx_k__next_states), 0, 0, 1, 1}, {&__pyx_n_s__num_subpatterns, __pyx_k__num_subpatterns, sizeof(__pyx_k__num_subpatterns), 0, 0, 1, 1}, {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1}, @@ -60744,9 +64418,10 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__sample_size, __pyx_k__sample_size, sizeof(__pyx_k__sample_size), 0, 0, 1, 1}, {&__pyx_n_s__sampler, __pyx_k__sampler, sizeof(__pyx_k__sampler), 0, 0, 1, 1}, {&__pyx_n_s__sarray, __pyx_k__sarray, sizeof(__pyx_k__sarray), 0, 0, 1, 1}, + {&__pyx_n_s__scorer, __pyx_k__scorer, sizeof(__pyx_k__scorer), 0, 0, 1, 1}, {&__pyx_n_s__scores, __pyx_k__scores, sizeof(__pyx_k__scores), 0, 0, 1, 1}, {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1}, - {&__pyx_n_s__setdefault, __pyx_k__setdefault, sizeof(__pyx_k__setdefault), 0, 0, 1, 1}, + {&__pyx_n_s__set, __pyx_k__set, sizeof(__pyx_k__set), 0, 0, 1, 1}, {&__pyx_n_s__shortest, __pyx_k__shortest, sizeof(__pyx_k__shortest), 0, 0, 1, 1}, {&__pyx_n_s__side, __pyx_k__side, sizeof(__pyx_k__side), 0, 0, 1, 1}, {&__pyx_n_s__size, __pyx_k__size, sizeof(__pyx_k__size), 0, 0, 1, 1}, @@ -60765,11 +64440,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_n_s__tight_phrases, __pyx_k__tight_phrases, sizeof(__pyx_k__tight_phrases), 0, 0, 1, 1}, {&__pyx_n_s__toMap, __pyx_k__toMap, sizeof(__pyx_k__toMap), 0, 0, 1, 1}, {&__pyx_n_s__train_min_gap_size, __pyx_k__train_min_gap_size, sizeof(__pyx_k__train_min_gap_size), 0, 0, 1, 1}, + {&__pyx_n_s__ttable, __pyx_k__ttable, sizeof(__pyx_k__ttable), 0, 0, 1, 1}, {&__pyx_n_s__unlink, __pyx_k__unlink, sizeof(__pyx_k__unlink), 0, 0, 1, 1}, {&__pyx_n_s__use_baeza_yates, __pyx_k__use_baeza_yates, sizeof(__pyx_k__use_baeza_yates), 0, 0, 1, 1}, {&__pyx_n_s__use_collocations, __pyx_k__use_collocations, sizeof(__pyx_k__use_collocations), 0, 0, 1, 1}, {&__pyx_n_s__use_index, __pyx_k__use_index, sizeof(__pyx_k__use_index), 0, 0, 1, 1}, {&__pyx_n_s__use_sent_id, __pyx_k__use_sent_id, sizeof(__pyx_k__use_sent_id), 0, 0, 1, 1}, + {&__pyx_n_s__value, __pyx_k__value, sizeof(__pyx_k__value), 0, 0, 1, 1}, {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1}, {&__pyx_n_s__warn, __pyx_k__warn, sizeof(__pyx_k__warn), 0, 0, 1, 1}, {&__pyx_n_s__word, __pyx_k__word, sizeof(__pyx_k__word), 0, 0, 1, 1}, @@ -60782,17 +64459,16 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { }; static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __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[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 108; __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[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 109; __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 = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_map = __Pyx_GetName(__pyx_b, __pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_zip = __Pyx_GetName(__pyx_b, __pyx_n_s__zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_n_s__cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_sorted = __Pyx_GetName(__pyx_b, __pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_n_s__cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_sorted = __Pyx_GetName(__pyx_b, __pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; __pyx_L1_error:; return -1; @@ -61359,7 +65035,7 @@ static int __Pyx_InitCachedConstants(void) { * cdef float start_time = monitor_cpu() * */ - __pyx_k_tuple_73 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_73 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_73); __Pyx_INCREF(((PyObject *)__pyx_kp_s_72)); PyTuple_SET_ITEM(__pyx_k_tuple_73, 0, ((PyObject *)__pyx_kp_s_72)); @@ -61373,7 +65049,7 @@ static int __Pyx_InitCachedConstants(void) { * N = len(data) * for i from 0 <= i < N: */ - __pyx_k_tuple_75 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_75 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_75); __Pyx_INCREF(((PyObject *)__pyx_kp_s_74)); PyTuple_SET_ITEM(__pyx_k_tuple_75, 0, ((PyObject *)__pyx_kp_s_74)); @@ -61387,7 +65063,7 @@ static int __Pyx_InitCachedConstants(void) { * N = len(queue) * ptr1 = 0 */ - __pyx_k_tuple_77 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_77 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_77); __Pyx_INCREF(((PyObject *)__pyx_kp_s_76)); PyTuple_SET_ITEM(__pyx_k_tuple_77, 0, ((PyObject *)__pyx_kp_s_76)); @@ -61401,7 +65077,7 @@ static int __Pyx_InitCachedConstants(void) { * J2_set.add(combined_pattern) * */ - __pyx_k_tuple_79 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_79)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_79 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_79)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 393; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_79); __Pyx_INCREF(__pyx_int_neg_1); PyTuple_SET_ITEM(__pyx_k_tuple_79, 0, __pyx_int_neg_1); @@ -61415,7 +65091,7 @@ static int __Pyx_InitCachedConstants(void) { * IJ_set.add(combined_pattern) * */ - __pyx_k_tuple_80 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_80)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_80 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_80)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 400; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_80); __Pyx_INCREF(__pyx_int_neg_1); PyTuple_SET_ITEM(__pyx_k_tuple_80, 0, __pyx_int_neg_1); @@ -61429,7 +65105,7 @@ static int __Pyx_InitCachedConstants(void) { * IJ_set.add(combined_pattern) * combined_pattern = pattern2 + (-1,) + pattern1 */ - __pyx_k_tuple_81 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_81)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_81 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_81)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_81); __Pyx_INCREF(__pyx_int_neg_1); PyTuple_SET_ITEM(__pyx_k_tuple_81, 0, __pyx_int_neg_1); @@ -61443,7 +65119,7 @@ static int __Pyx_InitCachedConstants(void) { * IJ_set.add(combined_pattern) * */ - __pyx_k_tuple_82 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_82)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_82 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_82)) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 409; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_82); __Pyx_INCREF(__pyx_int_neg_1); PyTuple_SET_ITEM(__pyx_k_tuple_82, 0, __pyx_int_neg_1); @@ -61457,7 +65133,7 @@ static int __Pyx_InitCachedConstants(void) { * for i from 0 <= i < N: * j = isa.arr[i] */ - __pyx_k_tuple_93 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_93)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_93 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_93)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_93); __Pyx_INCREF(((PyObject *)__pyx_kp_s_92)); PyTuple_SET_ITEM(__pyx_k_tuple_93, 0, ((PyObject *)__pyx_kp_s_92)); @@ -61471,7 +65147,7 @@ static int __Pyx_InitCachedConstants(void) { * for w_i in self.ha: * f.write("%d " % w_i) */ - __pyx_k_tuple_96 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_96 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_96); __Pyx_INCREF(((PyObject *)__pyx_kp_s_14)); PyTuple_SET_ITEM(__pyx_k_tuple_96, 0, ((PyObject *)__pyx_kp_s_14)); @@ -61485,7 +65161,7 @@ static int __Pyx_InitCachedConstants(void) { * * cdef int __search_high(self, int word_id, int offset, int low, int high): */ - __pyx_k_tuple_97 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_97)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_97 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_97)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_97); __Pyx_INCREF(((PyObject *)__pyx_kp_s_14)); PyTuple_SET_ITEM(__pyx_k_tuple_97, 0, ((PyObject *)__pyx_kp_s_14)); @@ -61499,7 +65175,7 @@ static int __Pyx_InitCachedConstants(void) { * self.darray.write_enhanced_handle(f) * for a_i in self.sa: */ - __pyx_k_tuple_98 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_98)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_98 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_98)) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 198; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_98); __Pyx_INCREF(Py_None); PyTuple_SET_ITEM(__pyx_k_tuple_98, 0, Py_None); @@ -61512,47 +65188,79 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(Py_None); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_98)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":92 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":60 + * self.fid = malloc(NFEATURES*sizeof(int)) + * cdef unsigned i + * for i, fnames in enumerate(('EgivenFCoherent', 'SampleCountF', 'CountEF', # <<<<<<<<<<<<<< + * 'MaxLexFgivenE', 'MaxLexEgivenF', 'IsSingletonF', 'IsSingletonFE')): + * self.fid[i] = FD.index(fnames) + */ + __pyx_k_tuple_100 = PyTuple_New(7); if (unlikely(!__pyx_k_tuple_100)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_100); + __Pyx_INCREF(((PyObject *)__pyx_n_s__EgivenFCoherent)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 0, ((PyObject *)__pyx_n_s__EgivenFCoherent)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__EgivenFCoherent)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__SampleCountF)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 1, ((PyObject *)__pyx_n_s__SampleCountF)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SampleCountF)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__CountEF)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 2, ((PyObject *)__pyx_n_s__CountEF)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CountEF)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__MaxLexFgivenE)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 3, ((PyObject *)__pyx_n_s__MaxLexFgivenE)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__MaxLexFgivenE)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__MaxLexEgivenF)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 4, ((PyObject *)__pyx_n_s__MaxLexEgivenF)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__MaxLexEgivenF)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__IsSingletonF)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 5, ((PyObject *)__pyx_n_s__IsSingletonF)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IsSingletonF)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__IsSingletonFE)); + PyTuple_SET_ITEM(__pyx_k_tuple_100, 6, ((PyObject *)__pyx_n_s__IsSingletonFE)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IsSingletonFE)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_100)); + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":93 * logger.info("Sampling strategy: uniform, max sample size = %d", sample_size) * else: * logger.info("Sampling strategy: no sampling") # <<<<<<<<<<<<<< * * def sample(self, PhraseLocation phrase_location): */ - __pyx_k_tuple_102 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_102)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_102); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_101)); - PyTuple_SET_ITEM(__pyx_k_tuple_102, 0, ((PyObject *)__pyx_kp_s_101)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_101)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_102)); + __pyx_k_tuple_104 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_104)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_104); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_103)); + PyTuple_SET_ITEM(__pyx_k_tuple_104, 0, ((PyObject *)__pyx_kp_s_103)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_103)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_104)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":300 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":302 * self.rules.root = ExtendedTrieNode(phrase_location=PhraseLocation()) * if alignment is None: * raise Exception("Must specify an alignment object") # <<<<<<<<<<<<<< * self.alignment = alignment * */ - __pyx_k_tuple_107 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_107)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_107); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_106)); - PyTuple_SET_ITEM(__pyx_k_tuple_107, 0, ((PyObject *)__pyx_kp_s_106)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_106)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_107)); + __pyx_k_tuple_109 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_109)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_109); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_108)); + PyTuple_SET_ITEM(__pyx_k_tuple_109, 0, ((PyObject *)__pyx_kp_s_108)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_108)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_109)); - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1004 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":1008 * else: * #ERROR: We never get here * raise Exception("Keyword trie error") # <<<<<<<<<<<<<< * # checking whether lookup_required * if lookup_required: */ - __pyx_k_tuple_122 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_122)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_122); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_121)); - PyTuple_SET_ITEM(__pyx_k_tuple_122, 0, ((PyObject *)__pyx_kp_s_121)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_121)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_122)); + __pyx_k_tuple_124 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_124)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_124); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_123)); + PyTuple_SET_ITEM(__pyx_k_tuple_124, 0, ((PyObject *)__pyx_kp_s_123)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_123)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_124)); /* "_sa.pyx":9 * resource.getrusage(resource.RUSAGE_SELF).ru_stime) @@ -61561,16 +65269,16 @@ static int __Pyx_InitCachedConstants(void) { * if filename.endswith('.gz'): * return gzip.GzipFile(filename) */ - __pyx_k_tuple_134 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_134); + __pyx_k_tuple_136 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_136)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_136); __Pyx_INCREF(((PyObject *)__pyx_n_s__filename)); - PyTuple_SET_ITEM(__pyx_k_tuple_134, 0, ((PyObject *)__pyx_n_s__filename)); + PyTuple_SET_ITEM(__pyx_k_tuple_136, 0, ((PyObject *)__pyx_n_s__filename)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename)); __Pyx_INCREF(((PyObject *)__pyx_n_s__filename)); - PyTuple_SET_ITEM(__pyx_k_tuple_134, 1, ((PyObject *)__pyx_n_s__filename)); + PyTuple_SET_ITEM(__pyx_k_tuple_136, 1, ((PyObject *)__pyx_n_s__filename)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__filename)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_134)); - __pyx_k_codeobj_135 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_134, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_136, __pyx_n_s__gzip_or_text, 9, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_135)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_136)); + __pyx_k_codeobj_137 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_136, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_138, __pyx_n_s__gzip_or_text, 9, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_137)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /* "_sa.pyx":15 * return open(filename) @@ -61579,12 +65287,12 @@ static int __Pyx_InitCachedConstants(void) { * * include "float_list.pxi" */ - __pyx_k_tuple_138 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_138)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_138); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_137)); - PyTuple_SET_ITEM(__pyx_k_tuple_138, 0, ((PyObject *)__pyx_kp_s_137)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_137)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_138)); + __pyx_k_tuple_140 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_140)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_140); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_139)); + PyTuple_SET_ITEM(__pyx_k_tuple_140, 0, ((PyObject *)__pyx_kp_s_139)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_139)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_140)); /* "/Users/vchahun/Sandbox/cdec/python/src/sa/sym.pxi":104 * return ALPHABET.setindex(sym, id) @@ -61592,16 +65300,16 @@ static int __Pyx_InitCachedConstants(void) { * def sym_fromstring(char* string, bint terminal): # <<<<<<<<<<<<<< * return ALPHABET.fromstring(string, terminal) */ - __pyx_k_tuple_139 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_139)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_139); + __pyx_k_tuple_141 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_141)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_141); __Pyx_INCREF(((PyObject *)__pyx_n_s__string)); - PyTuple_SET_ITEM(__pyx_k_tuple_139, 0, ((PyObject *)__pyx_n_s__string)); + PyTuple_SET_ITEM(__pyx_k_tuple_141, 0, ((PyObject *)__pyx_n_s__string)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__string)); __Pyx_INCREF(((PyObject *)__pyx_n_s__terminal)); - PyTuple_SET_ITEM(__pyx_k_tuple_139, 1, ((PyObject *)__pyx_n_s__terminal)); + PyTuple_SET_ITEM(__pyx_k_tuple_141, 1, ((PyObject *)__pyx_n_s__terminal)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__terminal)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_139)); - __pyx_k_codeobj_140 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_139, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_141, __pyx_n_s__sym_fromstring, 104, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_140)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_141)); + __pyx_k_codeobj_142 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_141, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_143, __pyx_n_s__sym_fromstring, 104, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_142)) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -61614,10 +65322,15 @@ static int __Pyx_InitGlobals(void) { __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_6 = PyInt_FromLong(6); if (unlikely(!__pyx_int_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_7 = PyInt_FromLong(7); if (unlikely(!__pyx_int_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_10 = PyInt_FromLong(10); if (unlikely(!__pyx_int_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_20 = PyInt_FromLong(20); if (unlikely(!__pyx_int_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_int_neg_99 = PyInt_FromLong(-99); if (unlikely(!__pyx_int_neg_99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_1000 = PyInt_FromLong(1000); if (unlikely(!__pyx_int_1000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; __pyx_int_65536 = PyInt_FromLong(65536); if (unlikely(!__pyx_int_65536)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; return 0; @@ -61694,6 +65407,7 @@ PyMODINIT_FUNC PyInit__sa(void) if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Global init code ---*/ __pyx_v_3_sa_ALPHABET = ((struct __pyx_obj_3_sa_Alphabet *)Py_None); Py_INCREF(Py_None); + __pyx_v_3_sa_FD = ((struct __pyx_obj_3_sa_StringMap *)Py_None); Py_INCREF(Py_None); /*--- Variable export code ---*/ /*--- Function export code ---*/ if (__Pyx_ExportFunction("sym_tostring", (void (*)(void))__pyx_f_3_sa_sym_tostring, "char *(int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -61701,16 +65415,6 @@ PyMODINIT_FUNC PyInit__sa(void) if (__Pyx_ExportFunction("sym_isvar", (void (*)(void))__pyx_f_3_sa_sym_isvar, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_ExportFunction("sym_getindex", (void (*)(void))__pyx_f_3_sa_sym_getindex, "int (int)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Type init code ---*/ - __pyx_vtabptr_3_sa_Phrase = &__pyx_vtable_3_sa_Phrase; - __pyx_vtable_3_sa_Phrase.chunkpos = (int (*)(struct __pyx_obj_3_sa_Phrase *, int))__pyx_f_3_sa_6Phrase_chunkpos; - __pyx_vtable_3_sa_Phrase.chunklen = (int (*)(struct __pyx_obj_3_sa_Phrase *, int))__pyx_f_3_sa_6Phrase_chunklen; - if (PyType_Ready(&__pyx_type_3_sa_Phrase) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_3_sa_Phrase.tp_dict, __pyx_vtabptr_3_sa_Phrase) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Phrase", (PyObject *)&__pyx_type_3_sa_Phrase) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa_Phrase = &__pyx_type_3_sa_Phrase; - if (PyType_Ready(&__pyx_type_3_sa_Rule) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Rule", (PyObject *)&__pyx_type_3_sa_Rule) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa_Rule = &__pyx_type_3_sa_Rule; __pyx_vtabptr_3_sa_FloatList = &__pyx_vtable_3_sa_FloatList; __pyx_vtable_3_sa_FloatList.set = (void (*)(struct __pyx_obj_3_sa_FloatList *, int, float))__pyx_f_3_sa_9FloatList_set; __pyx_vtable_3_sa_FloatList.write_handle = (void (*)(struct __pyx_obj_3_sa_FloatList *, FILE *))__pyx_f_3_sa_9FloatList_write_handle; @@ -61731,6 +65435,19 @@ PyMODINIT_FUNC PyInit__sa(void) if (__Pyx_SetVtable(__pyx_type_3_sa_IntList.tp_dict, __pyx_vtabptr_3_sa_IntList) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "IntList", (PyObject *)&__pyx_type_3_sa_IntList) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_IntList = &__pyx_type_3_sa_IntList; + if (PyType_Ready(&__pyx_type_3_sa_FeatureVector) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "FeatureVector", (PyObject *)&__pyx_type_3_sa_FeatureVector) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa_FeatureVector = &__pyx_type_3_sa_FeatureVector; + __pyx_vtabptr_3_sa_Phrase = &__pyx_vtable_3_sa_Phrase; + __pyx_vtable_3_sa_Phrase.chunkpos = (int (*)(struct __pyx_obj_3_sa_Phrase *, int))__pyx_f_3_sa_6Phrase_chunkpos; + __pyx_vtable_3_sa_Phrase.chunklen = (int (*)(struct __pyx_obj_3_sa_Phrase *, int))__pyx_f_3_sa_6Phrase_chunklen; + if (PyType_Ready(&__pyx_type_3_sa_Phrase) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_Phrase.tp_dict, __pyx_vtabptr_3_sa_Phrase) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Phrase", (PyObject *)&__pyx_type_3_sa_Phrase) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa_Phrase = &__pyx_type_3_sa_Phrase; + if (PyType_Ready(&__pyx_type_3_sa_Rule) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Rule", (PyObject *)&__pyx_type_3_sa_Rule) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa_Rule = &__pyx_type_3_sa_Rule; __pyx_vtabptr_3_sa_StringMap = &__pyx_vtable_3_sa_StringMap; __pyx_vtable_3_sa_StringMap.word = (char *(*)(struct __pyx_obj_3_sa_StringMap *, int))__pyx_f_3_sa_9StringMap_word; __pyx_vtable_3_sa_StringMap.index = (int (*)(struct __pyx_obj_3_sa_StringMap *, char *))__pyx_f_3_sa_9StringMap_index; @@ -61802,44 +65519,58 @@ PyMODINIT_FUNC PyInit__sa(void) __pyx_vtabptr_3_sa_TrieMap = &__pyx_vtable_3_sa_TrieMap; __pyx_vtable_3_sa_TrieMap._insert = (struct __pyx_t_3_sa__Trie_Node *(*)(struct __pyx_obj_3_sa_TrieMap *, int *, int))__pyx_f_3_sa_7TrieMap__insert; __pyx_vtable_3_sa_TrieMap._contains = (struct __pyx_t_3_sa__Trie_Node *(*)(struct __pyx_obj_3_sa_TrieMap *, int *, int))__pyx_f_3_sa_7TrieMap__contains; - if (PyType_Ready(&__pyx_type_3_sa_TrieMap) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_3_sa_TrieMap.tp_dict, __pyx_vtabptr_3_sa_TrieMap) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TrieMap", (PyObject *)&__pyx_type_3_sa_TrieMap) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_TrieMap) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_TrieMap.tp_dict, __pyx_vtabptr_3_sa_TrieMap) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "TrieMap", (PyObject *)&__pyx_type_3_sa_TrieMap) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_TrieMap = &__pyx_type_3_sa_TrieMap; __pyx_vtabptr_3_sa_Precomputation = &__pyx_vtable_3_sa_Precomputation; __pyx_vtable_3_sa_Precomputation.read_map = (PyObject *(*)(struct __pyx_obj_3_sa_Precomputation *, FILE *))__pyx_f_3_sa_14Precomputation_read_map; __pyx_vtable_3_sa_Precomputation.write_map = (PyObject *(*)(struct __pyx_obj_3_sa_Precomputation *, PyObject *, FILE *))__pyx_f_3_sa_14Precomputation_write_map; - if (PyType_Ready(&__pyx_type_3_sa_Precomputation) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_3_sa_Precomputation.tp_dict, __pyx_vtabptr_3_sa_Precomputation) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Precomputation", (PyObject *)&__pyx_type_3_sa_Precomputation) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_Precomputation) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_Precomputation.tp_dict, __pyx_vtabptr_3_sa_Precomputation) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Precomputation", (PyObject *)&__pyx_type_3_sa_Precomputation) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_Precomputation = &__pyx_type_3_sa_Precomputation; __pyx_vtabptr_3_sa_SuffixArray = &__pyx_vtable_3_sa_SuffixArray; __pyx_vtable_3_sa_SuffixArray.__pyx___search_high = (int (*)(struct __pyx_obj_3_sa_SuffixArray *, int, int, int, int))__pyx_f_3_sa_11SuffixArray___search_high; __pyx_vtable_3_sa_SuffixArray.__pyx___search_low = (int (*)(struct __pyx_obj_3_sa_SuffixArray *, int, int, int, int))__pyx_f_3_sa_11SuffixArray___search_low; __pyx_vtable_3_sa_SuffixArray.__pyx___get_range = (PyObject *(*)(struct __pyx_obj_3_sa_SuffixArray *, int, int, int, int, int))__pyx_f_3_sa_11SuffixArray___get_range; __pyx_vtable_3_sa_SuffixArray.__pyx___lookup_helper = (PyObject *(*)(struct __pyx_obj_3_sa_SuffixArray *, int, int, int, int))__pyx_f_3_sa_11SuffixArray___lookup_helper; - if (PyType_Ready(&__pyx_type_3_sa_SuffixArray) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_3_sa_SuffixArray.tp_dict, __pyx_vtabptr_3_sa_SuffixArray) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "SuffixArray", (PyObject *)&__pyx_type_3_sa_SuffixArray) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_SuffixArray) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_SuffixArray.tp_dict, __pyx_vtabptr_3_sa_SuffixArray) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "SuffixArray", (PyObject *)&__pyx_type_3_sa_SuffixArray) < 0) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_SuffixArray = &__pyx_type_3_sa_SuffixArray; - if (PyType_Ready(&__pyx_type_3_sa_TrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TrieNode", (PyObject *)&__pyx_type_3_sa_TrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_3_sa_Scorer = &__pyx_vtable_3_sa_Scorer; + __pyx_vtable_3_sa_Scorer.score = (struct __pyx_obj_3_sa_FeatureVector *(*)(struct __pyx_obj_3_sa_Scorer *, struct __pyx_obj_3_sa_Phrase *, struct __pyx_obj_3_sa_Phrase *, unsigned int, unsigned int, unsigned int))__pyx_f_3_sa_6Scorer_score; + if (PyType_Ready(&__pyx_type_3_sa_Scorer) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_Scorer.tp_dict, __pyx_vtabptr_3_sa_Scorer) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_3_sa_Scorer) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa_Scorer = &__pyx_type_3_sa_Scorer; + __pyx_vtabptr_3_sa_DefaultScorer = &__pyx_vtable_3_sa_DefaultScorer; + __pyx_vtable_3_sa_DefaultScorer.__pyx_base = *__pyx_vtabptr_3_sa_Scorer; + __pyx_vtable_3_sa_DefaultScorer.__pyx_base.score = (struct __pyx_obj_3_sa_FeatureVector *(*)(struct __pyx_obj_3_sa_Scorer *, struct __pyx_obj_3_sa_Phrase *, struct __pyx_obj_3_sa_Phrase *, unsigned int, unsigned int, unsigned int))__pyx_f_3_sa_13DefaultScorer_score; + __pyx_type_3_sa_DefaultScorer.tp_base = __pyx_ptype_3_sa_Scorer; + if (PyType_Ready(&__pyx_type_3_sa_DefaultScorer) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_DefaultScorer.tp_dict, __pyx_vtabptr_3_sa_DefaultScorer) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "DefaultScorer", (PyObject *)&__pyx_type_3_sa_DefaultScorer) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa_DefaultScorer = &__pyx_type_3_sa_DefaultScorer; + if (PyType_Ready(&__pyx_type_3_sa_TrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "TrieNode", (PyObject *)&__pyx_type_3_sa_TrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_TrieNode = &__pyx_type_3_sa_TrieNode; __pyx_type_3_sa_ExtendedTrieNode.tp_base = __pyx_ptype_3_sa_TrieNode; - if (PyType_Ready(&__pyx_type_3_sa_ExtendedTrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "ExtendedTrieNode", (PyObject *)&__pyx_type_3_sa_ExtendedTrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_ExtendedTrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "ExtendedTrieNode", (PyObject *)&__pyx_type_3_sa_ExtendedTrieNode) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_ExtendedTrieNode = &__pyx_type_3_sa_ExtendedTrieNode; - if (PyType_Ready(&__pyx_type_3_sa_TrieTable) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TrieTable", (PyObject *)&__pyx_type_3_sa_TrieTable) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_TrieTable) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "TrieTable", (PyObject *)&__pyx_type_3_sa_TrieTable) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_TrieTable = &__pyx_type_3_sa_TrieTable; __pyx_vtabptr_3_sa_PhraseLocation = &__pyx_vtable_3_sa_PhraseLocation; __pyx_vtable_3_sa_PhraseLocation.contains = (int (*)(struct __pyx_obj_3_sa_PhraseLocation *, int))__pyx_f_3_sa_14PhraseLocation_contains; - if (PyType_Ready(&__pyx_type_3_sa_PhraseLocation) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_3_sa_PhraseLocation.tp_dict, __pyx_vtabptr_3_sa_PhraseLocation) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "PhraseLocation", (PyObject *)&__pyx_type_3_sa_PhraseLocation) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_PhraseLocation) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_PhraseLocation.tp_dict, __pyx_vtabptr_3_sa_PhraseLocation) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "PhraseLocation", (PyObject *)&__pyx_type_3_sa_PhraseLocation) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_PhraseLocation = &__pyx_type_3_sa_PhraseLocation; - if (PyType_Ready(&__pyx_type_3_sa_Sampler) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Sampler", (PyObject *)&__pyx_type_3_sa_Sampler) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_Sampler) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Sampler", (PyObject *)&__pyx_type_3_sa_Sampler) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_Sampler = &__pyx_type_3_sa_Sampler; __pyx_vtabptr_3_sa_HieroCachingRuleFactory = &__pyx_vtable_3_sa_HieroCachingRuleFactory; __pyx_vtable_3_sa_HieroCachingRuleFactory.set_idmap = (PyObject *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, struct __pyx_obj_3_sa_DataArray *))__pyx_f_3_sa_23HieroCachingRuleFactory_set_idmap; @@ -61855,22 +65586,36 @@ PyMODINIT_FUNC PyInit__sa(void) __pyx_vtable_3_sa_HieroCachingRuleFactory.find_projection = (PyObject *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, int, int, int *, int *, int *, int *))__pyx_f_3_sa_23HieroCachingRuleFactory_find_projection; __pyx_vtable_3_sa_HieroCachingRuleFactory.int_arr_extend = (int *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, int *, int *, int *, int))__pyx_f_3_sa_23HieroCachingRuleFactory_int_arr_extend; __pyx_vtable_3_sa_HieroCachingRuleFactory.extract_phrases = (PyObject *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, int, int, int *, int *, int *, int, int, int, int *, int *, int *, int, int, int))__pyx_f_3_sa_23HieroCachingRuleFactory_extract_phrases; - __pyx_vtable_3_sa_HieroCachingRuleFactory.create_alignments = (PyObject *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, int *, int, PyObject *, PyObject *))__pyx_f_3_sa_23HieroCachingRuleFactory_create_alignments; + __pyx_vtable_3_sa_HieroCachingRuleFactory.create_alignments = (struct __pyx_obj_3_sa_IntList *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, int *, int, PyObject *, PyObject *))__pyx_f_3_sa_23HieroCachingRuleFactory_create_alignments; __pyx_vtable_3_sa_HieroCachingRuleFactory.extract = (PyObject *(*)(struct __pyx_obj_3_sa_HieroCachingRuleFactory *, struct __pyx_obj_3_sa_Phrase *, struct __pyx_t_3_sa_Matching *, int *, int))__pyx_f_3_sa_23HieroCachingRuleFactory_extract; - if (PyType_Ready(&__pyx_type_3_sa_HieroCachingRuleFactory) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_3_sa_HieroCachingRuleFactory.tp_dict, __pyx_vtabptr_3_sa_HieroCachingRuleFactory) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HieroCachingRuleFactory", (PyObject *)&__pyx_type_3_sa_HieroCachingRuleFactory) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_3_sa_HieroCachingRuleFactory) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_3_sa_HieroCachingRuleFactory.tp_dict, __pyx_vtabptr_3_sa_HieroCachingRuleFactory) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HieroCachingRuleFactory", (PyObject *)&__pyx_type_3_sa_HieroCachingRuleFactory) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_3_sa_HieroCachingRuleFactory = &__pyx_type_3_sa_HieroCachingRuleFactory; - if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct__read_bitext) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa___pyx_scope_struct__read_bitext = &__pyx_type_3_sa___pyx_scope_struct__read_bitext; - if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_1_genexpr) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa___pyx_scope_struct_1_genexpr = &__pyx_type_3_sa___pyx_scope_struct_1_genexpr; - if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_2_compute_stats) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa___pyx_scope_struct_2_compute_stats = &__pyx_type_3_sa___pyx_scope_struct_2_compute_stats; - if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_3___iter__) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa___pyx_scope_struct_3___iter__ = &__pyx_type_3_sa___pyx_scope_struct_3___iter__; - if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_4_input) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_3_sa___pyx_scope_struct_4_input = &__pyx_type_3_sa___pyx_scope_struct_4_input; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct____iter__ = &__pyx_type_3_sa___pyx_scope_struct____iter__; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_1_read_bitext) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_1_read_bitext = &__pyx_type_3_sa___pyx_scope_struct_1_read_bitext; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_2_genexpr) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_2_genexpr = &__pyx_type_3_sa___pyx_scope_struct_2_genexpr; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_3_compute_stats) < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_3_compute_stats = &__pyx_type_3_sa___pyx_scope_struct_3_compute_stats; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_4___iter__) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_4___iter__ = &__pyx_type_3_sa___pyx_scope_struct_4___iter__; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_5___str__ = &__pyx_type_3_sa___pyx_scope_struct_5___str__; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_6_genexpr = &__pyx_type_3_sa___pyx_scope_struct_6_genexpr; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_7_alignments) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_7_alignments = &__pyx_type_3_sa___pyx_scope_struct_7_alignments; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_8___iter__) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_8___iter__ = &__pyx_type_3_sa___pyx_scope_struct_8___iter__; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_9___str__) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_9___str__ = &__pyx_type_3_sa___pyx_scope_struct_9___str__; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_10_genexpr) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_10_genexpr = &__pyx_type_3_sa___pyx_scope_struct_10_genexpr; + if (PyType_Ready(&__pyx_type_3_sa___pyx_scope_struct_11_input) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 923; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_3_sa___pyx_scope_struct_11_input = &__pyx_type_3_sa___pyx_scope_struct_11_input; /*--- Type import code ---*/ /*--- Variable import code ---*/ /*--- Function import code ---*/ @@ -61933,7 +65678,7 @@ PyMODINIT_FUNC PyInit__sa(void) __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getLogger); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_138), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_140), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_s__logger, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -62023,6 +65768,121 @@ PyMODINIT_FUNC PyInit__sa(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sym_fromstring, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":1 + * cdef StringMap FD = StringMap() # <<<<<<<<<<<<<< + * + * INITIAL_CAPACITY = 7 # default number of features + */ + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_3_sa_StringMap)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_XGOTREF(((PyObject *)__pyx_v_3_sa_FD)); + __Pyx_DECREF(((PyObject *)__pyx_v_3_sa_FD)); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_v_3_sa_FD = ((struct __pyx_obj_3_sa_StringMap *)__pyx_t_1); + __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":3 + * cdef StringMap FD = StringMap() + * + * INITIAL_CAPACITY = 7 # default number of features # <<<<<<<<<<<<<< + * INCREMENT = INITIAL_CAPACITY # double size + * + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__INITIAL_CAPACITY, __pyx_int_7) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":4 + * + * INITIAL_CAPACITY = 7 # default number of features + * INCREMENT = INITIAL_CAPACITY # double size # <<<<<<<<<<<<<< + * + * cdef class FeatureVector: + */ + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__INITIAL_CAPACITY); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__INCREMENT, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":39 + * from libc.math cimport log10 + * + * MAXSCORE = -99 # <<<<<<<<<<<<<< + * EgivenFCoherent = 0 + * SampleCountF = 1 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__MAXSCORE, __pyx_int_neg_99) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":40 + * + * MAXSCORE = -99 + * EgivenFCoherent = 0 # <<<<<<<<<<<<<< + * SampleCountF = 1 + * CountEF = 2 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__EgivenFCoherent, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":41 + * MAXSCORE = -99 + * EgivenFCoherent = 0 + * SampleCountF = 1 # <<<<<<<<<<<<<< + * CountEF = 2 + * MaxLexFgivenE = 3 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__SampleCountF, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":42 + * EgivenFCoherent = 0 + * SampleCountF = 1 + * CountEF = 2 # <<<<<<<<<<<<<< + * MaxLexFgivenE = 3 + * MaxLexEgivenF = 4 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CountEF, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":43 + * SampleCountF = 1 + * CountEF = 2 + * MaxLexFgivenE = 3 # <<<<<<<<<<<<<< + * MaxLexEgivenF = 4 + * IsSingletonF = 5 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__MaxLexFgivenE, __pyx_int_3) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":44 + * CountEF = 2 + * MaxLexFgivenE = 3 + * MaxLexEgivenF = 4 # <<<<<<<<<<<<<< + * IsSingletonF = 5 + * IsSingletonFE = 6 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__MaxLexEgivenF, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":45 + * MaxLexFgivenE = 3 + * MaxLexEgivenF = 4 + * IsSingletonF = 5 # <<<<<<<<<<<<<< + * IsSingletonFE = 6 + * NFEATURES = 7 + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IsSingletonF, __pyx_int_5) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":46 + * MaxLexEgivenF = 4 + * IsSingletonF = 5 + * IsSingletonFE = 6 # <<<<<<<<<<<<<< + * NFEATURES = 7 + * + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__IsSingletonFE, __pyx_int_6) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/features.pxi":47 + * IsSingletonF = 5 + * IsSingletonFE = 6 + * NFEATURES = 7 # <<<<<<<<<<<<<< + * + * cdef class DefaultScorer(Scorer): + */ + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__NFEATURES, __pyx_int_7) < 0) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":5 * # Much faster than the Python numbers reported there. * # Note to reader: this code is closer to C than Python @@ -62038,13 +65898,49 @@ PyMODINIT_FUNC PyInit__sa(void) /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":11 * from libc.math cimport fmod, ceil, floor, log * + * from collections import defaultdict, Counter # <<<<<<<<<<<<<< + * + * cdef int PRECOMPUTE = 0 + */ + __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_INCREF(((PyObject *)__pyx_n_s__defaultdict)); + PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__defaultdict)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__defaultdict)); + __Pyx_INCREF(((PyObject *)__pyx_n_s__Counter)); + PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__Counter)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Counter)); + __pyx_t_2 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), ((PyObject *)__pyx_t_1), -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__defaultdict); + if (__pyx_t_1 == NULL) { + if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__defaultdict); + if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__defaultdict, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__Counter); + if (__pyx_t_1 == NULL) { + if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseImportError(__pyx_n_s__Counter); + if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + } + __Pyx_GOTREF(__pyx_t_1); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Counter, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":13 + * from collections import defaultdict, Counter + * * cdef int PRECOMPUTE = 0 # <<<<<<<<<<<<<< * cdef int MERGE = 1 * cdef int BAEZA_YATES = 2 */ __pyx_v_3_sa_PRECOMPUTE = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":12 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":14 * * cdef int PRECOMPUTE = 0 * cdef int MERGE = 1 # <<<<<<<<<<<<<< @@ -62053,7 +65949,7 @@ PyMODINIT_FUNC PyInit__sa(void) */ __pyx_v_3_sa_MERGE = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":13 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":15 * cdef int PRECOMPUTE = 0 * cdef int MERGE = 1 * cdef int BAEZA_YATES = 2 # <<<<<<<<<<<<<< @@ -62062,55 +65958,55 @@ PyMODINIT_FUNC PyInit__sa(void) */ __pyx_v_3_sa_BAEZA_YATES = 2; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":16 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":18 * * # NOTE: was encoded as a non-terminal in the previous version * cdef int EPSILON = sym_fromstring('*EPS*', True) # <<<<<<<<<<<<<< * * cdef class TrieNode: */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__sym_fromstring); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_142)); - PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_142)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_142)); - PyTuple_SET_ITEM(__pyx_t_3, 1, __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[8]; __pyx_lineno = 16; __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_4 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(((PyObject *)__pyx_kp_s_144)); + PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_144)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_144)); + PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_3_sa_EPSILON = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":39 + /* "/Users/vchahun/Sandbox/cdec/python/src/sa/rulefactory.pxi":41 * cdef public int count * cdef public root * def __cinit__(self, extended=False): # <<<<<<<<<<<<<< * self.count = 0 * self.extended = extended */ - __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_2); - __pyx_k_99 = __pyx_t_2; - __Pyx_GIVEREF(__pyx_t_2); - __pyx_t_2 = 0; + __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_k_101 = __pyx_t_1; + __Pyx_GIVEREF(__pyx_t_1); + __pyx_t_1 = 0; /* "_sa.pyx":1 * import logging # <<<<<<<<<<<<<< * import resource * import gzip */ - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_2)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; + __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); @@ -62929,6 +66825,15 @@ bad: return module; } +static CYTHON_INLINE void __Pyx_RaiseImportError(PyObject *name) { +#if PY_MAJOR_VERSION < 3 + PyErr_Format(PyExc_ImportError, "cannot import name %.230s", + PyString_AsString(name)); +#else + PyErr_Format(PyExc_ImportError, "cannot import name %S", name); +#endif +} + static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { #if CYTHON_COMPILING_IN_PYPY return PyObject_RichCompareBool(s1, s2, equals); @@ -63009,6 +66914,415 @@ static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int #endif } +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("", + func_name, (void *)op); +#else + return PyString_FromFormat("", + PyString_AsString(func_name), (void *)op); +#endif +} +#if CYTHON_COMPILING_IN_PYPY +static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + PyCFunctionObject* f = (PyCFunctionObject*)func; + PyCFunction meth = PyCFunction_GET_FUNCTION(func); + PyObject *self = PyCFunction_GET_SELF(func); + Py_ssize_t size; + switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) { + case METH_VARARGS: + if (likely(kw == NULL) || PyDict_Size(kw) == 0) + return (*meth)(self, arg); + break; + case METH_VARARGS | METH_KEYWORDS: + return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); + case METH_NOARGS: + if (likely(kw == NULL) || PyDict_Size(kw) == 0) { + size = PyTuple_GET_SIZE(arg); + if (size == 0) + return (*meth)(self, NULL); + PyErr_Format(PyExc_TypeError, + "%.200s() takes no arguments (%zd given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + case METH_O: + if (likely(kw == NULL) || PyDict_Size(kw) == 0) { + size = PyTuple_GET_SIZE(arg); + if (size == 1) + return (*meth)(self, PyTuple_GET_ITEM(arg, 0)); + PyErr_Format(PyExc_TypeError, + "%.200s() takes exactly one argument (%zd given)", + f->m_ml->ml_name, size); + return NULL; + } + break; + default: + PyErr_SetString(PyExc_SystemError, "Bad call flags in " + "__Pyx_CyFunction_Call. METH_OLDARGS is no " + "longer supported!"); + return NULL; + } + PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", + f->m_ml->ml_name); + return NULL; +} +#else +static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { + return PyCFunction_Call(func, arg, kw); +} +#endif +static PyTypeObject __pyx_CyFunctionType_type = { + PyVarObject_HEAD_INIT(0, 0) + __Pyx_NAMESTR("cython_function_or_method"), /*tp_name*/ + sizeof(__pyx_CyFunctionObject), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + (destructor) __Pyx_CyFunction_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ +#if PY_MAJOR_VERSION < 3 + 0, /*tp_compare*/ +#else + 0, /*reserved*/ +#endif + (reprfunc) __Pyx_CyFunction_repr, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + __Pyx_CyFunction_Call, /*tp_call*/ + 0, /*tp_str*/ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /*tp_as_buffer*/ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags*/ + 0, /*tp_doc*/ + (traverseproc) __Pyx_CyFunction_traverse, /*tp_traverse*/ + (inquiry) __Pyx_CyFunction_clear, /*tp_clear*/ + 0, /*tp_richcompare*/ + offsetof(__pyx_CyFunctionObject, func_weakreflist), /* tp_weaklistoffse */ + 0, /*tp_iter*/ + 0, /*tp_iternext*/ + __pyx_CyFunction_methods, /*tp_methods*/ + __pyx_CyFunction_members, /*tp_members*/ + __pyx_CyFunction_getsets, /*tp_getset*/ + 0, /*tp_base*/ + 0, /*tp_dict*/ + __Pyx_CyFunction_descr_get, /*tp_descr_get*/ + 0, /*tp_descr_set*/ + offsetof(__pyx_CyFunctionObject, func_dict),/*tp_dictoffset*/ + 0, /*tp_init*/ + 0, /*tp_alloc*/ + 0, /*tp_new*/ + 0, /*tp_free*/ + 0, /*tp_is_gc*/ + 0, /*tp_bases*/ + 0, /*tp_mro*/ + 0, /*tp_cache*/ + 0, /*tp_subclasses*/ + 0, /*tp_weaklist*/ + 0, /*tp_del*/ +#if PY_VERSION_HEX >= 0x02060000 + 0, /*tp_version_tag*/ +#endif +}; +static int __Pyx_CyFunction_init(void) { +#if !CYTHON_COMPILING_IN_PYPY + __pyx_CyFunctionType_type.tp_call = PyCFunction_Call; +#endif + if (PyType_Ready(&__pyx_CyFunctionType_type) < 0) + return -1; + __pyx_CyFunctionType = &__pyx_CyFunctionType_type; + return 0; +} +static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults = PyMem_Malloc(size); + if (!m->defaults) + return PyErr_NoMemory(); + memset(m->defaults, 0, sizeof(size)); + m->defaults_pyobjects = pyobjects; + return m->defaults; +} +static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) { + __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func; + m->defaults_tuple = tuple; + Py_INCREF(tuple); +} + static CYTHON_INLINE 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/sa/_sa.pxd b/python/src/sa/_sa.pxd index d390bfc5..f1cd8e29 100644 --- a/python/src/sa/_sa.pxd +++ b/python/src/sa/_sa.pxd @@ -1,3 +1,31 @@ +from libc.stdio cimport FILE + +cdef class FloatList: + cdef int size + cdef int increment + cdef int len + cdef float* arr + cdef void set(self, int i, float v) + cdef void write_handle(self, FILE* f) + cdef void read_handle(self, FILE* f) + +cdef class IntList: + cdef int size + cdef int increment + cdef int len + cdef int* arr + cdef void set(self, int i, int val) + cdef void _append(self, int val) + cdef void _extend(self, IntList other) + cdef void _extend_arr(self, int* other, int other_len) + cdef void _clear(self) + cdef void write_handle(self, FILE* f) + cdef void read_handle(self, FILE* f) + +cdef class FeatureVector: + cdef IntList names + cdef FloatList values + cdef class Phrase: cdef int *syms cdef int n, *varpos, n_vars @@ -5,11 +33,11 @@ cdef class Phrase: cdef public int chunklen(self, int k) cdef class Rule: - cdef public int lhs + cdef int lhs cdef readonly Phrase f, e - cdef float *cscores + cdef FeatureVector scores cdef int n_scores - cdef public word_alignments + cdef word_alignments cdef char* sym_tostring(int sym) cdef char* sym_tocat(int sym) diff --git a/python/src/sa/_sa.pyx b/python/src/sa/_sa.pyx index 710f8cb4..bb3a4d38 100644 --- a/python/src/sa/_sa.pyx +++ b/python/src/sa/_sa.pyx @@ -26,4 +26,5 @@ include "sym.pxi" include "rule.pxi" include "precomputation.pxi" include "suffix_array.pxi" +include "features.pxi" include "rulefactory.pxi" diff --git a/python/src/sa/features.pxi b/python/src/sa/features.pxi new file mode 100644 index 00000000..fcb93f26 --- /dev/null +++ b/python/src/sa/features.pxi @@ -0,0 +1,34 @@ +cdef StringMap FD = StringMap() + +INITIAL_CAPACITY = 7 # default number of features +INCREMENT = INITIAL_CAPACITY # double size + +cdef class FeatureVector: + def __cinit__(self): + self.names = IntList(INITIAL_CAPACITY, INCREMENT) + self.values = FloatList(INITIAL_CAPACITY, INCREMENT) + + def set(self, unsigned name, float value): + self.names.append(name) + self.values.append(value) + + def __iter__(self): + cdef unsigned i + for i in range(self.names.len): + yield (FD.word(self.names[i]), self.values[i]) + + def __str__(self): + return ' '.join('%s=%s' % feat for feat in self) + +cdef class Scorer: + cdef models + def __init__(self, *models): + names = [FD.index(model.__name__) for model in models] + self.models = zip(names, models) + + cdef FeatureVector score(self, Phrase fphrase, Phrase ephrase, + unsigned paircount, unsigned fcount, unsigned fsample_count): + cdef FeatureVector scores = FeatureVector() + for name, model in self.models: + scores.set(name, model(fphrase, ephrase, paircount, fcount, fsample_count)) + return scores diff --git a/python/src/sa/float_list.pxi b/python/src/sa/float_list.pxi index 88ffd5fc..b98e444f 100644 --- a/python/src/sa/float_list.pxi +++ b/python/src/sa/float_list.pxi @@ -7,10 +7,6 @@ from libc.stdlib cimport malloc, realloc, free from libc.string cimport memset, strcpy, strlen cdef class FloatList: - cdef int size - cdef int increment - cdef int len - cdef float* arr def __cinit__(self, int size=0, int increment=1, int initial_len=0): if initial_len > size: diff --git a/python/src/sa/int_list.pxi b/python/src/sa/int_list.pxi index ad14bc9c..63c0fe67 100644 --- a/python/src/sa/int_list.pxi +++ b/python/src/sa/int_list.pxi @@ -7,10 +7,6 @@ from libc.stdlib cimport malloc, realloc, free from libc.string cimport memset, memcpy cdef class IntList: - cdef int size - cdef int increment - cdef int len - cdef int* arr def __cinit__(self, int size=0, int increment=1, int initial_len=0): if initial_len > size: @@ -82,6 +78,11 @@ cdef class IntList: def __dealloc__(self): free(self.arr) + def __iter__(self): + cdef int i + for i in range(self.len): + yield self.arr[i] + def __getitem__(self, index): cdef int i, j, k if isinstance(index, int): diff --git a/python/src/sa/rule.pxi b/python/src/sa/rule.pxi index bf1a83c6..98fbac76 100644 --- a/python/src/sa/rule.pxi +++ b/python/src/sa/rule.pxi @@ -31,7 +31,7 @@ cdef class Phrase: for i from 0 <= i < self.n: s = self.syms[i] strs.append(sym_tostring(s)) - return " ".join(strs) + return ' '.join(strs) def handle(self): """return a hashable representation that normalizes the ordering @@ -60,7 +60,7 @@ cdef class Phrase: s = sym_setindex(s,i) i = i + 1 norm.append(sym_tostring(s)) - return " ".join(norm) + return ' '.join(norm) def arity(self): return self.n_vars @@ -158,45 +158,20 @@ cdef class Phrase: cdef class Rule: - def __cinit__(self, int lhs, Phrase f, Phrase e, - scores=None, word_alignments=None): - cdef int i, n - cdef char *rest - - if not sym_isvar(lhs): - raise Exception('Invalid LHS symbol: %d' % lhs) - + def __cinit__(self, int lhs, Phrase f, Phrase e, scores=None, word_alignments=None): + if not sym_isvar(lhs): raise Exception('Invalid LHS symbol: %d' % lhs) self.lhs = lhs self.f = f self.e = e - self.word_alignments = word_alignments - if scores is None: - self.cscores = NULL - self.n_scores = 0 - else: - n = len(scores) - self.cscores = malloc(n*sizeof(float)) - self.n_scores = n - for i from 0 <= i < n: - self.cscores[i] = scores[i] - - def __dealloc__(self): - if self.cscores != NULL: - free(self.cscores) + self.scores = scores def __hash__(self): return hash((self.lhs, self.f, self.e)) def __cmp__(self, Rule other): - return cmp((self.lhs, self.f, self.e, self.word_alignments), (other.lhs, other.f, other.e, self.word_alignments)) - - def __iadd__(self, Rule other): - if self.n_scores != other.n_scores: - raise ValueError - for i from 0 <= i < self.n_scores: - self.cscores[i] = self.cscores[i] + other.cscores[i] - return self + return cmp((self.lhs, self.f, self.e, self.word_alignments), + (other.lhs, other.f, other.e, self.word_alignments)) def fmerge(self, Phrase f): if self.f == f: @@ -206,31 +181,12 @@ cdef class Rule: return self.f.arity() def __str__(self): - scorestrs = [] - for i from 0 <= i < self.n_scores: - scorestrs.append(str(self.cscores[i])) - fields = [sym_tostring(self.lhs), str(self.f), str(self.e), " ".join(scorestrs)] + cdef unsigned i + fields = [sym_tostring(self.lhs), str(self.f), str(self.e), str(self.scores)] if self.word_alignments is not None: - alignstr = [] - for i from 0 <= i < len(self.word_alignments): - alignstr.append("%d-%d" % (self.word_alignments[i]/65536, self.word_alignments[i]%65536)) - #for s,t in self.word_alignments: - #alignstr.append("%d-%d" % (s,t)) - fields.append(" ".join(alignstr)) - - return " ||| ".join(fields) + fields.append(' '.join('%d-%d' % a for a in self.alignments())) + return ' ||| '.join(fields) - property scores: - def __get__(self): - s = [None]*self.n_scores - for i from 0 <= i < self.n_scores: - s[i] = self.cscores[i] - return s - - def __set__(self, s): - if self.cscores != NULL: - free(self.cscores) - self.cscores = malloc(len(s)*sizeof(float)) - self.n_scores = len(s) - for i from 0 <= i < self.n_scores: - self.cscores[i] = s[i] + def alignments(self): + for point in self.word_alignments: + yield point/65536, point%65536 diff --git a/python/src/sa/rulefactory.pxi b/python/src/sa/rulefactory.pxi index 1c8d25a4..34a002c5 100644 --- a/python/src/sa/rulefactory.pxi +++ b/python/src/sa/rulefactory.pxi @@ -8,6 +8,8 @@ from libc.stdlib cimport malloc, realloc, free from libc.string cimport memset, memcpy from libc.math cimport fmod, ceil, floor, log +from collections import defaultdict, Counter + cdef int PRECOMPUTE = 0 cdef int MERGE = 1 cdef int BAEZA_YATES = 2 @@ -73,8 +75,7 @@ cdef class PhraseLocation: self.arr_high = arr_high self.arr = arr self.num_subpatterns = num_subpatterns - - + cdef class Sampler: '''A Sampler implements a logic for choosing @@ -208,6 +209,7 @@ cdef class HieroCachingRuleFactory: cdef TrieTable rules cdef Sampler sampler + cdef Scorer scorer cdef int max_chunks cdef int max_target_chunks @@ -359,7 +361,8 @@ cdef class HieroCachingRuleFactory: self.findexes = IntList(initial_len=10) self.findexes1 = IntList(initial_len=10) - def configure(self, SuffixArray fsarray, DataArray edarray, Sampler sampler): + def configure(self, SuffixArray fsarray, DataArray edarray, + Sampler sampler, Scorer scorer): '''This gives the RuleFactory access to the Context object. Here we also use it to precompute the most expensive intersections in the corpus quickly.''' @@ -370,6 +373,7 @@ cdef class HieroCachingRuleFactory: self.eid2symid = self.set_idmap(self.eda) self.precompute() self.sampler = sampler + self.scorer = scorer cdef set_idmap(self, DataArray darray): cdef int word_id, new_word_id, N @@ -916,7 +920,7 @@ cdef class HieroCachingRuleFactory: candidate.append([next_id,curr[1]+jump]) return sorted(result); - def input(self, fwords, models): + def input(self, fwords): '''When this function is called on the RuleFactory, it looks up all of the rules that can be used to translate the input sentence''' @@ -1074,18 +1078,12 @@ cdef class HieroCachingRuleFactory: extract_stop = monitor_cpu() self.extract_time = self.extract_time + extract_stop - extract_start if len(extracts) > 0: - fphrases = {} - fals = {} - fcount = {} + fcount = Counter() + fphrases = defaultdict(lambda: defaultdict(Counter)) for f, e, count, als in extracts: - fcount.setdefault(f, 0.0) - fcount[f] = fcount[f] + count - fphrases.setdefault(f, {}) - fphrases[f].setdefault(e, {}) - fphrases[f][e].setdefault(als,0.0) - fphrases[f][e][als] = fphrases[f][e][als] + count + fcount[f] += count + fphrases[f][e][als] += count for f, elist in fphrases.iteritems(): - f_margin = fcount[f] for e, alslist in elist.iteritems(): alignment = None count = 0 @@ -1093,11 +1091,9 @@ cdef class HieroCachingRuleFactory: if currcount > count: alignment = als count = currcount - scores = [] - for model in models: - scores.append(model(f, e, count, fcount[f], num_samples)) - yield Rule(self.category, f, e, - scores=scores, word_alignments=alignment) + scores = self.scorer.score(f, e, count, + fcount[f], num_samples) + yield Rule(self.category, f, e, scores, alignment) if len(phrase) < self.max_length and i+spanlen < len(fwords) and pathlen+1 <= self.max_initial_size: for alt_id in range(len(fwords[i+spanlen])): @@ -1377,9 +1373,9 @@ cdef class HieroCachingRuleFactory: free(e_gap_order) return result - cdef create_alignments(self, int* sent_links, int num_links, findexes, eindexes): + cdef IntList create_alignments(self, int* sent_links, int num_links, findexes, eindexes): cdef unsigned i - ret = IntList() + cdef IntList ret = IntList() for i in range(len(findexes)): s = findexes[i] if (s<0): -- cgit v1.2.3 From 501c0419200234f4ff6b8c3d9f9602596a96c28e Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Tue, 16 Oct 2012 01:07:11 -0400 Subject: [python] Fix string problems + Documentation. - use bytes instead of char* - add some basic docstrings to functions/constructors --- python/src/_cdec.cpp | 5290 +++++++++++++++++++++++---------------------- python/src/_cdec.pyx | 20 +- python/src/grammar.pxi | 35 +- python/src/hypergraph.pxi | 21 + python/src/lattice.pxi | 19 +- python/src/mteval.pxi | 11 +- python/src/vectors.pxi | 10 +- 7 files changed, 2812 insertions(+), 2594 deletions(-) (limited to 'python/src/lattice.pxi') diff --git a/python/src/_cdec.cpp b/python/src/_cdec.cpp index 1bd600f0..c8d50a4f 100644 --- a/python/src/_cdec.cpp +++ b/python/src/_cdec.cpp @@ -1,4 +1,4 @@ -/* Generated by Cython 0.17.beta1 on Tue Aug 14 22:47:23 2012 */ +/* Generated by Cython 0.17.1 on Tue Oct 16 01:04:11 2012 */ #define PY_SSIZE_T_CLEAN #include "Python.h" @@ -11,7 +11,6 @@ #ifndef offsetof #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) #endif - #if !defined(WIN32) && !defined(MS_WINDOWS) #ifndef __stdcall #define __stdcall @@ -23,22 +22,18 @@ #define __fastcall #endif #endif - #ifndef DL_IMPORT #define DL_IMPORT(t) t #endif #ifndef DL_EXPORT #define DL_EXPORT(t) t #endif - #ifndef PY_LONG_LONG #define PY_LONG_LONG LONG_LONG #endif - #ifndef Py_HUGE_VAL #define Py_HUGE_VAL HUGE_VAL #endif - #ifdef PYPY_VERSION #define CYTHON_COMPILING_IN_PYPY 1 #define CYTHON_COMPILING_IN_CPYTHON 0 @@ -46,12 +41,12 @@ #define CYTHON_COMPILING_IN_PYPY 0 #define CYTHON_COMPILING_IN_CPYTHON 1 #endif - #if PY_VERSION_HEX < 0x02050000 typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN #define PY_FORMAT_SIZE_T "" + #define CYTHON_FORMAT_SSIZE_T "" #define PyInt_FromSsize_t(z) PyInt_FromLong(z) #define PyInt_AsSsize_t(o) __Pyx_PyInt_AsInt(o) #define PyNumber_Index(o) ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \ @@ -63,8 +58,8 @@ #define __PYX_BUILD_PY_SSIZE_T "i" #else #define __PYX_BUILD_PY_SSIZE_T "n" + #define CYTHON_FORMAT_SSIZE_T "z" #endif - #if PY_VERSION_HEX < 0x02060000 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) @@ -72,7 +67,6 @@ #define PyVarObject_HEAD_INIT(type, size) \ PyObject_HEAD_INIT(type) size, #define PyType_Modified(t) - typedef struct { void *buf; PyObject *obj; @@ -86,7 +80,6 @@ Py_ssize_t *suboffsets; void *internal; } Py_buffer; - #define PyBUF_SIMPLE 0 #define PyBUF_WRITABLE 0x0001 #define PyBUF_FORMAT 0x0004 @@ -98,11 +91,9 @@ #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE) #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE) - typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); typedef void (*releasebufferproc)(PyObject *, Py_buffer *); #endif - #if PY_MAJOR_VERSION < 3 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ @@ -112,21 +103,16 @@ #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \ PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) #endif - #if PY_MAJOR_VERSION < 3 && PY_MINOR_VERSION < 6 #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict") #endif - #if PY_MAJOR_VERSION >= 3 #define Py_TPFLAGS_CHECKTYPES 0 #define Py_TPFLAGS_HAVE_INDEX 0 #endif - #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3) #define Py_TPFLAGS_HAVE_NEWBUFFER 0 #endif - - #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) #define CYTHON_PEP393_ENABLED 1 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ? \ @@ -139,10 +125,8 @@ #define __Pyx_PyUnicode_READY(op) (0) #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_READ(k, d, i) ((k=k), (Py_UCS4)(((Py_UNICODE*)d)[i])) #endif - #if PY_MAJOR_VERSION >= 3 #define PyBaseString_Type PyUnicode_Type #define PyStringObject PyUnicodeObject @@ -150,7 +134,6 @@ #define PyString_Check PyUnicode_Check #define PyString_CheckExact PyUnicode_CheckExact #endif - #if PY_VERSION_HEX < 0x02060000 #define PyBytesObject PyStringObject #define PyBytes_Type PyString_Type @@ -169,7 +152,6 @@ #define PyBytes_Concat PyString_Concat #define PyBytes_ConcatAndDel PyString_ConcatAndDel #endif - #if PY_VERSION_HEX < 0x02060000 #define PySet_Check(obj) PyObject_TypeCheck(obj, &PySet_Type) #define PyFrozenSet_Check(obj) PyObject_TypeCheck(obj, &PyFrozenSet_Type) @@ -177,9 +159,7 @@ #ifndef PySet_CheckExact #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) #endif - #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type) - #if PY_MAJOR_VERSION >= 3 #define PyIntObject PyLongObject #define PyInt_Type PyLong_Type @@ -196,11 +176,9 @@ #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask #endif - #if PY_MAJOR_VERSION >= 3 #define PyBoolObject PyLongObject #endif - #if PY_VERSION_HEX < 0x03020000 typedef long Py_hash_t; #define __Pyx_PyInt_FromHash_t PyInt_FromLong @@ -209,7 +187,6 @@ #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t #endif - #if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300) #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b) #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value) @@ -228,11 +205,9 @@ (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \ (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1))) #endif - #if PY_MAJOR_VERSION >= 3 #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) #endif - #if PY_VERSION_HEX < 0x02050000 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n))) #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a)) @@ -242,7 +217,6 @@ #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a)) #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n)) #endif - #if PY_VERSION_HEX < 0x02050000 #define __Pyx_NAMESTR(n) ((char *)(n)) #define __Pyx_DOCSTR(n) ((char *)(n)) @@ -251,6 +225,7 @@ #define __Pyx_DOCSTR(n) (n) #endif + #if PY_MAJOR_VERSION >= 3 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) @@ -275,6 +250,10 @@ #define __PYX_HAVE_API___cdec #include "string.h" #include +#include "ios" +#include "new" +#include "stdexcept" +#include "typeinfo" #include #include #include @@ -400,11 +379,13 @@ static const char *__pyx_f[] = { "hypergraph.pxi", "lattice.pxi", "mteval.pxi", + "stringsource", "cdec.sa._sa.pxd", }; /*--- Type declarations ---*/ struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector; +struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__; struct __pyx_obj_5_cdec_NTRef; struct __pyx_obj_5_cdec_Scorer; struct __pyx_obj_4cdec_2sa_3_sa_IntList; @@ -427,7 +408,6 @@ struct __pyx_obj_5_cdec_Candidate; struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr; struct __pyx_obj_5_cdec_NT; struct __pyx_obj_4cdec_2sa_3_sa_FloatList; -struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__; struct __pyx_obj_5_cdec_HypergraphEdge; struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__; struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__; @@ -459,7 +439,7 @@ struct __pyx_opt_args_5_cdec_as_str; /* "_cdec.pyx":6 * cimport decoder * - * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< + * cdef bytes as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< * cdef bytes ret * if isinstance(data, unicode): */ @@ -468,7 +448,7 @@ struct __pyx_opt_args_5_cdec_as_str { char *error_msg; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":25 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":25 * cdef void read_handle(self, FILE* f) * * cdef class FeatureVector: # <<<<<<<<<<<<<< @@ -482,7 +462,20 @@ struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":20 +/* "_cdec.pyx":47 + * cdef DenseVector weights + * + * def __init__(self, config_str=None, **config): # <<<<<<<<<<<<<< + * """Decoder('formalism = scfg') -> initialize from configuration string + * Decoder(formalism='scfg') -> initialize from named parameters + */ +struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ { + PyObject_HEAD + PyObject *__pyx_v_config; +}; + + +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":21 * return '[%s]' % self.cat * * cdef class NTRef: # <<<<<<<<<<<<<< @@ -495,7 +488,7 @@ struct __pyx_obj_5_cdec_NTRef { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":117 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":121 * return CandidateSet(self) * * cdef class Scorer: # <<<<<<<<<<<<<< @@ -509,7 +502,7 @@ struct __pyx_obj_5_cdec_Scorer { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":12 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":12 * cdef void read_handle(self, FILE* f) * * cdef class IntList: # <<<<<<<<<<<<<< @@ -526,7 +519,7 @@ struct __pyx_obj_4cdec_2sa_3_sa_IntList { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":29 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":29 * cdef FloatList values * * cdef class Phrase: # <<<<<<<<<<<<<< @@ -543,7 +536,7 @@ struct __pyx_obj_4cdec_2sa_3_sa_Phrase { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":90 * return candidate * * def __iter__(self): # <<<<<<<<<<<<<< @@ -559,8 +552,8 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":178 - * super(MRule, self).__init__(lhs, rhs, e, scores, a) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":193 + * super(MRule, self).__init__(lhs, rhs, e, scores, None) * * cdef class Grammar: # <<<<<<<<<<<<<< * cdef shared_ptr[grammar.Grammar]* grammar @@ -572,9 +565,9 @@ struct __pyx_obj_5_cdec_Grammar { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 - * +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' @@ -595,12 +588,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":91 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":103 * del hypos * * def sample_trees(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" * cdef vector[string]* trees = new vector[string]() - * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) */ struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees { PyObject_HEAD @@ -613,7 +606,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":156 * * property edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -629,7 +622,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< @@ -642,7 +635,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":65 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":65 * return result * * cdef class CandidateSet: # <<<<<<<<<<<<<< @@ -657,7 +650,7 @@ struct __pyx_obj_5_cdec_CandidateSet { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":142 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":162 * * property nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -673,7 +666,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":47 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":49 * return TRule(lhs, f, e, scores, a) * * cdef class TRule: # <<<<<<<<<<<<<< @@ -686,7 +679,7 @@ struct __pyx_obj_5_cdec_TRule { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":35 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":35 * cdef public int chunklen(self, int k) * * cdef class Rule: # <<<<<<<<<<<<<< @@ -704,19 +697,19 @@ struct __pyx_obj_4cdec_2sa_3_sa_Rule { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":166 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":177 * _phrase(self.f), _phrase(self.e), scores) * * cdef class MRule(TRule): # <<<<<<<<<<<<<< - * def __init__(self, lhs, rhs, scores, a=None): - * cdef unsigned i = 1 + * def __init__(self, lhs, rhs, scores): + * """MRule(lhs, rhs, scores, a=None) -> Monolingual rule. */ struct __pyx_obj_5_cdec_MRule { struct __pyx_obj_5_cdec_TRule __pyx_base; }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":98 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":100 * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) * * cdef class SegmentEvaluator: # <<<<<<<<<<<<<< @@ -730,7 +723,7 @@ struct __pyx_obj_5_cdec_SegmentEvaluator { }; -/* "_cdec.pyx":57 +/* "_cdec.pyx":56 * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< @@ -739,7 +732,7 @@ struct __pyx_obj_5_cdec_SegmentEvaluator { */ struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr { PyObject_HEAD - struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *__pyx_outer_scope; + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *__pyx_outer_scope; PyObject *__pyx_v_kv; PyObject *__pyx_t_0; Py_ssize_t __pyx_t_1; @@ -747,12 +740,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":61 * yield self[i] * * def todot(self): # <<<<<<<<<<<<<< + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): - * yield 'digraph lattice {' */ struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot { PyObject_HEAD @@ -760,7 +753,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":12 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":12 * return stats * * cdef class Candidate: # <<<<<<<<<<<<<< @@ -774,7 +767,7 @@ struct __pyx_obj_5_cdec_Candidate { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":173 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< @@ -791,7 +784,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":8 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":8 * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) * * cdef class NT: # <<<<<<<<<<<<<< @@ -805,7 +798,7 @@ struct __pyx_obj_5_cdec_NT { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":3 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":3 * from libc.stdio cimport FILE * * cdef class FloatList: # <<<<<<<<<<<<<< @@ -822,20 +815,7 @@ struct __pyx_obj_4cdec_2sa_3_sa_FloatList { }; -/* "_cdec.pyx":46 - * cdef DenseVector weights - * - * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<< - * """ Configuration can be given as a string: - * Decoder('formalism = scfg') - */ -struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ { - PyObject_HEAD - PyObject *__pyx_v_config; -}; - - -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":170 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":191 * return vector * * cdef class HypergraphEdge: # <<<<<<<<<<<<<< @@ -851,7 +831,7 @@ struct __pyx_obj_5_cdec_HypergraphEdge { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":72 * self.vector.set_value(fid, value) * * def __iter__(self): # <<<<<<<<<<<<<< @@ -868,7 +848,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":226 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":247 * * property in_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -884,7 +864,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":131 * * property a: * def __get__(self): # <<<<<<<<<<<<<< @@ -901,7 +881,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":56 * return unicode(str(self), 'utf8') * * def __iter__(self): # <<<<<<<<<<<<<< @@ -917,7 +897,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ { }; -/* "_cdec.pyx":42 +/* "_cdec.pyx":43 * yield key, str(value) * * cdef class Decoder: # <<<<<<<<<<<<<< @@ -931,7 +911,7 @@ struct __pyx_obj_5_cdec_Decoder { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":237 * raise NotImplemented('comparison not implemented for HypergraphEdge') * * cdef class HypergraphNode: # <<<<<<<<<<<<<< @@ -946,7 +926,7 @@ struct __pyx_obj_5_cdec_HypergraphNode { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":45 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":48 * return sparse * * cdef class SparseVector: # <<<<<<<<<<<<<< @@ -959,7 +939,7 @@ struct __pyx_obj_5_cdec_SparseVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":232 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":253 * * property out_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -975,7 +955,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":32 * self.vector[0][fid] = value * * def __iter__(self): # <<<<<<<<<<<<<< @@ -991,7 +971,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":44 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":44 * return self.stats.size() * * def __iter__(self): # <<<<<<<<<<<<<< @@ -1008,7 +988,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":3 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":3 * from cython.operator cimport preincrement as pinc * * cdef class DenseVector: # <<<<<<<<<<<<<< @@ -1022,7 +1002,7 @@ struct __pyx_obj_5_cdec_DenseVector { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":199 * del self.grammar * * def __iter__(self): # <<<<<<<<<<<<<< @@ -1041,7 +1021,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":172 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":176 * out.fields[i] = ss[i] * * cdef class Metric: # <<<<<<<<<<<<<< @@ -1054,7 +1034,7 @@ struct __pyx_obj_5_cdec_Metric { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":26 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":26 * return fmap * * cdef class SufficientStats: # <<<<<<<<<<<<<< @@ -1068,12 +1048,12 @@ struct __pyx_obj_5_cdec_SufficientStats { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":36 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":44 * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') * * def kbest(self, size): # <<<<<<<<<<<<<< + * """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation */ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest { PyObject_HEAD @@ -1087,12 +1067,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":66 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":76 * del e_derivations * * def kbest_features(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation */ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features { PyObject_HEAD @@ -1107,7 +1087,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":211 * * property tail_nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -1123,8 +1103,8 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161 - * self.rule.get().lhs_ = -TDConvert(lhs.cat) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":172 + * self.rule.get().lhs_ = -TDConvert(( lhs).cat) * * def __str__(self): # <<<<<<<<<<<<<< * scores = ' '.join('%s=%s' % feat for feat in self.scores) @@ -1136,7 +1116,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":6 * * def _phrase(phrase): * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<< @@ -1153,12 +1133,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":57 * del derivations * * def kbest_trees(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation */ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees { PyObject_HEAD @@ -1176,7 +1156,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":4 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":4 * cimport kbest * * cdef class Hypergraph: # <<<<<<<<<<<<<< @@ -1191,7 +1171,7 @@ struct __pyx_obj_5_cdec_Hypergraph { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":3 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":3 * cimport lattice * * cdef class Lattice: # <<<<<<<<<<<<<< @@ -1204,12 +1184,12 @@ struct __pyx_obj_5_cdec_Lattice { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":81 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":92 * del derivations * * def sample(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() - * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) */ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample { PyObject_HEAD @@ -1222,7 +1202,7 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample { }; -/* "_cdec.pyx":31 +/* "_cdec.pyx":32 * SetSilent(yn) * * def _make_config(config): # <<<<<<<<<<<<<< @@ -1245,12 +1225,12 @@ struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config { }; -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":201 - * self.grammar.get().SetGrammarName(string(name)) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":217 + * self.grammar.get().SetGrammarName(name) * * cdef class TextGrammar(Grammar): # <<<<<<<<<<<<<< - * def __cinit__(self, rules): - * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) + * def __init__(self, rules): + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" */ struct __pyx_obj_5_cdec_TextGrammar { struct __pyx_obj_5_cdec_Grammar __pyx_base; @@ -1258,7 +1238,7 @@ struct __pyx_obj_5_cdec_TextGrammar { -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":4 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":4 * cimport kbest * * cdef class Hypergraph: # <<<<<<<<<<<<<< @@ -1272,7 +1252,7 @@ struct __pyx_vtabstruct_5_cdec_Hypergraph { static struct __pyx_vtabstruct_5_cdec_Hypergraph *__pyx_vtabptr_5_cdec_Hypergraph; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":170 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":191 * return vector * * cdef class HypergraphEdge: # <<<<<<<<<<<<<< @@ -1286,7 +1266,7 @@ struct __pyx_vtabstruct_5_cdec_HypergraphEdge { static struct __pyx_vtabstruct_5_cdec_HypergraphEdge *__pyx_vtabptr_5_cdec_HypergraphEdge; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":12 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":12 * cdef void read_handle(self, FILE* f) * * cdef class IntList: # <<<<<<<<<<<<<< @@ -1306,7 +1286,7 @@ struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList { static struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList *__pyx_vtabptr_4cdec_2sa_3_sa_IntList; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":3 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":3 * from libc.stdio cimport FILE * * cdef class FloatList: # <<<<<<<<<<<<<< @@ -1322,7 +1302,7 @@ struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList { static struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList *__pyx_vtabptr_4cdec_2sa_3_sa_FloatList; -/* "/Users/vchahun/Sandbox/cdec/python/src/cdec.sa._sa.pxd":29 +/* "/home/vchahune/tools/cdec/python/src/cdec.sa._sa.pxd":29 * cdef FloatList values * * cdef class Phrase: # <<<<<<<<<<<<<< @@ -1337,7 +1317,7 @@ struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase { static struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase *__pyx_vtabptr_4cdec_2sa_3_sa_Phrase; -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":216 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":237 * raise NotImplemented('comparison not implemented for HypergraphEdge') * * cdef class HypergraphNode: # <<<<<<<<<<<<<< @@ -1542,11 +1522,9 @@ static CYTHON_INLINE int __Pyx_IterFinish(void); /*proto*/ static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); /*proto*/ -static CYTHON_INLINE int __Pyx_NegateNonNeg(int b) { - return unlikely(b < 0) ? b : !b; -} -static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) { - return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b); +static CYTHON_INLINE int __Pyx_PyDict_Contains(PyObject* item, PyObject* dict, int eq) { + int result = PyDict_Contains(dict, item); + return unlikely(result < 0) ? result : (result == (eq == Py_EQ)); } #define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL) @@ -1661,18 +1639,6 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m, PyObject *tuple); static int __Pyx_CyFunction_init(void); -#include - -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ - -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals); /*proto*/ - -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals -#else -#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals -#endif - static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *); static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *); @@ -1705,9 +1671,6 @@ static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *); static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *); -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename); /*proto*/ - static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ #define __Pyx_Generator_USED @@ -1718,14 +1681,14 @@ typedef struct { PyObject_HEAD __pyx_generator_body_t body; PyObject *closure; - int is_running; - int resume_label; PyObject *exc_type; PyObject *exc_value; PyObject *exc_traceback; PyObject *gi_weakreflist; PyObject *classobj; PyObject *yieldfrom; + int resume_label; + char is_running; // using T_BOOL for property below requires char value } __pyx_GeneratorObject; static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body, PyObject *closure); @@ -1737,6 +1700,9 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue); #define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue) #endif +static void __Pyx_WriteUnraisable(const char *name, int clineno, + int lineno, const char *filename); /*proto*/ + static int __Pyx_check_binary_version(void); static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ @@ -1749,10 +1715,10 @@ static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ #endif #endif -static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ - static PyObject *__Pyx_ImportModule(const char *name); /*proto*/ +static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict); /*proto*/ + static void* __Pyx_GetVtable(PyObject *dict); /*proto*/ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (**f)(void), const char *sig); /*proto*/ @@ -1858,13 +1824,14 @@ static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_20_lines = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_21___iter__ = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_22___iter__ = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_23__make_config = 0; -static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_24___cinit__ = 0; +static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_24___init__ = 0; static PyTypeObject *__pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr = 0; -static char *__pyx_f_5_cdec_as_str(PyObject *, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args); /*proto*/ +static PyObject *__pyx_f_5_cdec_as_str(PyObject *, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args); /*proto*/ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_obj_4cdec_2sa_3_sa_Rule *); /*proto*/ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject *, PyObject *); /*proto*/ static float __pyx_f_5_cdec__compute_score(void *, SufficientStats *); /*proto*/ static void __pyx_f_5_cdec__compute_sufficient_stats(void *, std::string *, std::vector *, SufficientStats *); /*proto*/ +static std::string __pyx_convert_string_from_py_(PyObject *); /*proto*/ #define __Pyx_MODULE_NAME "_cdec" int __pyx_module_is_main__cdec = 0; @@ -1940,12 +1907,12 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_lhs); /* proto */ static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self); /* proto */ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self); /* proto */ -static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a); /* proto */ +static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores); /* proto */ static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self); /* proto */ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self, PyObject *__pyx_v_name); /* proto */ -static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules); /* proto */ +static int __pyx_pf_5_cdec_11TextGrammar___init__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules); /* proto */ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self); /* proto */ @@ -2024,8 +1991,8 @@ static PyObject *__pyx_pf_5_cdec_6Metric_4score(CYTHON_UNUSED struct __pyx_obj_5 static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_obj_5_cdec_Metric *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_hyp, CYTHON_UNUSED PyObject *__pyx_v_refs); /* proto */ static PyObject *__pyx_pf_5_cdec_2set_silent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_yn); /* proto */ static PyObject *__pyx_pf_5_cdec_4_make_config(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_config); /* proto */ -static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_self); /* proto */ -static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config); /* proto */ +static PyObject *__pyx_pf_5_cdec_7Decoder_8__init___genexpr(PyObject *__pyx_self); /* proto */ +static int __pyx_pf_5_cdec_7Decoder___init__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config); /* proto */ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5_cdec_Decoder *__pyx_v_self); /* proto */ static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self); /* proto */ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_weights); /* proto */ @@ -2047,30 +2014,30 @@ static char __pyx_k_16[] = "csplit_preserve_full_word"; static char __pyx_k_17[] = "cannot reweight hypergraph with %s"; static char __pyx_k_18[] = "comparison not implemented for HypergraphEdge"; static char __pyx_k_20[] = "comparison not implemented for HypergraphNode"; -static char __pyx_k_23[] = "cannot create lattice from %s"; -static char __pyx_k_24[] = "lattice index out of range"; -static char __pyx_k_28[] = "digraph lattice {"; - static char __pyx_k_29[] = "rankdir = LR;"; - static char __pyx_k_30[] = "node [shape=circle];"; - static char __pyx_k_31[] = "%d -> %d [label=\"%s\"];"; - static char __pyx_k_32[] = "\""; - static char __pyx_k_33[] = "\\\""; - static char __pyx_k_35[] = "%d [shape=doublecircle]"; -static char __pyx_k_36[] = "}"; -static char __pyx_k_39[] = "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi"; -static char __pyx_k_40[] = "\n"; -static char __pyx_k_42[] = "sufficient stats vector index out of range"; -static char __pyx_k_44[] = "candidate set index out of range"; -static char __pyx_k_46[] = "%s %s"; -static char __pyx_k_47[] = "%s = %s"; -static char __pyx_k_49[] = "formalism \"%s\" unknown"; -static char __pyx_k_50[] = "cannot initialize weights with %s"; -static char __pyx_k_51[] = "#"; -static char __pyx_k_54[] = "Cannot translate input type %s"; -static char __pyx_k_55[] = "cdec.sa._sa"; -static char __pyx_k_56[] = "*"; -static char __pyx_k_59[] = "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi"; -static char __pyx_k_65[] = "/Users/vchahun/Sandbox/cdec/python/src/_cdec.pyx"; +static char __pyx_k_22[] = "cannot create lattice from %s"; +static char __pyx_k_23[] = "lattice index out of range"; +static char __pyx_k_26[] = "digraph lattice {"; + static char __pyx_k_27[] = "rankdir = LR;"; + static char __pyx_k_28[] = "node [shape=circle];"; + static char __pyx_k_29[] = "%d -> %d [label=\"%s\"];"; + static char __pyx_k_30[] = "\""; + static char __pyx_k_31[] = "\\\""; + static char __pyx_k_33[] = "%d [shape=doublecircle]"; +static char __pyx_k_34[] = "}"; +static char __pyx_k_37[] = "/home/vchahune/tools/cdec/python/src/lattice.pxi"; +static char __pyx_k_38[] = "\n"; +static char __pyx_k_40[] = "sufficient stats vector index out of range"; +static char __pyx_k_42[] = "candidate set index out of range"; +static char __pyx_k_44[] = "%s %s"; +static char __pyx_k_45[] = "%s = %s"; +static char __pyx_k_47[] = "formalism \"%s\" unknown"; +static char __pyx_k_48[] = "cannot initialize weights with %s"; +static char __pyx_k_49[] = "#"; +static char __pyx_k_52[] = "Cannot translate input type %s"; +static char __pyx_k_53[] = "cdec.sa._sa"; +static char __pyx_k_54[] = "*"; +static char __pyx_k_57[] = "/home/vchahune/tools/cdec/python/src/grammar.pxi"; +static char __pyx_k_63[] = "/home/vchahune/tools/cdec/python/src/_cdec.pyx"; static char __pyx_k__a[] = "a"; static char __pyx_k__e[] = "e"; static char __pyx_k__f[] = "f"; @@ -2170,32 +2137,32 @@ static PyObject *__pyx_n_s_16; static PyObject *__pyx_kp_s_17; static PyObject *__pyx_kp_s_18; static PyObject *__pyx_kp_s_20; +static PyObject *__pyx_kp_s_22; static PyObject *__pyx_kp_s_23; -static PyObject *__pyx_kp_s_24; +static PyObject *__pyx_kp_s_26; +static PyObject *__pyx_kp_s_27; static PyObject *__pyx_kp_s_28; static PyObject *__pyx_kp_s_29; static PyObject *__pyx_kp_s_3; static PyObject *__pyx_kp_s_30; static PyObject *__pyx_kp_s_31; -static PyObject *__pyx_kp_s_32; static PyObject *__pyx_kp_s_33; -static PyObject *__pyx_kp_s_35; -static PyObject *__pyx_kp_s_36; -static PyObject *__pyx_kp_s_39; +static PyObject *__pyx_kp_s_34; +static PyObject *__pyx_kp_s_37; +static PyObject *__pyx_kp_s_38; static PyObject *__pyx_kp_s_4; static PyObject *__pyx_kp_s_40; static PyObject *__pyx_kp_s_42; static PyObject *__pyx_kp_s_44; -static PyObject *__pyx_kp_s_46; +static PyObject *__pyx_kp_s_45; static PyObject *__pyx_kp_s_47; +static PyObject *__pyx_kp_s_48; static PyObject *__pyx_kp_s_49; -static PyObject *__pyx_kp_s_50; -static PyObject *__pyx_kp_s_51; -static PyObject *__pyx_kp_s_54; -static PyObject *__pyx_n_s_55; -static PyObject *__pyx_n_s_56; -static PyObject *__pyx_kp_s_59; -static PyObject *__pyx_kp_s_65; +static PyObject *__pyx_kp_s_52; +static PyObject *__pyx_n_s_53; +static PyObject *__pyx_n_s_54; +static PyObject *__pyx_kp_s_57; +static PyObject *__pyx_kp_s_63; static PyObject *__pyx_kp_s_7; static PyObject *__pyx_kp_s_8; static PyObject *__pyx_kp_s_9; @@ -2297,47 +2264,44 @@ static PyObject *__pyx_k_tuple_6; static PyObject *__pyx_k_tuple_14; static PyObject *__pyx_k_tuple_19; 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_26; -static PyObject *__pyx_k_tuple_27; -static PyObject *__pyx_k_tuple_34; -static PyObject *__pyx_k_tuple_37; +static PyObject *__pyx_k_tuple_32; +static PyObject *__pyx_k_tuple_35; +static PyObject *__pyx_k_tuple_39; static PyObject *__pyx_k_tuple_41; static PyObject *__pyx_k_tuple_43; -static PyObject *__pyx_k_tuple_45; -static PyObject *__pyx_k_tuple_48; -static PyObject *__pyx_k_tuple_52; -static PyObject *__pyx_k_tuple_53; -static PyObject *__pyx_k_tuple_57; +static PyObject *__pyx_k_tuple_46; +static PyObject *__pyx_k_tuple_50; +static PyObject *__pyx_k_tuple_51; +static PyObject *__pyx_k_tuple_55; +static PyObject *__pyx_k_tuple_58; +static PyObject *__pyx_k_tuple_59; static PyObject *__pyx_k_tuple_60; static PyObject *__pyx_k_tuple_61; -static PyObject *__pyx_k_tuple_62; -static PyObject *__pyx_k_tuple_63; -static PyObject *__pyx_k_tuple_66; -static PyObject *__pyx_k_codeobj_38; -static PyObject *__pyx_k_codeobj_58; -static PyObject *__pyx_k_codeobj_64; -static PyObject *__pyx_k_codeobj_67; +static PyObject *__pyx_k_tuple_64; +static PyObject *__pyx_k_codeobj_36; +static PyObject *__pyx_k_codeobj_56; +static PyObject *__pyx_k_codeobj_62; +static PyObject *__pyx_k_codeobj_65; /* "_cdec.pyx":6 * cimport decoder * - * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< + * cdef bytes as_str(data, char* error_msg='Cannot convert type %s to str'): # <<<<<<<<<<<<<< * cdef bytes ret * if isinstance(data, unicode): */ -static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args) { +static PyObject *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args_5_cdec_as_str *__pyx_optional_args) { char *__pyx_v_error_msg = ((char *)__pyx_k_1); PyObject *__pyx_v_ret = 0; - char *__pyx_r; + PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; PyObject *__pyx_t_4 = NULL; - char *__pyx_t_5; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; @@ -2349,7 +2313,7 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args } /* "_cdec.pyx":8 - * cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): + * cdef bytes as_str(data, char* error_msg='Cannot convert type %s to str'): * cdef bytes ret * if isinstance(data, unicode): # <<<<<<<<<<<<<< * ret = data.encode('utf8') @@ -2448,26 +2412,32 @@ static char *__pyx_f_5_cdec_as_str(PyObject *__pyx_v_data, struct __pyx_opt_args * * include "vectors.pxi" */ - __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_ret)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_r = __pyx_t_5; + __Pyx_XDECREF(((PyObject *)__pyx_r)); + __Pyx_INCREF(((PyObject *)__pyx_v_ret)); + __pyx_r = __pyx_v_ret; goto __pyx_L0; - __pyx_r = 0; + __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); - __Pyx_WriteUnraisable("_cdec.as_str", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.as_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_ret); + __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_11DenseVector___init__[] = "DenseVector() -> Dense weight/feature vector."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_11DenseVector___init__; +#endif static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -2480,30 +2450,35 @@ static int __pyx_pw_5_cdec_11DenseVector_1__init__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":7 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":7 * cdef bint owned # if True, do not manage memory * * def __init__(self): # <<<<<<<<<<<<<< + * """DenseVector() -> Dense weight/feature vector.""" * self.vector = new vector[weight_t]() - * self.owned = False */ static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) { int __pyx_r; __Pyx_RefNannyDeclarations + std::vector *__pyx_t_1; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":8 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":9 * def __init__(self): + * """DenseVector() -> Dense weight/feature vector.""" * self.vector = new vector[weight_t]() # <<<<<<<<<<<<<< * self.owned = False * */ - __pyx_v_self->vector = new std::vector(); + try {__pyx_t_1 = new std::vector();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[1]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->vector = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":9 - * def __init__(self): + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":10 + * """DenseVector() -> Dense weight/feature vector.""" * self.vector = new vector[weight_t]() * self.owned = False # <<<<<<<<<<<<<< * @@ -2512,6 +2487,11 @@ static int __pyx_pf_5_cdec_11DenseVector___init__(struct __pyx_obj_5_cdec_DenseV __pyx_v_self->owned = 0; __pyx_r = 0; + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("_cdec.DenseVector.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_r = -1; + __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -2525,7 +2505,7 @@ static void __pyx_pw_5_cdec_11DenseVector_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":11 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":12 * self.owned = False * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -2538,7 +2518,7 @@ static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_D int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":12 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":13 * * def __dealloc__(self): * if not self.owned: # <<<<<<<<<<<<<< @@ -2548,7 +2528,7 @@ static void __pyx_pf_5_cdec_11DenseVector_2__dealloc__(struct __pyx_obj_5_cdec_D __pyx_t_1 = (!__pyx_v_self->owned); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":13 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":14 * def __dealloc__(self): * if not self.owned: * del self.vector # <<<<<<<<<<<<<< @@ -2574,7 +2554,7 @@ static Py_ssize_t __pyx_pw_5_cdec_11DenseVector_5__len__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":15 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":16 * del self.vector * * def __len__(self): # <<<<<<<<<<<<<< @@ -2587,7 +2567,7 @@ static Py_ssize_t __pyx_pf_5_cdec_11DenseVector_4__len__(struct __pyx_obj_5_cdec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":16 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":17 * * def __len__(self): * return self.vector.size() # <<<<<<<<<<<<<< @@ -2611,7 +2591,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_se __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); assert(__pyx_arg_fname); { - __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2624,7 +2604,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_7__getitem__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":18 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":19 * return self.vector.size() * * def __getitem__(self, char* fname): # <<<<<<<<<<<<<< @@ -2644,7 +2624,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":19 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":20 * * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< @@ -2653,7 +2633,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c */ __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":20 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":21 * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) * if 0 <= fid < self.vector.size(): # <<<<<<<<<<<<<< @@ -2666,7 +2646,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c } if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":21 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":22 * cdef int fid = FDConvert(fname) * if 0 <= fid < self.vector.size(): * return self.vector[0][fid] # <<<<<<<<<<<<<< @@ -2674,7 +2654,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyFloat_FromDouble(((__pyx_v_self->vector[0])[__pyx_v_fid])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(((__pyx_v_self->vector[0])[__pyx_v_fid])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -2683,26 +2663,26 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_6__getitem__(struct __pyx_obj_5_c } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":22 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":23 * if 0 <= fid < self.vector.size(): * return self.vector[0][fid] * raise KeyError(fname) # <<<<<<<<<<<<<< * * def __setitem__(self, char* fname, float value): */ - __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -2726,10 +2706,10 @@ static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, Py __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); assert(__pyx_arg_fname); { - __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } assert(__pyx_arg_value); { - __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -2742,11 +2722,11 @@ static int __pyx_pw_5_cdec_11DenseVector_9__setitem__(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":24 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":25 * raise KeyError(fname) * * def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<< - * cdef int fid = FDConvert(fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) */ @@ -2762,43 +2742,43 @@ static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_De int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":25 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":26 * * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< + * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< * if fid < 0: raise KeyError(fname) * if self.vector.size() <= fid: */ - __pyx_v_fid = FD::Convert(((char *)__pyx_v_fname)); + __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":26 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":27 * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * if self.vector.size() <= fid: * self.vector.resize(fid + 1) */ __pyx_t_1 = (__pyx_v_fid < 0); if (__pyx_t_1) { - __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":27 - * cdef int fid = FDConvert(fname) + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":28 + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) * if self.vector.size() <= fid: # <<<<<<<<<<<<<< * self.vector.resize(fid + 1) @@ -2807,7 +2787,7 @@ static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_De __pyx_t_1 = (__pyx_v_self->vector->size() <= __pyx_v_fid); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":28 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":29 * if fid < 0: raise KeyError(fname) * if self.vector.size() <= fid: * self.vector.resize(fid + 1) # <<<<<<<<<<<<<< @@ -2819,7 +2799,7 @@ static int __pyx_pf_5_cdec_11DenseVector_8__setitem__(struct __pyx_obj_5_cdec_De } __pyx_L4:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":29 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":30 * if self.vector.size() <= fid: * self.vector.resize(fid + 1) * self.vector[0][fid] = value # <<<<<<<<<<<<<< @@ -2852,7 +2832,7 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_11__iter__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":31 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":32 * self.vector[0][fid] = value * * def __iter__(self): # <<<<<<<<<<<<<< @@ -2878,7 +2858,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_10__iter__(struct __pyx_obj_5_cde __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_11DenseVector_12generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_11DenseVector_12generator, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -2915,9 +2895,9 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":33 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":34 * def __iter__(self): * cdef unsigned fid * for fid in range(1, self.vector.size()): # <<<<<<<<<<<<<< @@ -2928,26 +2908,26 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject for (__pyx_t_2 = 1; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_fid = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":34 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":35 * cdef unsigned fid * for fid in range(1, self.vector.size()): * yield str(FDConvert(fid).c_str()), self.vector[0][fid] # <<<<<<<<<<<<<< * * def dot(self, SparseVector other): */ - __pyx_t_3 = PyBytes_FromString(FD::Convert(__pyx_cur_scope->__pyx_v_fid).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyBytes_FromString(FD::Convert(__pyx_cur_scope->__pyx_v_fid).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->vector[0])[__pyx_cur_scope->__pyx_v_fid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyFloat_FromDouble(((__pyx_cur_scope->__pyx_v_self->vector[0])[__pyx_cur_scope->__pyx_v_fid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); @@ -2967,7 +2947,7 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -2986,11 +2966,12 @@ static PyObject *__pyx_gb_5_cdec_11DenseVector_12generator(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static char __pyx_doc_5_cdec_11DenseVector_13dot[] = "vector.dot(SparseVector other) -> Dot product of the two vectors."; static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dot (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_11DenseVector_13dot(((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)); goto __pyx_L0; __pyx_L1_error:; @@ -3000,12 +2981,12 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_14dot(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":36 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":37 * yield str(FDConvert(fid).c_str()), self.vector[0][fid] * * def dot(self, SparseVector other): # <<<<<<<<<<<<<< + * """vector.dot(SparseVector other) -> Dot product of the two vectors.""" * return other.dot(self) - * */ static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self, struct __pyx_obj_5_cdec_SparseVector *__pyx_v_other) { @@ -3019,22 +3000,22 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_Den int __pyx_clineno = 0; __Pyx_RefNannySetupContext("dot", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":37 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":39 * def dot(self, SparseVector other): + * """vector.dot(SparseVector other) -> Dot product of the two vectors.""" * return other.dot(self) # <<<<<<<<<<<<<< * * def tosparse(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_other), __pyx_n_s__dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_other), __pyx_n_s__dot); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -3058,6 +3039,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_13dot(struct __pyx_obj_5_cdec_Den /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_11DenseVector_15tosparse[] = "vector.tosparse() -> Equivalent SparseVector."; static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3067,12 +3049,12 @@ static PyObject *__pyx_pw_5_cdec_11DenseVector_16tosparse(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":39 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":41 * return other.dot(self) * * def tosparse(self): # <<<<<<<<<<<<<< + * """vector.tosparse() -> Equivalent SparseVector.""" * cdef SparseVector sparse = SparseVector.__new__(SparseVector) - * sparse.vector = new FastSparseVector[weight_t]() */ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cdec_DenseVector *__pyx_v_self) { @@ -3085,21 +3067,21 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("tosparse", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":40 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":43 * def tosparse(self): + * """vector.tosparse() -> Equivalent SparseVector.""" * cdef SparseVector sparse = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * sparse.vector = new FastSparseVector[weight_t]() * InitSparseVector(self.vector[0], sparse.vector) */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_sparse = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":41 - * def tosparse(self): + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":44 + * """vector.tosparse() -> Equivalent SparseVector.""" * cdef SparseVector sparse = SparseVector.__new__(SparseVector) * sparse.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<< * InitSparseVector(self.vector[0], sparse.vector) @@ -3107,7 +3089,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde */ __pyx_v_sparse->vector = new FastSparseVector(); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":45 * cdef SparseVector sparse = SparseVector.__new__(SparseVector) * sparse.vector = new FastSparseVector[weight_t]() * InitSparseVector(self.vector[0], sparse.vector) # <<<<<<<<<<<<<< @@ -3116,7 +3098,7 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde */ Weights::InitSparseVector((__pyx_v_self->vector[0]), __pyx_v_sparse->vector); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":43 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":46 * sparse.vector = new FastSparseVector[weight_t]() * InitSparseVector(self.vector[0], sparse.vector) * return sparse # <<<<<<<<<<<<<< @@ -3143,6 +3125,10 @@ static PyObject *__pyx_pf_5_cdec_11DenseVector_15tosparse(struct __pyx_obj_5_cde /* Python wrapper */ static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_12SparseVector___init__[] = "SparseVector() -> Sparse feature/weight vector."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_12SparseVector___init__; +#endif static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { int __pyx_r; __Pyx_RefNannyDeclarations @@ -3155,12 +3141,12 @@ static int __pyx_pw_5_cdec_12SparseVector_1__init__(PyObject *__pyx_v_self, PyOb return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":51 * cdef FastSparseVector[weight_t]* vector * * def __init__(self): # <<<<<<<<<<<<<< + * """SparseVector() -> Sparse feature/weight vector.""" * self.vector = new FastSparseVector[weight_t]() - * */ static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) { @@ -3168,9 +3154,9 @@ static int __pyx_pf_5_cdec_12SparseVector___init__(struct __pyx_obj_5_cdec_Spars __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":49 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":53 * def __init__(self): + * """SparseVector() -> Sparse feature/weight vector.""" * self.vector = new FastSparseVector[weight_t]() # <<<<<<<<<<<<<< * * def __dealloc__(self): @@ -3191,7 +3177,7 @@ static void __pyx_pw_5_cdec_12SparseVector_3__dealloc__(PyObject *__pyx_v_self) __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":51 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":55 * self.vector = new FastSparseVector[weight_t]() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -3203,7 +3189,7 @@ static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":52 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":56 * * def __dealloc__(self): * del self.vector # <<<<<<<<<<<<<< @@ -3217,6 +3203,7 @@ static void __pyx_pf_5_cdec_12SparseVector_2__dealloc__(CYTHON_UNUSED struct __p /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_12SparseVector_4copy[] = "vector.copy() -> SparseVector copy."; static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3226,12 +3213,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_5copy(PyObject *__pyx_v_self, CY return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":54 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":58 * del self.vector * * def copy(self): # <<<<<<<<<<<<<< + * """vector.copy() -> SparseVector copy.""" * return self * 1 - * */ static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self) { @@ -3243,15 +3230,15 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_4copy(struct __pyx_obj_5_cdec_Sp int __pyx_clineno = 0; __Pyx_RefNannySetupContext("copy", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":55 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":60 * def copy(self): + * """vector.copy() -> SparseVector copy.""" * return self * 1 # <<<<<<<<<<<<<< * * def __getitem__(self, char* fname): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_self), __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Multiply(((PyObject *)__pyx_v_self), __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3277,7 +3264,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_s __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0); assert(__pyx_arg_fname); { - __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3290,7 +3277,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_7__getitem__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":62 * return self * 1 * * def __getitem__(self, char* fname): # <<<<<<<<<<<<<< @@ -3310,7 +3297,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":63 * * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< @@ -3319,7 +3306,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_ */ __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":64 * def __getitem__(self, char* fname): * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< @@ -3328,24 +3315,24 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_ */ __pyx_t_1 = (__pyx_v_fid < 0); if (__pyx_t_1) { - __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":65 * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) * return self.vector.value(fid) # <<<<<<<<<<<<<< @@ -3353,7 +3340,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_6__getitem__(struct __pyx_obj_5_ * def __setitem__(self, char* fname, float value): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->vector->value(__pyx_v_fid)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyFloat_FromDouble(__pyx_v_self->vector->value(__pyx_v_fid)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_r = __pyx_t_2; __pyx_t_2 = 0; @@ -3381,10 +3368,10 @@ static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, P __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__setitem__ (wrapper)", 0); assert(__pyx_arg_fname); { - __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } assert(__pyx_arg_value); { - __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_value = __pyx_PyFloat_AsFloat(__pyx_arg_value); if (unlikely((__pyx_v_value == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3397,11 +3384,11 @@ static int __pyx_pw_5_cdec_12SparseVector_9__setitem__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":62 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":67 * return self.vector.value(fid) * * def __setitem__(self, char* fname, float value): # <<<<<<<<<<<<<< - * cdef int fid = FDConvert(fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) */ @@ -3417,43 +3404,43 @@ static int __pyx_pf_5_cdec_12SparseVector_8__setitem__(struct __pyx_obj_5_cdec_S int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":63 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":68 * * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< + * cdef int fid = FDConvert(fname) # <<<<<<<<<<<<<< * if fid < 0: raise KeyError(fname) * self.vector.set_value(fid, value) */ - __pyx_v_fid = FD::Convert(((char *)__pyx_v_fname)); + __pyx_v_fid = FD::Convert(__pyx_v_fname); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":64 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":69 * def __setitem__(self, char* fname, float value): - * cdef int fid = FDConvert(fname) + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * self.vector.set_value(fid, value) * */ __pyx_t_1 = (__pyx_v_fid < 0); if (__pyx_t_1) { - __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_FromString(__pyx_v_fname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":65 - * cdef int fid = FDConvert(fname) + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":70 + * cdef int fid = FDConvert(fname) * if fid < 0: raise KeyError(fname) * self.vector.set_value(fid, value) # <<<<<<<<<<<<<< * @@ -3485,7 +3472,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_11__iter__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":67 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":72 * self.vector.set_value(fid, value) * * def __iter__(self): # <<<<<<<<<<<<<< @@ -3511,7 +3498,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_10__iter__(struct __pyx_obj_5_cd __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12SparseVector_12generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_12SparseVector_12generator1, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -3548,9 +3535,9 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":68 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":73 * * def __iter__(self): * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False) # <<<<<<<<<<<<<< @@ -3559,7 +3546,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje */ __pyx_cur_scope->__pyx_v_it = new FastSparseVector::const_iterator((__pyx_cur_scope->__pyx_v_self->vector[0]), 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":70 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":75 * cdef FastSparseVector[weight_t].const_iterator* it = new FastSparseVector[weight_t].const_iterator(self.vector[0], False) * cdef unsigned i * try: # <<<<<<<<<<<<<< @@ -3568,7 +3555,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":76 * cdef unsigned i * try: * for i in range(self.vector.size()): # <<<<<<<<<<<<<< @@ -3579,26 +3566,26 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":77 * try: * for i in range(self.vector.size()): * yield (str(FDConvert(it[0].ptr().first).c_str()), it[0].ptr().second) # <<<<<<<<<<<<<< * pinc(it[0]) # ++it * finally: */ - __pyx_t_3 = PyBytes_FromString(FD::Convert((__pyx_cur_scope->__pyx_v_it[0]).operator->()->first).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_3 = PyBytes_FromString(FD::Convert((__pyx_cur_scope->__pyx_v_it[0]).operator->()->first).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyFloat_FromDouble((__pyx_cur_scope->__pyx_v_it[0]).operator->()->second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = PyFloat_FromDouble((__pyx_cur_scope->__pyx_v_it[0]).operator->()->second); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); @@ -3618,9 +3605,9 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje __pyx_L9_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":73 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":78 * for i in range(self.vector.size()): * yield (str(FDConvert(it[0].ptr().first).c_str()), it[0].ptr().second) * pinc(it[0]) # ++it # <<<<<<<<<<<<<< @@ -3631,7 +3618,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje } } - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":75 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":80 * pinc(it[0]) # ++it * finally: * del it # <<<<<<<<<<<<<< @@ -3683,6 +3670,7 @@ static PyObject *__pyx_gb_5_cdec_12SparseVector_12generator1(__pyx_GeneratorObje /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/ +static char __pyx_doc_5_cdec_12SparseVector_13dot[] = "vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors."; static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, PyObject *__pyx_v_other) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -3692,12 +3680,12 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_14dot(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":77 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":82 * del it * * def dot(self, other): # <<<<<<<<<<<<<< + * """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" * if isinstance(other, DenseVector): - * return self.vector.dot(( other).vector[0]) */ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_SparseVector *__pyx_v_self, PyObject *__pyx_v_other) { @@ -3711,9 +3699,9 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp int __pyx_clineno = 0; __Pyx_RefNannySetupContext("dot", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":78 - * + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":84 * def dot(self, other): + * """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" * if isinstance(other, DenseVector): # <<<<<<<<<<<<<< * return self.vector.dot(( other).vector[0]) * elif isinstance(other, SparseVector): @@ -3724,15 +3712,15 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":79 - * def dot(self, other): + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":85 + * """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" * if isinstance(other, DenseVector): * return self.vector.dot(( other).vector[0]) # <<<<<<<<<<<<<< * elif isinstance(other, SparseVector): * return self.vector.dot(( other).vector[0]) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_DenseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3740,7 +3728,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":80 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":86 * if isinstance(other, DenseVector): * return self.vector.dot(( other).vector[0]) * elif isinstance(other, SparseVector): # <<<<<<<<<<<<<< @@ -3753,7 +3741,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":81 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":87 * return self.vector.dot(( other).vector[0]) * elif isinstance(other, SparseVector): * return self.vector.dot(( other).vector[0]) # <<<<<<<<<<<<<< @@ -3761,7 +3749,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->vector->dot((((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3770,26 +3758,26 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_13dot(struct __pyx_obj_5_cdec_Sp } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":82 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":88 * elif isinstance(other, SparseVector): * return self.vector.dot(( other).vector[0]) * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other)) # <<<<<<<<<<<<<< * * def __richcmp__(SparseVector x, SparseVector y, int op): */ - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_other))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -3810,8 +3798,8 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_ PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_12SparseVector_15__richcmp__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y), ((int)__pyx_v_op)); goto __pyx_L0; __pyx_L1_error:; @@ -3821,7 +3809,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_16__richcmp__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":84 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":90 * raise TypeError('cannot take the dot product of %s and SparseVector' % type(other)) * * def __richcmp__(SparseVector x, SparseVector y, int op): # <<<<<<<<<<<<<< @@ -3839,7 +3827,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":93 * if op == 2: # == * return x.vector[0] == y.vector[0] * elif op == 3: # != # <<<<<<<<<<<<<< @@ -3848,7 +3836,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":85 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":91 * * def __richcmp__(SparseVector x, SparseVector y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -3857,7 +3845,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":86 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":92 * def __richcmp__(SparseVector x, SparseVector y, int op): * if op == 2: # == * return x.vector[0] == y.vector[0] # <<<<<<<<<<<<<< @@ -3865,14 +3853,14 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_x->vector[0]) == (__pyx_v_y->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_x->vector[0]) == (__pyx_v_y->vector[0]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; break; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":93 * if op == 2: # == * return x.vector[0] == y.vector[0] * elif op == 3: # != # <<<<<<<<<<<<<< @@ -3881,7 +3869,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":88 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":94 * return x.vector[0] == y.vector[0] * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< @@ -3889,11 +3877,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -3901,18 +3888,18 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_15__richcmp__(struct __pyx_obj_5 break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":95 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for SparseVector') # <<<<<<<<<<<<<< * * def __len__(self): */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -3937,7 +3924,7 @@ static Py_ssize_t __pyx_pw_5_cdec_12SparseVector_18__len__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":91 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":97 * raise NotImplemented('comparison not implemented for SparseVector') * * def __len__(self): # <<<<<<<<<<<<<< @@ -3950,7 +3937,7 @@ static Py_ssize_t __pyx_pf_5_cdec_12SparseVector_17__len__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":92 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":98 * * def __len__(self): * return self.vector.size() # <<<<<<<<<<<<<< @@ -3974,7 +3961,7 @@ static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__contains__ (wrapper)", 0); assert(__pyx_arg_fname); { - __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_fname = PyBytes_AsString(__pyx_arg_fname); if (unlikely((!__pyx_v_fname) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -3987,7 +3974,7 @@ static int __pyx_pw_5_cdec_12SparseVector_20__contains__(PyObject *__pyx_v_self, return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":94 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":100 * return self.vector.size() * * def __contains__(self, char* fname): # <<<<<<<<<<<<<< @@ -4000,7 +3987,7 @@ static int __pyx_pf_5_cdec_12SparseVector_19__contains__(struct __pyx_obj_5_cdec __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__contains__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":95 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":101 * * def __contains__(self, char* fname): * return self.vector.nonzero(FDConvert(fname)) # <<<<<<<<<<<<<< @@ -4027,7 +4014,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_22__neg__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":97 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":103 * return self.vector.nonzero(FDConvert(fname)) * * def __neg__(self): # <<<<<<<<<<<<<< @@ -4045,20 +4032,20 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__neg__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":98 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":104 * * def __neg__(self): * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](self.vector[0]) * result.vector[0] *= -1.0 */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":99 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":105 * def __neg__(self): * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](self.vector[0]) # <<<<<<<<<<<<<< @@ -4067,7 +4054,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cde */ __pyx_v_result->vector = new FastSparseVector((__pyx_v_self->vector[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":100 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":106 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](self.vector[0]) * result.vector[0] *= -1.0 # <<<<<<<<<<<<<< @@ -4076,7 +4063,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_21__neg__(struct __pyx_obj_5_cde */ (__pyx_v_result->vector[0]) *= -1.0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":101 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":107 * result.vector = new FastSparseVector[weight_t](self.vector[0]) * result.vector[0] *= -1.0 * return result # <<<<<<<<<<<<<< @@ -4107,7 +4094,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_sel PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iadd__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_12SparseVector_23__iadd__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)); goto __pyx_L0; __pyx_L1_error:; @@ -4117,7 +4104,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_24__iadd__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":103 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":109 * return result * * def __iadd__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<< @@ -4130,7 +4117,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iadd__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":104 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":110 * * def __iadd__(SparseVector self, SparseVector other): * self.vector[0] += other.vector[0] # <<<<<<<<<<<<<< @@ -4139,7 +4126,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_23__iadd__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) += (__pyx_v_other->vector[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":105 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":111 * def __iadd__(SparseVector self, SparseVector other): * self.vector[0] += other.vector[0] * return self # <<<<<<<<<<<<<< @@ -4164,7 +4151,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_sel PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__isub__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5_cdec_SparseVector, 1, "other", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_12SparseVector_25__isub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_self), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_other)); goto __pyx_L0; __pyx_L1_error:; @@ -4174,7 +4161,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_26__isub__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":107 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":113 * return self * * def __isub__(SparseVector self, SparseVector other): # <<<<<<<<<<<<<< @@ -4187,7 +4174,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__isub__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":114 * * def __isub__(SparseVector self, SparseVector other): * self.vector[0] -= other.vector[0] # <<<<<<<<<<<<<< @@ -4196,7 +4183,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_25__isub__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) -= (__pyx_v_other->vector[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":109 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":115 * def __isub__(SparseVector self, SparseVector other): * self.vector[0] -= other.vector[0] * return self # <<<<<<<<<<<<<< @@ -4223,7 +4210,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_sel __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__imul__ (wrapper)", 0); assert(__pyx_arg_scalar); { - __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -4236,7 +4223,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_28__imul__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":111 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":117 * return self * * def __imul__(SparseVector self, float scalar): # <<<<<<<<<<<<<< @@ -4249,7 +4236,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__imul__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":112 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":118 * * def __imul__(SparseVector self, float scalar): * self.vector[0] *= scalar # <<<<<<<<<<<<<< @@ -4258,7 +4245,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_27__imul__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) *= __pyx_v_scalar; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":113 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":119 * def __imul__(SparseVector self, float scalar): * self.vector[0] *= scalar * return self # <<<<<<<<<<<<<< @@ -4286,7 +4273,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_sel __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__idiv__ (wrapper)", 0); assert(__pyx_arg_scalar); { - __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_scalar = __pyx_PyFloat_AsFloat(__pyx_arg_scalar); if (unlikely((__pyx_v_scalar == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -4300,7 +4287,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_30__idiv__(PyObject *__pyx_v_sel } #endif /*!(#if PY_MAJOR_VERSION < 3)*/ -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":115 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":121 * return self * * def __idiv__(SparseVector self, float scalar): # <<<<<<<<<<<<<< @@ -4314,7 +4301,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__idiv__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":116 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":122 * * def __idiv__(SparseVector self, float scalar): * self.vector[0] /= scalar # <<<<<<<<<<<<<< @@ -4323,7 +4310,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_29__idiv__(struct __pyx_obj_5_cd */ (__pyx_v_self->vector[0]) /= __pyx_v_scalar; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":117 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":123 * def __idiv__(SparseVector self, float scalar): * self.vector[0] /= scalar * return self # <<<<<<<<<<<<<< @@ -4349,8 +4336,8 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, P PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__add__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_12SparseVector_31__add__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y)); goto __pyx_L0; __pyx_L1_error:; @@ -4360,7 +4347,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_32__add__(PyObject *__pyx_v_x, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":119 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":125 * return self * * def __add__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<< @@ -4378,20 +4365,20 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__add__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":120 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":126 * * def __add__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) * return result */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":121 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":127 * def __add__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) # <<<<<<<<<<<<<< @@ -4400,7 +4387,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_31__add__(struct __pyx_obj_5_cde */ __pyx_v_result->vector = new FastSparseVector(((__pyx_v_x->vector[0]) + (__pyx_v_y->vector[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":122 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":128 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] + y.vector[0]) * return result # <<<<<<<<<<<<<< @@ -4431,8 +4418,8 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, P PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__sub__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_SparseVector, 1, "x", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_SparseVector, 1, "y", 0))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_12SparseVector_33__sub__(((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_x), ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_v_y)); goto __pyx_L0; __pyx_L1_error:; @@ -4442,7 +4429,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_34__sub__(PyObject *__pyx_v_x, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":124 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":130 * return result * * def __sub__(SparseVector x, SparseVector y): # <<<<<<<<<<<<<< @@ -4460,20 +4447,20 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__sub__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":125 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":131 * * def __sub__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) * return result */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":126 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":132 * def __sub__(SparseVector x, SparseVector y): * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) # <<<<<<<<<<<<<< @@ -4482,7 +4469,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_33__sub__(struct __pyx_obj_5_cde */ __pyx_v_result->vector = new FastSparseVector(((__pyx_v_x->vector[0]) - (__pyx_v_y->vector[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":127 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":133 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](x.vector[0] - y.vector[0]) * return result # <<<<<<<<<<<<<< @@ -4518,7 +4505,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_36__mul__(PyObject *__pyx_v_x, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":129 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":135 * return result * * def __mul__(x, y): # <<<<<<<<<<<<<< @@ -4540,7 +4527,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__mul__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":132 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":138 * cdef SparseVector vector * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<< @@ -4552,10 +4539,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_x; __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; __pyx_v_scalar = __pyx_t_3; @@ -4563,37 +4550,37 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":133 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":139 * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x # <<<<<<<<<<<<<< * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) */ - if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_y; __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; __pyx_v_scalar = __pyx_t_3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":134 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":140 * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) * return result */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":135 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":141 * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) # <<<<<<<<<<<<<< @@ -4602,7 +4589,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_35__mul__(PyObject *__pyx_v_x, P */ __pyx_v_result->vector = new FastSparseVector(((__pyx_v_vector->vector[0]) * __pyx_v_scalar)); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":136 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":142 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] * scalar) * return result # <<<<<<<<<<<<<< @@ -4641,7 +4628,7 @@ static PyObject *__pyx_pw_5_cdec_12SparseVector_38__div__(PyObject *__pyx_v_x, P } #endif /*!(#if PY_MAJOR_VERSION < 3)*/ -/* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":138 +/* "/home/vchahune/tools/cdec/python/src/vectors.pxi":144 * return result * * def __div__(x, y): # <<<<<<<<<<<<<< @@ -4664,7 +4651,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__div__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":141 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":147 * cdef SparseVector vector * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y # <<<<<<<<<<<<<< @@ -4676,10 +4663,10 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_x, __pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_x) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_x, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_x; __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_y); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; __pyx_v_scalar = __pyx_t_3; @@ -4687,37 +4674,37 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":142 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":148 * cdef float scalar * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x # <<<<<<<<<<<<<< * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) */ - if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_y) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_y, __pyx_ptype_5_cdec_SparseVector))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_1 = __pyx_v_y; __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsFloat(__pyx_v_x); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; __pyx_v_scalar = __pyx_t_3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":143 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":149 * if isinstance(x, SparseVector): vector, scalar = x, y * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) * return result */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_result = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":144 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":150 * else: vector, scalar = y, x * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) # <<<<<<<<<<<<<< @@ -4725,7 +4712,7 @@ static PyObject *__pyx_pf_5_cdec_12SparseVector_37__div__(PyObject *__pyx_v_x, P */ __pyx_v_result->vector = new FastSparseVector(((__pyx_v_vector->vector[0]) / __pyx_v_scalar)); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":145 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":151 * cdef SparseVector result = SparseVector.__new__(SparseVector) * result.vector = new FastSparseVector[weight_t](vector.vector[0] / scalar) * return result # <<<<<<<<<<<<<< @@ -4763,7 +4750,7 @@ static PyObject *__pyx_pw_5_cdec_1_phrase(PyObject *__pyx_self, PyObject *__pyx_ } static PyObject *__pyx_gb_5_cdec_7_phrase_2generator18(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":6 * * def _phrase(phrase): * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<< @@ -4842,16 +4829,16 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator18(__pyx_GeneratorObject *__ if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); @@ -4929,7 +4916,7 @@ static PyObject *__pyx_gb_5_cdec_7_phrase_2generator18(__pyx_GeneratorObject *__ return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< @@ -4958,7 +4945,7 @@ static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyO __Pyx_INCREF(__pyx_cur_scope->__pyx_v_phrase); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_phrase); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":6 * * def _phrase(phrase): * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<< @@ -5000,6 +4987,10 @@ static PyObject *__pyx_pf_5_cdec__phrase(CYTHON_UNUSED PyObject *__pyx_self, PyO /* Python wrapper */ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_2NT___init__[] = "NT(bytes cat, int ref=0) -> Non-terminal from category `cat`."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_2NT___init__; +#endif static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_cat = 0; unsigned int __pyx_v_ref; @@ -5065,12 +5056,12 @@ static int __pyx_pw_5_cdec_2NT_1__init__(PyObject *__pyx_v_self, PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":11 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":11 * cdef public bytes cat * cdef public unsigned ref * def __init__(self, bytes cat, unsigned ref=0): # <<<<<<<<<<<<<< + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" * self.cat = cat - * self.ref = ref */ static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self, PyObject *__pyx_v_cat, unsigned int __pyx_v_ref) { @@ -5078,9 +5069,9 @@ static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":12 - * cdef public unsigned ref + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":13 * def __init__(self, bytes cat, unsigned ref=0): + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" * self.cat = cat # <<<<<<<<<<<<<< * self.ref = ref * @@ -5091,8 +5082,8 @@ static int __pyx_pf_5_cdec_2NT___init__(struct __pyx_obj_5_cdec_NT *__pyx_v_self __Pyx_DECREF(((PyObject *)__pyx_v_self->cat)); __pyx_v_self->cat = __pyx_v_cat; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":13 - * def __init__(self, bytes cat, unsigned ref=0): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":14 + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" * self.cat = cat * self.ref = ref # <<<<<<<<<<<<<< * @@ -5116,7 +5107,7 @@ static PyObject *__pyx_pw_5_cdec_2NT_3__str__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":15 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":16 * self.ref = ref * * def __str__(self): # <<<<<<<<<<<<<< @@ -5135,7 +5126,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":16 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":17 * * def __str__(self): * if self.ref > 0: # <<<<<<<<<<<<<< @@ -5145,7 +5136,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ __pyx_t_1 = (__pyx_v_self->ref > 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":17 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":18 * def __str__(self): * if self.ref > 0: * return '[%s,%d]' % (self.cat, self.ref) # <<<<<<<<<<<<<< @@ -5153,9 +5144,9 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_self->cat)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->cat)); @@ -5163,7 +5154,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = ((PyObject *)__pyx_t_2); @@ -5173,7 +5164,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":18 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":19 * if self.ref > 0: * return '[%s,%d]' % (self.cat, self.ref) * return '[%s]' % self.cat # <<<<<<<<<<<<<< @@ -5181,7 +5172,7 @@ static PyObject *__pyx_pf_5_cdec_2NT_2__str__(struct __pyx_obj_5_cdec_NT *__pyx_ * cdef class NTRef: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_v_self->cat)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), ((PyObject *)__pyx_v_self->cat)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __pyx_r = ((PyObject *)__pyx_t_2); __pyx_t_2 = 0; @@ -5211,7 +5202,7 @@ static PyObject *__pyx_pw_5_cdec_2NT_3cat_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":9 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":9 * * cdef class NT: * cdef public bytes cat # <<<<<<<<<<<<<< @@ -5307,12 +5298,12 @@ static PyObject *__pyx_pw_5_cdec_2NT_3ref_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":10 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":10 * cdef class NT: * cdef public bytes cat * cdef public unsigned ref # <<<<<<<<<<<<<< * def __init__(self, bytes cat, unsigned ref=0): - * self.cat = cat + * """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" */ static PyObject *__pyx_pf_5_cdec_2NT_3ref___get__(struct __pyx_obj_5_cdec_NT *__pyx_v_self) { @@ -5376,6 +5367,10 @@ static int __pyx_pf_5_cdec_2NT_3ref_2__set__(struct __pyx_obj_5_cdec_NT *__pyx_v /* Python wrapper */ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_5NTRef___init__[] = "NTRef(int ref) -> Non-terminal reference."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_5NTRef___init__; +#endif static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { unsigned int __pyx_v_ref; int __pyx_r; @@ -5399,18 +5394,18 @@ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__ else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; } else { values[0] = PyTuple_GET_ITEM(__pyx_args, 0); } - __pyx_v_ref = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_ref == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_ref = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_ref == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.NTRef.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5421,12 +5416,12 @@ static int __pyx_pw_5_cdec_5NTRef_1__init__(PyObject *__pyx_v_self, PyObject *__ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":22 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":23 * cdef class NTRef: * cdef public unsigned ref * def __init__(self, unsigned ref): # <<<<<<<<<<<<<< + * """NTRef(int ref) -> Non-terminal reference.""" * self.ref = ref - * */ static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self, unsigned int __pyx_v_ref) { @@ -5434,9 +5429,9 @@ static int __pyx_pf_5_cdec_5NTRef___init__(struct __pyx_obj_5_cdec_NTRef *__pyx_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":23 - * cdef public unsigned ref + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":25 * def __init__(self, unsigned ref): + * """NTRef(int ref) -> Non-terminal reference.""" * self.ref = ref # <<<<<<<<<<<<<< * * def __str__(self): @@ -5459,7 +5454,7 @@ static PyObject *__pyx_pw_5_cdec_5NTRef_3__str__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":25 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":27 * self.ref = ref * * def __str__(self): # <<<<<<<<<<<<<< @@ -5477,7 +5472,7 @@ static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef * int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":26 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":28 * * def __str__(self): * return '[%d]' % self.ref # <<<<<<<<<<<<<< @@ -5485,9 +5480,9 @@ static PyObject *__pyx_pf_5_cdec_5NTRef_2__str__(struct __pyx_obj_5_cdec_NTRef * * cdef TRule convert_rule(_sa.Rule rule): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = ((PyObject *)__pyx_t_2); @@ -5518,12 +5513,12 @@ static PyObject *__pyx_pw_5_cdec_5NTRef_3ref_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":21 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":22 * * cdef class NTRef: * cdef public unsigned ref # <<<<<<<<<<<<<< * def __init__(self, unsigned ref): - * self.ref = ref + * """NTRef(int ref) -> Non-terminal reference.""" */ static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTRef *__pyx_v_self) { @@ -5535,7 +5530,7 @@ static PyObject *__pyx_pf_5_cdec_5NTRef_3ref___get__(struct __pyx_obj_5_cdec_NTR int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -5572,7 +5567,7 @@ static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *_ const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->ref = __pyx_t_1; __pyx_r = 0; @@ -5585,7 +5580,7 @@ static int __pyx_pf_5_cdec_5NTRef_3ref_2__set__(struct __pyx_obj_5_cdec_NTRef *_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":28 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":30 * return '[%d]' % self.ref * * cdef TRule convert_rule(_sa.Rule rule): # <<<<<<<<<<<<<< @@ -5615,7 +5610,7 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o int __pyx_clineno = 0; __Pyx_RefNannySetupContext("convert_rule", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":29 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":31 * * cdef TRule convert_rule(_sa.Rule rule): * lhs = _sa.sym_tocat(rule.lhs) # <<<<<<<<<<<<<< @@ -5624,41 +5619,41 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_lhs = __pyx_f_4cdec_2sa_3_sa_sym_tocat(__pyx_v_rule->lhs); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":30 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":32 * cdef TRule convert_rule(_sa.Rule rule): * lhs = _sa.sym_tocat(rule.lhs) * scores = dict(rule.scores) # <<<<<<<<<<<<<< * f, e = [], [] * cdef int* fsyms = rule.f.syms */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_rule->scores)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_rule->scores)); __Pyx_GIVEREF(((PyObject *)__pyx_v_rule->scores)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyDict_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_scores = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":31 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":33 * lhs = _sa.sym_tocat(rule.lhs) * scores = dict(rule.scores) * f, e = [], [] # <<<<<<<<<<<<<< * cdef int* fsyms = rule.f.syms * for i in range(rule.f.n): */ - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_f = __pyx_t_2; __pyx_t_2 = 0; __pyx_v_e = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":32 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":34 * scores = dict(rule.scores) * f, e = [], [] * cdef int* fsyms = rule.f.syms # <<<<<<<<<<<<<< @@ -5667,7 +5662,7 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_fsyms = __pyx_v_rule->f->syms; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":33 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":35 * f, e = [], [] * cdef int* fsyms = rule.f.syms * for i in range(rule.f.n): # <<<<<<<<<<<<<< @@ -5678,7 +5673,7 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":34 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":36 * cdef int* fsyms = rule.f.syms * for i in range(rule.f.n): * if _sa.sym_isvar(fsyms[i]): # <<<<<<<<<<<<<< @@ -5688,45 +5683,45 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o __pyx_t_5 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_fsyms[__pyx_v_i])); if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":35 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":37 * for i in range(rule.f.n): * if _sa.sym_isvar(fsyms[i]): * f.append(NT(_sa.sym_tocat(fsyms[i]))) # <<<<<<<<<<<<<< * else: * f.append(_sa.sym_tostring(fsyms[i])) */ - __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tocat((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_6 = PyList_Append(__pyx_v_f, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_Append(__pyx_v_f, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":37 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":39 * f.append(NT(_sa.sym_tocat(fsyms[i]))) * else: * f.append(_sa.sym_tostring(fsyms[i])) # <<<<<<<<<<<<<< * cdef int* esyms = rule.e.syms * for i in range(rule.e.n): */ - __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_fsyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_6 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_Append(__pyx_v_f, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; } __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":38 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":40 * else: * f.append(_sa.sym_tostring(fsyms[i])) * cdef int* esyms = rule.e.syms # <<<<<<<<<<<<<< @@ -5735,7 +5730,7 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o */ __pyx_v_esyms = __pyx_v_rule->e->syms; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":39 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":41 * f.append(_sa.sym_tostring(fsyms[i])) * cdef int* esyms = rule.e.syms * for i in range(rule.e.n): # <<<<<<<<<<<<<< @@ -5746,7 +5741,7 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { __pyx_v_i = __pyx_t_4; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":40 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":42 * cdef int* esyms = rule.e.syms * for i in range(rule.e.n): * if _sa.sym_isvar(esyms[i]): # <<<<<<<<<<<<<< @@ -5756,68 +5751,68 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o __pyx_t_5 = __pyx_f_4cdec_2sa_3_sa_sym_isvar((__pyx_v_esyms[__pyx_v_i])); if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":41 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":43 * for i in range(rule.e.n): * if _sa.sym_isvar(esyms[i]): * e.append(NTRef(_sa.sym_getindex(esyms[i]))) # <<<<<<<<<<<<<< * else: * e.append(_sa.sym_tostring(esyms[i])) */ - __pyx_t_1 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_f_4cdec_2sa_3_sa_sym_getindex((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_6 = PyList_Append(__pyx_v_e, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_Append(__pyx_v_e, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L8; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":43 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":45 * e.append(NTRef(_sa.sym_getindex(esyms[i]))) * else: * e.append(_sa.sym_tostring(esyms[i])) # <<<<<<<<<<<<<< * a = list(rule.alignments()) * return TRule(lhs, f, e, scores, a) */ - __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_f_4cdec_2sa_3_sa_sym_tostring((__pyx_v_esyms[__pyx_v_i]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_6 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyList_Append(__pyx_v_e, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; } __pyx_L8:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":44 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":46 * else: * e.append(_sa.sym_tostring(esyms[i])) * a = list(rule.alignments()) # <<<<<<<<<<<<<< * return TRule(lhs, f, e, scores, a) * */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rule), __pyx_n_s__alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_rule), __pyx_n_s__alignments); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_a = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":45 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":47 * e.append(_sa.sym_tostring(esyms[i])) * a = list(rule.alignments()) * return TRule(lhs, f, e, scores, a) # <<<<<<<<<<<<<< @@ -5825,9 +5820,9 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o * cdef class TRule: */ __Pyx_XDECREF(((PyObject *)__pyx_r)); - __pyx_t_2 = PyBytes_FromString(__pyx_v_lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyBytes_FromString(__pyx_v_lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); @@ -5844,7 +5839,7 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_v_a)); __Pyx_GIVEREF(((PyObject *)__pyx_v_a)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TRule)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_2); @@ -5870,6 +5865,10 @@ static struct __pyx_obj_5_cdec_TRule *__pyx_f_5_cdec_convert_rule(struct __pyx_o /* Python wrapper */ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_5TRule___init__[] = "TRule(lhs, f, e, scores, a=None) -> Translation rule.\n lhs: left hand side non-terminal\n f: source phrase (list of words/NT)\n e: target phrase (list of words/NTRef)\n scores: dictionary of feature scores\n a: optional list of alignment points"; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_5TRule___init__; +#endif static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_lhs = 0; PyObject *__pyx_v_f = 0; @@ -5883,12 +5882,12 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__f,&__pyx_n_s__e,&__pyx_n_s__scores,&__pyx_n_s__a,0}; PyObject* values[5] = {0,0,0,0,0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":52 * cdef shared_ptr[grammar.TRule]* rule * * def __init__(self, lhs, f, e, scores, a=None): # <<<<<<<<<<<<<< - * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) - * self.lhs = lhs + * """TRule(lhs, f, e, scores, a=None) -> Translation rule. + * lhs: left hand side non-terminal */ values[4] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -5911,17 +5910,17 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__f)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 3: if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 4: if (kw_args > 0) { @@ -5930,7 +5929,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -5951,7 +5950,7 @@ static int __pyx_pw_5_cdec_5TRule_1__init__(PyObject *__pyx_v_self, PyObject *__ } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.TRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -5972,75 +5971,75 @@ static int __pyx_pf_5_cdec_5TRule___init__(struct __pyx_obj_5_cdec_TRule *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":51 - * - * def __init__(self, lhs, f, e, scores, a=None): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":59 + * scores: dictionary of feature scores + * a: optional list of alignment points""" * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) # <<<<<<<<<<<<<< * self.lhs = lhs * self.e = e */ - try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + try {__pyx_t_1 = new TRule();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} __pyx_v_self->rule = new boost::shared_ptr(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":52 - * def __init__(self, lhs, f, e, scores, a=None): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":60 + * a: optional list of alignment points""" * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) * self.lhs = lhs # <<<<<<<<<<<<<< * self.e = e * self.f = f */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lhs, __pyx_v_lhs) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":53 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":61 * self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) * self.lhs = lhs * self.e = e # <<<<<<<<<<<<<< * self.f = f * self.scores = scores */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__e, __pyx_v_e) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":54 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":62 * self.lhs = lhs * self.e = e * self.f = f # <<<<<<<<<<<<<< * self.scores = scores * if a: */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__f, __pyx_v_f) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":55 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":63 * self.e = e * self.f = f * self.scores = scores # <<<<<<<<<<<<<< * if a: * self.a = a */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__scores, __pyx_v_scores) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":56 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":64 * self.f = f * self.scores = scores * if a: # <<<<<<<<<<<<<< * self.a = a * self.rule.get().ComputeArity() */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_a); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":57 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":65 * self.scores = scores * if a: * self.a = a # <<<<<<<<<<<<<< * self.rule.get().ComputeArity() * */ - if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__a, __pyx_v_a) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L3; } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":66 * if a: * self.a = a * self.rule.get().ComputeArity() # <<<<<<<<<<<<<< @@ -6068,7 +6067,7 @@ static void __pyx_pw_5_cdec_5TRule_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":60 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":68 * self.rule.get().ComputeArity() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -6080,7 +6079,7 @@ static void __pyx_pf_5_cdec_5TRule_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5 __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":61 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":69 * * def __dealloc__(self): * del self.rule # <<<<<<<<<<<<<< @@ -6103,7 +6102,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_5arity_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":64 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":72 * * property arity: * def __get__(self): # <<<<<<<<<<<<<< @@ -6120,7 +6119,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_T int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":65 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":73 * property arity: * def __get__(self): * return self.rule.get().arity_ # <<<<<<<<<<<<<< @@ -6128,7 +6127,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_5arity___get__(struct __pyx_obj_5_cdec_T * property f: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->rule->get()->arity_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->rule->get()->arity_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -6157,7 +6156,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1f_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":68 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":76 * * property f: * def __get__(self): # <<<<<<<<<<<<<< @@ -6184,7 +6183,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":69 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":77 * property f: * def __get__(self): * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<< @@ -6193,19 +6192,19 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":79 * cdef vector[WordID]* f_ = &self.rule.get().f_ * cdef WordID w * cdef f = [] # <<<<<<<<<<<<<< * cdef unsigned i * cdef int idx = 0 */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_f = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":73 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":81 * cdef f = [] * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6214,7 +6213,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":74 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":82 * cdef unsigned i * cdef int idx = 0 * for i in range(f_.size()): # <<<<<<<<<<<<<< @@ -6225,7 +6224,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":75 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":83 * cdef int idx = 0 * for i in range(f_.size()): * w = f_[0][i] # <<<<<<<<<<<<<< @@ -6234,7 +6233,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_w = ((__pyx_v_f_[0])[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":76 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":84 * for i in range(f_.size()): * w = f_[0][i] * if w < 0: # <<<<<<<<<<<<<< @@ -6244,7 +6243,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __pyx_t_4 = (__pyx_v_w < 0); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":77 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":85 * w = f_[0][i] * if w < 0: * idx += 1 # <<<<<<<<<<<<<< @@ -6253,18 +6252,18 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":78 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":86 * if w < 0: * idx += 1 * f.append(NT(TDConvert(-w).c_str(), idx)) # <<<<<<<<<<<<<< * else: * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) */ - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_w)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyInt_FromLong(__pyx_v_idx); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); @@ -6272,10 +6271,10 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __Pyx_GIVEREF(__pyx_t_5); __pyx_t_1 = 0; __pyx_t_5 = 0; - __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -6283,28 +6282,28 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":80 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":88 * f.append(NT(TDConvert(-w).c_str(), idx)) * else: * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) # <<<<<<<<<<<<<< * return f * */ - __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6)); __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyObject_Append(__pyx_v_f, __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; @@ -6312,7 +6311,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1f___get__(struct __pyx_obj_5_cdec_TRule __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":81 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":89 * else: * f.append(unicode(TDConvert(w).c_str(), encoding='utf8')) * return f # <<<<<<<<<<<<<< @@ -6350,7 +6349,7 @@ static int __pyx_pw_5_cdec_5TRule_1f_3__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":83 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":91 * return f * * def __set__(self, f): # <<<<<<<<<<<<<< @@ -6362,6 +6361,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p std::vector *__pyx_v_f_; unsigned int __pyx_v_i; CYTHON_UNUSED int __pyx_v_idx; + PyObject *__pyx_v_fi = NULL; int __pyx_r; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; @@ -6375,7 +6375,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":92 * * def __set__(self, f): * cdef vector[WordID]* f_ = &self.rule.get().f_ # <<<<<<<<<<<<<< @@ -6384,17 +6384,17 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_f_ = (&__pyx_v_self->rule->get()->f_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":85 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":93 * def __set__(self, f): * cdef vector[WordID]* f_ = &self.rule.get().f_ * f_.resize(len(f)) # <<<<<<<<<<<<<< * cdef unsigned i * cdef int idx = 0 */ - __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_f_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":95 * f_.resize(len(f)) * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6403,25 +6403,25 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":88 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":96 * cdef unsigned i * cdef int idx = 0 * for i in range(len(f)): # <<<<<<<<<<<<<< * if isinstance(f[i], NT): - * f_[0][i] = -TDConvert(f[i].cat) + * f_[0][i] = -TDConvert(( f[i]).cat) */ - __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_f); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":89 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":97 * cdef int idx = 0 * for i in range(len(f)): * if isinstance(f[i], NT): # <<<<<<<<<<<<<< - * f_[0][i] = -TDConvert(f[i].cat) + * f_[0][i] = -TDConvert(( f[i]).cat) * else: */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)); __Pyx_INCREF(__pyx_t_4); @@ -6430,36 +6430,47 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":90 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":98 * for i in range(len(f)): * if isinstance(f[i], NT): - * f_[0][i] = -TDConvert(f[i].cat) # <<<<<<<<<<<<<< + * f_[0][i] = -TDConvert(( f[i]).cat) # <<<<<<<<<<<<<< * else: - * f_[0][i] = TDConvert(as_str(f[i])) + * fi = as_str(f[i]) */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__cat); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_3); + __pyx_t_6 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_5_cdec_NT *)__pyx_t_4)->cat)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - ((__pyx_v_f_[0])[__pyx_v_i]) = (-TD::Convert(((char *)__pyx_t_6))); + ((__pyx_v_f_[0])[__pyx_v_i]) = (-TD::Convert(__pyx_t_6)); goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":92 - * f_[0][i] = -TDConvert(f[i].cat) + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":100 + * f_[0][i] = -TDConvert(( f[i]).cat) * else: - * f_[0][i] = TDConvert(as_str(f[i])) # <<<<<<<<<<<<<< + * fi = as_str(f[i]) # <<<<<<<<<<<<<< + * f_[0][i] = TDConvert(fi) * - * property e: */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_f, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + __pyx_t_3 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - ((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_fi)); + __pyx_v_fi = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":101 + * else: + * fi = as_str(f[i]) + * f_[0][i] = TDConvert(fi) # <<<<<<<<<<<<<< + * + * property e: + */ + __pyx_t_6 = PyBytes_AsString(((PyObject *)__pyx_v_fi)); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + ((__pyx_v_f_[0])[__pyx_v_i]) = TD::Convert(__pyx_t_6); } __pyx_L5:; } @@ -6472,6 +6483,7 @@ static int __pyx_pf_5_cdec_5TRule_1f_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_AddTraceback("_cdec.TRule.f.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_fi); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -6487,7 +6499,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1e_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":95 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":104 * * property e: * def __get__(self): # <<<<<<<<<<<<<< @@ -6514,7 +6526,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":96 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":105 * property e: * def __get__(self): * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<< @@ -6523,19 +6535,19 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":98 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":107 * cdef vector[WordID]* e_ = &self.rule.get().e_ * cdef WordID w * cdef e = [] # <<<<<<<<<<<<<< * cdef unsigned i * cdef int idx = 0 */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_e = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":100 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":109 * cdef e = [] * cdef unsigned i * cdef int idx = 0 # <<<<<<<<<<<<<< @@ -6544,7 +6556,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":101 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":110 * cdef unsigned i * cdef int idx = 0 * for i in range(e_.size()): # <<<<<<<<<<<<<< @@ -6555,7 +6567,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":102 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":111 * cdef int idx = 0 * for i in range(e_.size()): * w = e_[0][i] # <<<<<<<<<<<<<< @@ -6564,7 +6576,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_w = ((__pyx_v_e_[0])[__pyx_v_i]); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":103 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":112 * for i in range(e_.size()): * w = e_[0][i] * if w < 1: # <<<<<<<<<<<<<< @@ -6574,7 +6586,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule __pyx_t_4 = (__pyx_v_w < 1); if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":104 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":113 * w = e_[0][i] * if w < 1: * idx += 1 # <<<<<<<<<<<<<< @@ -6583,24 +6595,24 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_idx = (__pyx_v_idx + 1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":105 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":114 * if w < 1: * idx += 1 * e.append(NTRef(1-w)) # <<<<<<<<<<<<<< * else: * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) */ - __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong((1 - __pyx_v_w)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -6608,28 +6620,28 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":107 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":116 * e.append(NTRef(1-w)) * else: * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) # <<<<<<<<<<<<<< * return e * */ - __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyBytes_FromString(TD::Convert(__pyx_v_w).c_str()); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_5)); __Pyx_GIVEREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); - if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__encoding), ((PyObject *)__pyx_n_s__utf8)) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_e, __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; @@ -6637,7 +6649,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1e___get__(struct __pyx_obj_5_cdec_TRule __pyx_L5:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":117 * else: * e.append(unicode(TDConvert(w).c_str(), encoding='utf8')) * return e # <<<<<<<<<<<<<< @@ -6675,7 +6687,7 @@ static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":110 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":119 * return e * * def __set__(self, e): # <<<<<<<<<<<<<< @@ -6686,6 +6698,7 @@ static int __pyx_pw_5_cdec_5TRule_1e_3__set__(PyObject *__pyx_v_self, PyObject * static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__pyx_v_self, PyObject *__pyx_v_e) { std::vector *__pyx_v_e_; unsigned int __pyx_v_i; + PyObject *__pyx_v_ei = NULL; int __pyx_r; __Pyx_RefNannyDeclarations Py_ssize_t __pyx_t_1; @@ -6694,12 +6707,13 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p PyObject *__pyx_t_4 = NULL; int __pyx_t_5; WordID __pyx_t_6; + char *__pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":111 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":120 * * def __set__(self, e): * cdef vector[WordID]* e_ = &self.rule.get().e_ # <<<<<<<<<<<<<< @@ -6708,35 +6722,35 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_e_ = (&__pyx_v_self->rule->get()->e_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":112 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":121 * def __set__(self, e): * cdef vector[WordID]* e_ = &self.rule.get().e_ * e_.resize(len(e)) # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(len(e)): */ - __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_e_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":114 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":123 * e_.resize(len(e)) * cdef unsigned i * for i in range(len(e)): # <<<<<<<<<<<<<< * if isinstance(e[i], NTRef): * e_[0][i] = 1-e[i].ref */ - __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_e); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":115 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":124 * cdef unsigned i * for i in range(len(e)): * if isinstance(e[i], NTRef): # <<<<<<<<<<<<<< * e_[0][i] = 1-e[i].ref * else: */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)); __Pyx_INCREF(__pyx_t_4); @@ -6745,39 +6759,53 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":116 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":125 * for i in range(len(e)): * if isinstance(e[i], NTRef): * e_[0][i] = 1-e[i].ref # <<<<<<<<<<<<<< * else: - * e_[0][i] = TDConvert(as_str(e[i])) + * ei = as_str(e[i]) */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__ref); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyNumber_Subtract(__pyx_int_1, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_PyInt_from_py_WordID(__pyx_t_4); if (unlikely((__pyx_t_6 == (WordID)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; ((__pyx_v_e_[0])[__pyx_v_i]) = __pyx_t_6; goto __pyx_L5; } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":118 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":127 * e_[0][i] = 1-e[i].ref * else: - * e_[0][i] = TDConvert(as_str(e[i])) # <<<<<<<<<<<<<< + * ei = as_str(e[i]) # <<<<<<<<<<<<<< + * e_[0][i] = TDConvert(ei) * - * property a: */ - __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_e, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - ((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)); + __pyx_t_3 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_4, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; + __Pyx_XDECREF(((PyObject *)__pyx_v_ei)); + __pyx_v_ei = ((PyObject*)__pyx_t_3); + __pyx_t_3 = 0; + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":128 + * else: + * ei = as_str(e[i]) + * e_[0][i] = TDConvert(ei) # <<<<<<<<<<<<<< + * + * property a: + */ + __pyx_t_7 = PyBytes_AsString(((PyObject *)__pyx_v_ei)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + ((__pyx_v_e_[0])[__pyx_v_i]) = TD::Convert(__pyx_t_7); } __pyx_L5:; } @@ -6790,6 +6818,7 @@ static int __pyx_pf_5_cdec_5TRule_1e_2__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_AddTraceback("_cdec.TRule.e.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_ei); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -6806,7 +6835,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_1a_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":121 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":131 * * property a: * def __get__(self): # <<<<<<<<<<<<<< @@ -6832,7 +6861,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_1a___get__(struct __pyx_obj_5_cdec_TRule __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_1a_2generator2, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -6869,9 +6898,9 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":123 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":133 * def __get__(self): * cdef unsigned i * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ # <<<<<<<<<<<<<< @@ -6880,7 +6909,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ */ __pyx_cur_scope->__pyx_v_a = (&__pyx_cur_scope->__pyx_v_self->rule->get()->a_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":124 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":134 * cdef unsigned i * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ * for i in range(a.size()): # <<<<<<<<<<<<<< @@ -6891,18 +6920,18 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":125 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":135 * cdef vector[grammar.AlignmentPoint]* a = &self.rule.get().a_ * for i in range(a.size()): * yield (a[0][i].s_, a[0][i].t_) # <<<<<<<<<<<<<< * * def __set__(self, a): */ - __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).s_); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyInt_FromLong(((__pyx_cur_scope->__pyx_v_a[0])[__pyx_cur_scope->__pyx_v_i]).t_); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); @@ -6922,7 +6951,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_1a_2generator2(__pyx_GeneratorObject *__ __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -6950,7 +6979,7 @@ static int __pyx_pw_5_cdec_5TRule_1a_4__set__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":127 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":137 * yield (a[0][i].s_, a[0][i].t_) * * def __set__(self, a): # <<<<<<<<<<<<<< @@ -6979,7 +7008,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":128 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":138 * * def __set__(self, a): * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ # <<<<<<<<<<<<<< @@ -6988,35 +7017,35 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p */ __pyx_v_a_ = (&__pyx_v_self->rule->get()->a_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":129 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":139 * def __set__(self, a): * cdef vector[grammar.AlignmentPoint]* a_ = &self.rule.get().a_ * a_.resize(len(a)) # <<<<<<<<<<<<<< * cdef unsigned i * cdef int s, t */ - __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_a_->resize(__pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":132 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":142 * cdef unsigned i * cdef int s, t * for i in range(len(a)): # <<<<<<<<<<<<<< * s, t = a[i] * a_[0][i] = grammar.AlignmentPoint(s, t) */ - __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(__pyx_v_a); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":133 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":143 * cdef int s, t * for i in range(len(a)): * s, t = a[i] # <<<<<<<<<<<<<< * a_[0][i] = grammar.AlignmentPoint(s, t) * */ - __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_a, __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { PyObject* sequence = __pyx_t_3; @@ -7028,7 +7057,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -7041,14 +7070,14 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; - __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext; @@ -7056,7 +7085,7 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_GOTREF(__pyx_t_4); index = 1; __pyx_t_5 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_7 = NULL; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L6_unpacking_done; @@ -7064,17 +7093,17 @@ static int __pyx_pf_5_cdec_5TRule_1a_3__set__(struct __pyx_obj_5_cdec_TRule *__p __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_7 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } - __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_v_s = __pyx_t_8; __pyx_v_t = __pyx_t_9; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":134 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":144 * for i in range(len(a)): * s, t = a[i] * a_[0][i] = grammar.AlignmentPoint(s, t) # <<<<<<<<<<<<<< @@ -7109,7 +7138,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_6scores_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":137 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":147 * * property scores: * def __get__(self): # <<<<<<<<<<<<<< @@ -7127,20 +7156,20 @@ static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":138 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":148 * property scores: * def __get__(self): * cdef SparseVector scores = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * scores.vector = new FastSparseVector[double](self.rule.get().scores_) * return scores */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_scores = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":139 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":149 * def __get__(self): * cdef SparseVector scores = SparseVector.__new__(SparseVector) * scores.vector = new FastSparseVector[double](self.rule.get().scores_) # <<<<<<<<<<<<<< @@ -7149,7 +7178,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_6scores___get__(struct __pyx_obj_5_cdec_ */ __pyx_v_scores->vector = new FastSparseVector(__pyx_v_self->rule->get()->scores_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":140 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":150 * cdef SparseVector scores = SparseVector.__new__(SparseVector) * scores.vector = new FastSparseVector[double](self.rule.get().scores_) * return scores # <<<<<<<<<<<<<< @@ -7185,7 +7214,7 @@ static int __pyx_pw_5_cdec_5TRule_6scores_3__set__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":142 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":152 * return scores * * def __set__(self, scores): # <<<<<<<<<<<<<< @@ -7198,6 +7227,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule int __pyx_v_fid; float __pyx_v_fval; PyObject *__pyx_v_fname = NULL; + PyObject *__pyx_v_fn = NULL; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; @@ -7209,13 +7239,14 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule PyObject *__pyx_t_7 = NULL; PyObject *(*__pyx_t_8)(PyObject *); float __pyx_t_9; - int __pyx_t_10; + char *__pyx_t_10; + int __pyx_t_11; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":143 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":153 * * def __set__(self, scores): * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ # <<<<<<<<<<<<<< @@ -7224,7 +7255,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_scores_ = (&__pyx_v_self->rule->get()->scores_); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":144 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":154 * def __set__(self, scores): * cdef FastSparseVector[double]* scores_ = &self.rule.get().scores_ * scores_.clear() # <<<<<<<<<<<<<< @@ -7233,23 +7264,23 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule */ __pyx_v_scores_->clear(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":147 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":157 * cdef int fid * cdef float fval * for fname, fval in scores.items(): # <<<<<<<<<<<<<< - * fid = FDConvert(as_str(fname)) - * if fid < 0: raise KeyError(fname) + * fn = as_str(fname) + * fid = FDConvert(fn) */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_scores, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -7258,23 +7289,23 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_4(__pyx_t_1); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7290,7 +7321,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -7303,14 +7334,14 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -7318,7 +7349,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L6_unpacking_done; @@ -7326,51 +7357,65 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L6_unpacking_done:; } - __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 147; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_9 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_v_fname); __pyx_v_fname = __pyx_t_5; __pyx_t_5 = 0; __pyx_v_fval = __pyx_t_9; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":148 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":158 * cdef float fval * for fname, fval in scores.items(): - * fid = FDConvert(as_str(fname)) # <<<<<<<<<<<<<< + * fn = as_str(fname) # <<<<<<<<<<<<<< + * fid = FDConvert(fn) * if fid < 0: raise KeyError(fname) - * scores_.set_value(fid, fval) */ - __pyx_v_fid = FD::Convert(__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL)); + __pyx_t_2 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_fname, NULL)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_2); + __Pyx_XDECREF(((PyObject *)__pyx_v_fn)); + __pyx_v_fn = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":149 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":159 * for fname, fval in scores.items(): - * fid = FDConvert(as_str(fname)) + * fn = as_str(fname) + * fid = FDConvert(fn) # <<<<<<<<<<<<<< + * if fid < 0: raise KeyError(fname) + * scores_.set_value(fid, fval) + */ + __pyx_t_10 = PyBytes_AsString(((PyObject *)__pyx_v_fn)); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_fid = FD::Convert(__pyx_t_10); + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":160 + * fn = as_str(fname) + * fid = FDConvert(fn) * if fid < 0: raise KeyError(fname) # <<<<<<<<<<<<<< * scores_.set_value(fid, fval) * */ - __pyx_t_10 = (__pyx_v_fid < 0); - if (__pyx_t_10) { - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_11 = (__pyx_v_fid < 0); + if (__pyx_t_11) { + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_fname); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fname); __Pyx_GIVEREF(__pyx_v_fname); - __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L7; } __pyx_L7:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":150 - * fid = FDConvert(as_str(fname)) + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":161 + * fid = FDConvert(fn) * if fid < 0: raise KeyError(fname) * scores_.set_value(fid, fval) # <<<<<<<<<<<<<< * @@ -7392,6 +7437,7 @@ static int __pyx_pf_5_cdec_5TRule_6scores_2__set__(struct __pyx_obj_5_cdec_TRule __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_fname); + __Pyx_XDECREF(__pyx_v_fn); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -7407,7 +7453,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_3lhs_1__get__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":153 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":164 * * property lhs: * def __get__(self): # <<<<<<<<<<<<<< @@ -7425,7 +7471,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":154 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":165 * property lhs: * def __get__(self): * return NT(TDConvert(-self.rule.get().lhs_).c_str()) # <<<<<<<<<<<<<< @@ -7433,14 +7479,14 @@ static PyObject *__pyx_pf_5_cdec_5TRule_3lhs___get__(struct __pyx_obj_5_cdec_TRu * def __set__(self, lhs): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->rule->get()->lhs_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -7471,7 +7517,7 @@ static int __pyx_pw_5_cdec_5TRule_3lhs_3__set__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":156 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":167 * return NT(TDConvert(-self.rule.get().lhs_).c_str()) * * def __set__(self, lhs): # <<<<<<<<<<<<<< @@ -7493,12 +7539,12 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ __Pyx_RefNannySetupContext("__set__", 0); __Pyx_INCREF(__pyx_v_lhs); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":157 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":168 * * def __set__(self, lhs): * if not isinstance(lhs, NT): # <<<<<<<<<<<<<< * lhs = NT(lhs) - * self.rule.get().lhs_ = -TDConvert(lhs.cat) + * self.rule.get().lhs_ = -TDConvert(( lhs).cat) */ __pyx_t_1 = ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)); __Pyx_INCREF(__pyx_t_1); @@ -7507,19 +7553,19 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ __pyx_t_3 = (!__pyx_t_2); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":158 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":169 * def __set__(self, lhs): * if not isinstance(lhs, NT): * lhs = NT(lhs) # <<<<<<<<<<<<<< - * self.rule.get().lhs_ = -TDConvert(lhs.cat) + * self.rule.get().lhs_ = -TDConvert(( lhs).cat) * */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_lhs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_lhs); __Pyx_GIVEREF(__pyx_v_lhs); - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NT)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_v_lhs); @@ -7529,18 +7575,15 @@ static int __pyx_pf_5_cdec_5TRule_3lhs_2__set__(struct __pyx_obj_5_cdec_TRule *_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":159 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":170 * if not isinstance(lhs, NT): * lhs = NT(lhs) - * self.rule.get().lhs_ = -TDConvert(lhs.cat) # <<<<<<<<<<<<<< + * self.rule.get().lhs_ = -TDConvert(( lhs).cat) # <<<<<<<<<<<<<< * * def __str__(self): */ - __pyx_t_4 = PyObject_GetAttr(__pyx_v_lhs, __pyx_n_s__cat); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_self->rule->get()->lhs_ = (-TD::Convert(((char *)__pyx_t_5))); + __pyx_t_5 = PyBytes_AsString(((PyObject *)((struct __pyx_obj_5_cdec_NT *)__pyx_v_lhs)->cat)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->rule->get()->lhs_ = (-TD::Convert(__pyx_t_5)); __pyx_r = 0; goto __pyx_L0; @@ -7567,7 +7610,7 @@ static PyObject *__pyx_pw_5_cdec_5TRule_5__str__(PyObject *__pyx_v_self) { } static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":173 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< @@ -7593,7 +7636,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_7__str___genexpr(PyObject *__pyx_self) { __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_7__str___2generator19, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_5TRule_7__str___2generator19, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -7629,15 +7672,15 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self), __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) { __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -7646,23 +7689,23 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_4(__pyx_t_2); if (unlikely(!__pyx_t_1)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -7673,7 +7716,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj __Pyx_GIVEREF(__pyx_t_1); __pyx_cur_scope->__pyx_v_feat = __pyx_t_1; __pyx_t_1 = 0; - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_cur_scope->__pyx_v_feat); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; @@ -7692,7 +7735,7 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj __Pyx_XGOTREF(__pyx_t_2); __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; __pyx_t_4 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetNone(PyExc_StopIteration); @@ -7709,8 +7752,8 @@ static PyObject *__pyx_gb_5_cdec_5TRule_7__str___2generator19(__pyx_GeneratorObj return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":161 - * self.rule.get().lhs_ = -TDConvert(lhs.cat) +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":172 + * self.rule.get().lhs_ = -TDConvert(( lhs).cat) * * def __str__(self): # <<<<<<<<<<<<<< * scores = ' '.join('%s=%s' % feat for feat in self.scores) @@ -7741,30 +7784,30 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":162 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":173 * * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) # <<<<<<<<<<<<<< * return '%s ||| %s ||| %s ||| %s' % (self.lhs, * _phrase(self.f), _phrase(self.e), scores) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_7), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __pyx_pf_5_cdec_5TRule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_pf_5_cdec_5TRule_7__str___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_scores = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":163 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":174 * def __str__(self): * scores = ' '.join('%s=%s' % feat for feat in self.scores) * return '%s ||| %s ||| %s ||| %s' % (self.lhs, # <<<<<<<<<<<<<< @@ -7772,43 +7815,43 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__lhs); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":164 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":175 * scores = ' '.join('%s=%s' % feat for feat in self.scores) * return '%s ||| %s ||| %s ||| %s' % (self.lhs, * _phrase(self.f), _phrase(self.e), scores) # <<<<<<<<<<<<<< * * cdef class MRule(TRule): */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__f); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s___phrase); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_n_s__e); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -7822,7 +7865,7 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_r = ((PyObject *)__pyx_t_3); @@ -7849,31 +7892,24 @@ static PyObject *__pyx_pf_5_cdec_5TRule_4__str__(struct __pyx_obj_5_cdec_TRule * /* Python wrapper */ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_5MRule___init__[] = "MRule(lhs, rhs, scores, a=None) -> Monolingual rule.\n lhs: left hand side non-terminal\n rhs: right hand side phrase (list of words/NT)\n scores: dictionary of feature scores"; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_5MRule___init__; +#endif static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_lhs = 0; PyObject *__pyx_v_rhs = 0; PyObject *__pyx_v_scores = 0; - PyObject *__pyx_v_a = 0; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,&__pyx_n_s__a,0}; - PyObject* values[4] = {0,0,0,0}; - - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":167 - * - * cdef class MRule(TRule): - * def __init__(self, lhs, rhs, scores, a=None): # <<<<<<<<<<<<<< - * cdef unsigned i = 1 - * e = [] - */ - values[3] = ((PyObject *)Py_None); + static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lhs,&__pyx_n_s__rhs,&__pyx_n_s__scores,0}; + PyObject* values[3] = {0,0,0}; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); @@ -7888,51 +7924,50 @@ static int __pyx_pw_5_cdec_5MRule_1__init__(PyObject *__pyx_v_self, PyObject *__ case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__rhs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } case 2: if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} - } - case 3: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a); - if (value) { values[3] = value; kw_args--; } + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } + } else if (PyTuple_GET_SIZE(__pyx_args) != 3) { + goto __pyx_L5_argtuple_error; } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3); - case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - break; - default: goto __pyx_L5_argtuple_error; - } + values[0] = PyTuple_GET_ITEM(__pyx_args, 0); + values[1] = PyTuple_GET_ITEM(__pyx_args, 1); + values[2] = PyTuple_GET_ITEM(__pyx_args, 2); } __pyx_v_lhs = values[0]; __pyx_v_rhs = values[1]; __pyx_v_scores = values[2]; - __pyx_v_a = values[3]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__init__", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.MRule.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_5MRule___init__(((struct __pyx_obj_5_cdec_MRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_rhs, __pyx_v_scores, __pyx_v_a); + __pyx_r = __pyx_pf_5_cdec_5MRule___init__(((struct __pyx_obj_5_cdec_MRule *)__pyx_v_self), __pyx_v_lhs, __pyx_v_rhs, __pyx_v_scores); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores, PyObject *__pyx_v_a) { +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":178 + * + * cdef class MRule(TRule): + * def __init__(self, lhs, rhs, scores): # <<<<<<<<<<<<<< + * """MRule(lhs, rhs, scores, a=None) -> Monolingual rule. + * lhs: left hand side non-terminal + */ + +static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_v_self, PyObject *__pyx_v_lhs, PyObject *__pyx_v_rhs, PyObject *__pyx_v_scores) { unsigned int __pyx_v_i; PyObject *__pyx_v_e = NULL; PyObject *__pyx_v_s = NULL; @@ -7950,28 +7985,28 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":168 - * cdef class MRule(TRule): - * def __init__(self, lhs, rhs, scores, a=None): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":183 + * rhs: right hand side phrase (list of words/NT) + * scores: dictionary of feature scores""" * cdef unsigned i = 1 # <<<<<<<<<<<<<< * e = [] * for s in rhs: */ __pyx_v_i = 1; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":169 - * def __init__(self, lhs, rhs, scores, a=None): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":184 + * scores: dictionary of feature scores""" * cdef unsigned i = 1 * e = [] # <<<<<<<<<<<<<< * for s in rhs: * if isinstance(s, NT): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_e = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":170 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":185 * cdef unsigned i = 1 * e = [] * for s in rhs: # <<<<<<<<<<<<<< @@ -7982,7 +8017,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __pyx_t_1 = __pyx_v_rhs; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rhs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -7990,23 +8025,23 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -8016,7 +8051,7 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __pyx_v_s = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":171 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":186 * e = [] * for s in rhs: * if isinstance(s, NT): # <<<<<<<<<<<<<< @@ -8029,27 +8064,27 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":172 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":187 * for s in rhs: * if isinstance(s, NT): * e.append(NTRef(i)) # <<<<<<<<<<<<<< * i += 1 * else: */ - __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_NTRef)), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_t_4); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":173 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":188 * if isinstance(s, NT): * e.append(NTRef(i)) * i += 1 # <<<<<<<<<<<<<< @@ -8061,27 +8096,27 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":175 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":190 * i += 1 * else: * e.append(s) # <<<<<<<<<<<<<< - * super(MRule, self).__init__(lhs, rhs, e, scores, a) + * super(MRule, self).__init__(lhs, rhs, e, scores, None) * */ - __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_Append(__pyx_v_e, __pyx_v_s); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L5:; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":176 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":191 * else: * e.append(s) - * super(MRule, self).__init__(lhs, rhs, e, scores, a) # <<<<<<<<<<<<<< + * super(MRule, self).__init__(lhs, rhs, e, scores, None) # <<<<<<<<<<<<<< * * cdef class Grammar: */ - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule))); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_5_cdec_MRule))); @@ -8089,13 +8124,13 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_super, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____init__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_INCREF(__pyx_v_lhs); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_lhs); @@ -8109,10 +8144,10 @@ static int __pyx_pf_5_cdec_5MRule___init__(struct __pyx_obj_5_cdec_MRule *__pyx_ __Pyx_INCREF(__pyx_v_scores); PyTuple_SET_ITEM(__pyx_t_4, 3, __pyx_v_scores); __Pyx_GIVEREF(__pyx_v_scores); - __Pyx_INCREF(__pyx_v_a); - PyTuple_SET_ITEM(__pyx_t_4, 4, __pyx_v_a); - __Pyx_GIVEREF(__pyx_v_a); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(Py_None); + PyTuple_SET_ITEM(__pyx_t_4, 4, Py_None); + __Pyx_GIVEREF(Py_None); + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; @@ -8142,7 +8177,7 @@ static void __pyx_pw_5_cdec_7Grammar_1__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":181 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":196 * cdef shared_ptr[grammar.Grammar]* grammar * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -8154,7 +8189,7 @@ static void __pyx_pf_5_cdec_7Grammar___dealloc__(CYTHON_UNUSED struct __pyx_obj_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":182 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":197 * * def __dealloc__(self): * del self.grammar # <<<<<<<<<<<<<< @@ -8178,7 +8213,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_3__iter__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":184 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":199 * del self.grammar * * def __iter__(self): # <<<<<<<<<<<<<< @@ -8204,7 +8239,7 @@ static PyObject *__pyx_pf_5_cdec_7Grammar_2__iter__(struct __pyx_obj_5_cdec_Gram __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Grammar_4generator3, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -8239,9 +8274,9 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":185 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":200 * * def __iter__(self): * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() # <<<<<<<<<<<<<< @@ -8250,7 +8285,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_root = __pyx_cur_scope->__pyx_v_self->grammar->get()->GetRoot(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":186 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":201 * def __iter__(self): * cdef grammar.const_GrammarIter* root = self.grammar.get().GetRoot() * cdef grammar.const_RuleBin* rbin = root.GetRules() # <<<<<<<<<<<<<< @@ -8259,7 +8294,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_rbin = __pyx_cur_scope->__pyx_v_root->GetRules(); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":189 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":204 * cdef TRule trule * cdef unsigned i * for i in range(rbin.GetNumRules()): # <<<<<<<<<<<<<< @@ -8270,23 +8305,23 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":190 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":205 * cdef unsigned i * for i in range(rbin.GetNumRules()): * trule = TRule.__new__(TRule) # <<<<<<<<<<<<<< * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) * yield trule */ - __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule)); __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_trule)); __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":191 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":206 * for i in range(rbin.GetNumRules()): * trule = TRule.__new__(TRule) * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) # <<<<<<<<<<<<<< @@ -8295,7 +8330,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p */ __pyx_cur_scope->__pyx_v_trule->rule = new boost::shared_ptr(__pyx_cur_scope->__pyx_v_rbin->GetIthRule(__pyx_cur_scope->__pyx_v_i)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":192 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":207 * trule = TRule.__new__(TRule) * trule.rule = new shared_ptr[grammar.TRule](rbin.GetIthRule(i)) * yield trule # <<<<<<<<<<<<<< @@ -8314,7 +8349,7 @@ static PyObject *__pyx_gb_5_cdec_7Grammar_4generator3(__pyx_GeneratorObject *__p __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -8340,7 +8375,7 @@ static PyObject *__pyx_pw_5_cdec_7Grammar_4name_1__get__(PyObject *__pyx_v_self) return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":195 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":210 * * property name: * def __get__(self): # <<<<<<<<<<<<<< @@ -8358,21 +8393,21 @@ static PyObject *__pyx_pf_5_cdec_7Grammar_4name___get__(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":196 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":211 * property name: * def __get__(self): * str(self.grammar.get().GetGrammarName().c_str()) # <<<<<<<<<<<<<< * * def __set__(self, name): */ - __pyx_t_1 = PyBytes_FromString(__pyx_v_self->grammar->get()->GetGrammarName().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_v_self->grammar->get()->GetGrammarName().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; @@ -8401,50 +8436,71 @@ static int __pyx_pw_5_cdec_7Grammar_4name_3__set__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":198 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":213 * str(self.grammar.get().GetGrammarName().c_str()) * * def __set__(self, name): # <<<<<<<<<<<<<< - * self.grammar.get().SetGrammarName(string(name)) - * + * name = as_str(name) + * self.grammar.get().SetGrammarName(name) */ static int __pyx_pf_5_cdec_7Grammar_4name_2__set__(struct __pyx_obj_5_cdec_Grammar *__pyx_v_self, PyObject *__pyx_v_name) { int __pyx_r; __Pyx_RefNannyDeclarations - char *__pyx_t_1; + PyObject *__pyx_t_1 = NULL; + std::string __pyx_t_2; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); + __Pyx_INCREF(__pyx_v_name); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":199 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":214 + * + * def __set__(self, name): + * name = as_str(name) # <<<<<<<<<<<<<< + * self.grammar.get().SetGrammarName(name) * + */ + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_name, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(__pyx_v_name); + __pyx_v_name = __pyx_t_1; + __pyx_t_1 = 0; + + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":215 * def __set__(self, name): - * self.grammar.get().SetGrammarName(string(name)) # <<<<<<<<<<<<<< + * name = as_str(name) + * self.grammar.get().SetGrammarName(name) # <<<<<<<<<<<<<< * * cdef class TextGrammar(Grammar): */ - __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->grammar->get()->SetGrammarName(std::string(((char *)__pyx_t_1))); + __pyx_t_2 = __pyx_convert_string_from_py_(__pyx_v_name); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->grammar->get()->SetGrammarName(__pyx_t_2); __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; + __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("_cdec.Grammar.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_name); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ -static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pw_5_cdec_11TextGrammar_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_11TextGrammar___init__[] = "TextGrammar(rules) -> SCFG Grammar containing the rules."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_11TextGrammar___init__; +#endif +static int __pyx_pw_5_cdec_11TextGrammar_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_rules = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__rules,0}; PyObject* values[1] = {0}; @@ -8463,7 +8519,7 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -8474,26 +8530,26 @@ static int __pyx_pw_5_cdec_11TextGrammar_1__cinit__(PyObject *__pyx_v_self, PyOb } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[2]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; - __Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.TextGrammar.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_11TextGrammar___cinit__(((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_v_self), __pyx_v_rules); + __pyx_r = __pyx_pf_5_cdec_11TextGrammar___init__(((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_v_self), __pyx_v_rules); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":202 +/* "/home/vchahune/tools/cdec/python/src/grammar.pxi":218 * * cdef class TextGrammar(Grammar): - * def __cinit__(self, rules): # <<<<<<<<<<<<<< + * def __init__(self, rules): # <<<<<<<<<<<<<< + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) - * cdef grammar.TextGrammar* _g = self.grammar.get() */ -static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules) { +static int __pyx_pf_5_cdec_11TextGrammar___init__(struct __pyx_obj_5_cdec_TextGrammar *__pyx_v_self, PyObject *__pyx_v_rules) { TextGrammar *__pyx_v__g; PyObject *__pyx_v_trule = NULL; int __pyx_r; @@ -8508,19 +8564,19 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); + __Pyx_RefNannySetupContext("__init__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":203 - * cdef class TextGrammar(Grammar): - * def __cinit__(self, rules): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":220 + * def __init__(self, rules): + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) # <<<<<<<<<<<<<< * cdef grammar.TextGrammar* _g = self.grammar.get() * for trule in rules: */ __pyx_v_self->__pyx_base.grammar = new boost::shared_ptr(new TextGrammar()); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":204 - * def __cinit__(self, rules): + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":221 + * """TextGrammar(rules) -> SCFG Grammar containing the rules.""" * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) * cdef grammar.TextGrammar* _g = self.grammar.get() # <<<<<<<<<<<<<< * for trule in rules: @@ -8528,7 +8584,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG */ __pyx_v__g = ((TextGrammar *)__pyx_v_self->__pyx_base.grammar->get()); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":205 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":222 * self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) * cdef grammar.TextGrammar* _g = self.grammar.get() * for trule in rules: # <<<<<<<<<<<<<< @@ -8539,7 +8595,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_t_1 = __pyx_v_rules; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = NULL; } else { - __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_rules); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -8547,23 +8603,23 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG if (!__pyx_t_3 && PyList_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_3 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; + __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_4 = __pyx_t_3(__pyx_t_1); if (unlikely(!__pyx_t_4)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[2]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -8573,7 +8629,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_v_trule = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":206 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":223 * cdef grammar.TextGrammar* _g = self.grammar.get() * for trule in rules: * if isinstance(trule, _sa.Rule): # <<<<<<<<<<<<<< @@ -8586,17 +8642,17 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (__pyx_t_5) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":207 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":224 * for trule in rules: * if isinstance(trule, _sa.Rule): * trule = convert_rule(trule) # <<<<<<<<<<<<<< * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') */ - if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_trule) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_trule, __pyx_ptype_4cdec_2sa_3_sa_Rule))))) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_4 = __pyx_v_trule; __Pyx_INCREF(__pyx_t_4); - __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_convert_rule(((struct __pyx_obj_4cdec_2sa_3_sa_Rule *)__pyx_t_4))); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_v_trule); @@ -8605,7 +8661,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG goto __pyx_L5; } - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":208 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":225 * if isinstance(trule, _sa.Rule): * trule = convert_rule(trule) * elif not isinstance(trule, TRule): # <<<<<<<<<<<<<< @@ -8619,22 +8675,22 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __pyx_t_7 = (!__pyx_t_5); if (__pyx_t_7) { - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":226 * trule = convert_rule(trule) * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<< * _g.AddRule(( trule).rule[0]) */ - __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L5; } __pyx_L5:; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":210 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":227 * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') * _g.AddRule(( trule).rule[0]) # <<<<<<<<<<<<<< @@ -8649,7 +8705,7 @@ static int __pyx_pf_5_cdec_11TextGrammar___cinit__(struct __pyx_obj_5_cdec_TextG __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_cdec.TextGrammar.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.TextGrammar.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_trule); @@ -8666,7 +8722,7 @@ static void __pyx_pw_5_cdec_10Hypergraph_1__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":8 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":8 * cdef MT19937* rng * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -8679,7 +8735,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp int __pyx_t_1; __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":9 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":9 * * def __dealloc__(self): * del self.hg # <<<<<<<<<<<<<< @@ -8688,7 +8744,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp */ delete __pyx_v_self->hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":10 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":10 * def __dealloc__(self): * del self.hg * if self.rng != NULL: # <<<<<<<<<<<<<< @@ -8698,7 +8754,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp __pyx_t_1 = (__pyx_v_self->rng != NULL); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":11 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":11 * del self.hg * if self.rng != NULL: * del self.rng # <<<<<<<<<<<<<< @@ -8713,7 +8769,7 @@ static void __pyx_pf_5_cdec_10Hypergraph___dealloc__(struct __pyx_obj_5_cdec_Hyp __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":13 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":13 * del self.rng * * cdef MT19937* _rng(self): # <<<<<<<<<<<<<< @@ -8731,7 +8787,7 @@ static MT19937 *__pyx_f_5_cdec_10Hypergraph__rng(struct __pyx_obj_5_cdec_Hypergr int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_rng", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":14 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":14 * * cdef MT19937* _rng(self): * if self.rng == NULL: # <<<<<<<<<<<<<< @@ -8741,7 +8797,7 @@ static MT19937 *__pyx_f_5_cdec_10Hypergraph__rng(struct __pyx_obj_5_cdec_Hypergr __pyx_t_1 = (__pyx_v_self->rng == NULL); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":15 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":15 * cdef MT19937* _rng(self): * if self.rng == NULL: * self.rng = new MT19937() # <<<<<<<<<<<<<< @@ -8754,7 +8810,7 @@ static MT19937 *__pyx_f_5_cdec_10Hypergraph__rng(struct __pyx_obj_5_cdec_Hypergr } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":16 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":16 * if self.rng == NULL: * self.rng = new MT19937() * return self.rng # <<<<<<<<<<<<<< @@ -8776,6 +8832,7 @@ static MT19937 *__pyx_f_5_cdec_10Hypergraph__rng(struct __pyx_obj_5_cdec_Hypergr /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_2viterbi[] = "hg.viterbi() -> String for the best hypothesis in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8785,12 +8842,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_3viterbi(PyObject *__pyx_v_self, C return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":18 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":18 * return self.rng * * def viterbi(self): # <<<<<<<<<<<<<< + * """hg.viterbi() -> String for the best hypothesis in the hypergraph.""" * cdef vector[WordID] trans - * hypergraph.ViterbiESentence(self.hg[0], &trans) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8804,8 +8861,8 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":20 - * def viterbi(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":21 + * """hg.viterbi() -> String for the best hypothesis in the hypergraph.""" * cdef vector[WordID] trans * hypergraph.ViterbiESentence(self.hg[0], &trans) # <<<<<<<<<<<<<< * return unicode(GetString(trans).c_str(), 'utf8') @@ -8813,7 +8870,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H */ ViterbiESentence((__pyx_v_self->hg[0]), (&__pyx_v_trans)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":21 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":22 * cdef vector[WordID] trans * hypergraph.ViterbiESentence(self.hg[0], &trans) * return unicode(GetString(trans).c_str(), 'utf8') # <<<<<<<<<<<<<< @@ -8821,9 +8878,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H * def viterbi_trees(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_trans).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::GetString(__pyx_v_trans).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); @@ -8831,7 +8888,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -8853,6 +8910,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_2viterbi(struct __pyx_obj_5_cdec_H /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_4viterbi_trees[] = "hg.viterbi_trees() -> (f_tree, e_tree)\n f_tree: Source tree for the best hypothesis in the hypergraph.\n e_tree: Target tree for the best hypothesis in the hypergraph.\n "; static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8862,12 +8920,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":23 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":24 * return unicode(GetString(trans).c_str(), 'utf8') * * def viterbi_trees(self): # <<<<<<<<<<<<<< - * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') - * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') + * """hg.viterbi_trees() -> (f_tree, e_tree) + * f_tree: Source tree for the best hypothesis in the hypergraph. */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8882,16 +8940,16 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi_trees", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":24 - * - * def viterbi_trees(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":29 + * e_tree: Target tree for the best hypothesis in the hypergraph. + * """ * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') # <<<<<<<<<<<<<< * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') * return (f_tree, e_tree) */ - __pyx_t_1 = PyBytes_FromString(ViterbiFTree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(ViterbiFTree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); @@ -8899,22 +8957,22 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_f_tree = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":25 - * def viterbi_trees(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":30 + * """ * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') # <<<<<<<<<<<<<< * return (f_tree, e_tree) * */ - __pyx_t_1 = PyBytes_FromString(ViterbiETree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(ViterbiETree((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); @@ -8922,13 +8980,13 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_v_e_tree = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":26 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":31 * f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') * e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') * return (f_tree, e_tree) # <<<<<<<<<<<<<< @@ -8936,7 +8994,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ * def viterbi_features(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_f_tree)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_f_tree)); @@ -8965,6 +9023,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4viterbi_trees(struct __pyx_obj_5_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_6viterbi_features[] = "hg.viterbi_features() -> SparseVector with the features corresponding\n to the best derivation in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -8974,12 +9033,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_7viterbi_features(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":28 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":33 * return (f_tree, e_tree) * * def viterbi_features(self): # <<<<<<<<<<<<<< - * cdef SparseVector fmap = SparseVector.__new__(SparseVector) - * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) + * """hg.viterbi_features() -> SparseVector with the features corresponding + * to the best derivation in the hypergraph.""" */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -8992,21 +9051,21 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi_features", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":29 - * - * def viterbi_features(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":36 + * """hg.viterbi_features() -> SparseVector with the features corresponding + * to the best derivation in the hypergraph.""" * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) * return fmap */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":30 - * def viterbi_features(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":37 + * to the best derivation in the hypergraph.""" * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) # <<<<<<<<<<<<<< * return fmap @@ -9014,7 +9073,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj */ __pyx_v_fmap->vector = new FastSparseVector(ViterbiFeatures((__pyx_v_self->hg[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":31 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":38 * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) * return fmap # <<<<<<<<<<<<<< @@ -9041,6 +9100,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6viterbi_features(struct __pyx_obj /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_8viterbi_joshua[] = "hg.viterbi_joshua() -> Joshua representation of the best derivation."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -9050,12 +9110,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":33 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":40 * return fmap * * def viterbi_joshua(self): # <<<<<<<<<<<<<< + * """hg.viterbi_joshua() -> Joshua representation of the best derivation.""" * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') - * */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -9068,17 +9128,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("viterbi_joshua", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":34 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":42 * def viterbi_joshua(self): + * """hg.viterbi_joshua() -> Joshua representation of the best derivation.""" * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') # <<<<<<<<<<<<<< * * def kbest(self, size): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(JoshuaVisualizationString((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(JoshuaVisualizationString((__pyx_v_self->hg[0])).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); @@ -9086,7 +9146,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_8viterbi_joshua(struct __pyx_obj_5 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -9109,6 +9169,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_10kbest[] = "hg.kbest(size) -> List of k-best hypotheses in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, PyObject *__pyx_v_size) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -9118,12 +9179,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_11kbest(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":36 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":44 * return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') * * def kbest(self, size): # <<<<<<<<<<<<<< + * """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) { @@ -9147,7 +9208,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_10kbest(struct __pyx_obj_5_cdec_Hy __Pyx_INCREF(__pyx_cur_scope->__pyx_v_size); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_size); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_12generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_12generator4, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9184,19 +9245,19 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":37 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":46 * def kbest(self, size): + * """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation * cdef unsigned k */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_derivations = new KBest::KBestDerivations,ESentenceTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":40 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":49 * cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9205,18 +9266,18 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":41 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":50 * cdef unsigned k * try: * for k in range(size): # <<<<<<<<<<<<<< * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break */ - __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L5;} for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) { __pyx_cur_scope->__pyx_v_k = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":51 * try: * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9225,7 +9286,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_derivation = __pyx_cur_scope->__pyx_v_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":43 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":52 * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break # <<<<<<<<<<<<<< @@ -9239,16 +9300,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject } __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":44 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":53 * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break * yield unicode(GetString(derivation._yield).c_str(), 'utf8') # <<<<<<<<<<<<<< * finally: * del derivations */ - __pyx_t_4 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_derivation->yield).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_derivation->yield).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); @@ -9256,7 +9317,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; __pyx_r = __pyx_t_4; @@ -9271,12 +9332,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_12generator4(__pyx_GeneratorObject __pyx_L10_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L5;} } __pyx_L8_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":46 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":55 * yield unicode(GetString(derivation._yield).c_str(), 'utf8') * finally: * del derivations # <<<<<<<<<<<<<< @@ -9327,6 +9388,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_13kbest_trees[] = "hg.kbest_trees(size) -> List of k-best trees in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_self, PyObject *__pyx_v_size) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -9336,12 +9398,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_14kbest_trees(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":57 * del derivations * * def kbest_trees(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) { @@ -9365,7 +9427,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_13kbest_trees(struct __pyx_obj_5_c __Pyx_INCREF(__pyx_cur_scope->__pyx_v_size); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_size); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_15generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_15generator5, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9404,29 +9466,29 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":49 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":59 * def kbest_trees(self, size): + * """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal]* e_derivations = new kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal](self.hg[0], size) */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_f_derivations = new KBest::KBestDerivations,FTreeTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":51 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":61 * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) * cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal]* e_derivations = new kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal].Derivation* e_derivation * cdef unsigned k */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_e_derivations = new KBest::KBestDerivations,ETreeTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":54 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":64 * cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal].Derivation* e_derivation * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9435,18 +9497,18 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":55 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":65 * cdef unsigned k * try: * for k in range(size): # <<<<<<<<<<<<<< * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) */ - __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L5;} for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) { __pyx_cur_scope->__pyx_v_k = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":56 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":66 * try: * for k in range(size): * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9455,7 +9517,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_f_derivation = __pyx_cur_scope->__pyx_v_f_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":57 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":67 * for k in range(size): * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9464,7 +9526,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_e_derivation = __pyx_cur_scope->__pyx_v_e_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":68 * f_derivation = f_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not f_derivation or not e_derivation: break # <<<<<<<<<<<<<< @@ -9484,16 +9546,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject } __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":69 * e_derivation = e_derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not f_derivation or not e_derivation: break * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8') # <<<<<<<<<<<<<< * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8') * yield (f_tree, e_tree) */ - __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_f_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_f_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6)); __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); @@ -9501,7 +9563,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree)); @@ -9510,16 +9572,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_cur_scope->__pyx_v_f_tree = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":70 * if not f_derivation or not e_derivation: break * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8') * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8') # <<<<<<<<<<<<<< * yield (f_tree, e_tree) * finally: */ - __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_e_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyBytes_FromString(TD::GetString(__pyx_cur_scope->__pyx_v_e_derivation->yield).c_str()); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(((PyObject *)__pyx_t_6)); - __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6)); __Pyx_GIVEREF(((PyObject *)__pyx_t_6)); @@ -9527,7 +9589,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0; __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_e_tree)); @@ -9536,14 +9598,14 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_cur_scope->__pyx_v_e_tree = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":61 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":71 * f_tree = unicode(GetString(f_derivation._yield).c_str(), 'utf8') * e_tree = unicode(GetString(e_derivation._yield).c_str(), 'utf8') * yield (f_tree, e_tree) # <<<<<<<<<<<<<< * finally: * del f_derivations */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_v_f_tree)); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_cur_scope->__pyx_v_f_tree)); @@ -9563,12 +9625,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_L10_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L5;} } __pyx_L8_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":63 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":73 * yield (f_tree, e_tree) * finally: * del f_derivations # <<<<<<<<<<<<<< @@ -9592,7 +9654,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_15generator5(__pyx_GeneratorObject __pyx_L6:; delete __pyx_cur_scope->__pyx_v_f_derivations; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":64 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":74 * finally: * del f_derivations * del e_derivations # <<<<<<<<<<<<<< @@ -9628,6 +9690,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v_self, PyObject *__pyx_v_size); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_16kbest_features[] = "hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v_self, PyObject *__pyx_v_size) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -9637,12 +9700,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_17kbest_features(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":66 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":76 * del e_derivations * * def kbest_features(self, size): # <<<<<<<<<<<<<< + * """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) - * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_16kbest_features(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_size) { @@ -9666,7 +9729,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_16kbest_features(struct __pyx_obj_ __Pyx_INCREF(__pyx_cur_scope->__pyx_v_size); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_size); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_18generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_18generator6, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9702,19 +9765,19 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":67 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":78 * def kbest_features(self, size): + * """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) # <<<<<<<<<<<<<< * cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation * cdef SparseVector fmap */ - __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_cur_scope->__pyx_v_derivations = new KBest::KBestDerivations,FeatureVectorTraversal>((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_t_1); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":82 * cdef SparseVector fmap * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9723,18 +9786,18 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":83 * cdef unsigned k * try: * for k in range(size): # <<<<<<<<<<<<<< * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break */ - __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __Pyx_PyInt_AsLong(__pyx_cur_scope->__pyx_v_size); if (unlikely((__pyx_t_2 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L5;} for (__pyx_t_1 = 0; __pyx_t_1 < __pyx_t_2; __pyx_t_1+=1) { __pyx_cur_scope->__pyx_v_k = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":73 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":84 * try: * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) # <<<<<<<<<<<<<< @@ -9743,7 +9806,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_derivation = __pyx_cur_scope->__pyx_v_derivations->LazyKthBest((__pyx_cur_scope->__pyx_v_self->hg->nodes_.size() - 1), __pyx_cur_scope->__pyx_v_k); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":74 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":85 * for k in range(size): * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break # <<<<<<<<<<<<<< @@ -9757,23 +9820,23 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject } __pyx_L9:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":75 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":86 * derivation = derivations.LazyKthBest(self.hg.nodes_.size() - 1, k) * if not derivation: break * fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * fmap.vector = new FastSparseVector[weight_t](derivation._yield) * yield fmap */ - __pyx_t_4 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_4 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_GOTREF(__pyx_t_4); - if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (!(likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L5;} __Pyx_XGOTREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap)); __Pyx_XDECREF(((PyObject *)__pyx_cur_scope->__pyx_v_fmap)); __Pyx_GIVEREF(__pyx_t_4); __pyx_cur_scope->__pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":76 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":87 * if not derivation: break * fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](derivation._yield) # <<<<<<<<<<<<<< @@ -9782,7 +9845,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject */ __pyx_cur_scope->__pyx_v_fmap->vector = new FastSparseVector(__pyx_cur_scope->__pyx_v_derivation->yield); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":77 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":88 * fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](derivation._yield) * yield fmap # <<<<<<<<<<<<<< @@ -9801,12 +9864,12 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_18generator6(__pyx_GeneratorObject __pyx_L10_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L5;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L5;} } __pyx_L8_break:; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":79 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":90 * yield fmap * finally: * del derivations # <<<<<<<<<<<<<< @@ -9855,13 +9918,14 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_19sample[] = "hg.sample(n) -> Sample of n hypotheses from the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, PyObject *__pyx_arg_n) { unsigned int __pyx_v_n; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sample (wrapper)", 0); assert(__pyx_arg_n); { - __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -9874,12 +9938,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_20sample(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":81 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":92 * del derivations * * def sample(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() - * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n) { @@ -9901,7 +9965,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_19sample(struct __pyx_obj_5_cdec_H __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __pyx_cur_scope->__pyx_v_n = __pyx_v_n; { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_21generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_21generator7, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -9923,10 +9987,11 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject { struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)__pyx_generator->closure); PyObject *__pyx_r = NULL; - size_t __pyx_t_1; - unsigned int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; + std::vector *__pyx_t_1; + size_t __pyx_t_2; + unsigned int __pyx_t_3; PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("None", 0); switch (__pyx_generator->resume_label) { @@ -9937,19 +10002,20 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":82 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":94 * def sample(self, unsigned n): + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() # <<<<<<<<<<<<<< * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) * cdef unsigned k */ - __pyx_cur_scope->__pyx_v_hypos = new std::vector(); + try {__pyx_t_1 = new std::vector();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_cur_scope->__pyx_v_hypos = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":83 - * def sample(self, unsigned n): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":95 + * """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" * cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) # <<<<<<<<<<<<<< * cdef unsigned k @@ -9957,7 +10023,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject */ HypergraphSampler::sample_hypotheses((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_cur_scope->__pyx_v_n, ((struct __pyx_vtabstruct_5_cdec_Hypergraph *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_rng(__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_hypos); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":85 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":97 * hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -9966,54 +10032,54 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":86 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":98 * cdef unsigned k * try: * for k in range(hypos.size()): # <<<<<<<<<<<<<< * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8') * finally: */ - __pyx_t_1 = __pyx_cur_scope->__pyx_v_hypos->size(); - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_cur_scope->__pyx_v_k = __pyx_t_2; + __pyx_t_2 = __pyx_cur_scope->__pyx_v_hypos->size(); + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_cur_scope->__pyx_v_k = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":99 * try: * for k in range(hypos.size()): * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8') # <<<<<<<<<<<<<< * finally: * del hypos */ - __pyx_t_3 = PyBytes_FromString(TD::GetString(((__pyx_cur_scope->__pyx_v_hypos[0])[__pyx_cur_scope->__pyx_v_k]).words).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_4 = PyBytes_FromString(TD::GetString(((__pyx_cur_scope->__pyx_v_hypos[0])[__pyx_cur_scope->__pyx_v_k]).words).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; - __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L9_resume_from_yield:; - __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; - __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L5;} } } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":89 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":101 * yield unicode(GetString(hypos[0][k].words).c_str(), 'utf8') * finally: * del hypos # <<<<<<<<<<<<<< @@ -10028,8 +10094,8 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject __pyx_why = 0; goto __pyx_L6; __pyx_L5: { __pyx_why = 4; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L6; @@ -10050,8 +10116,8 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_21generator7(__pyx_GeneratorObject PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("sample", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); @@ -10064,13 +10130,14 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_23sample_trees(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_22sample_trees[] = "hg.sample_trees(n) -> Sample of n trees from the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_23sample_trees(PyObject *__pyx_v_self, PyObject *__pyx_arg_n) { unsigned int __pyx_v_n; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sample_trees (wrapper)", 0); assert(__pyx_arg_n); { - __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __pyx_v_n = __Pyx_PyInt_AsUnsignedInt(__pyx_arg_n); if (unlikely((__pyx_v_n == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; @@ -10083,12 +10150,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_23sample_trees(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":91 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":103 * del hypos * * def sample_trees(self, unsigned n): # <<<<<<<<<<<<<< + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" * cdef vector[string]* trees = new vector[string]() - * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_22sample_trees(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, unsigned int __pyx_v_n) { @@ -10110,7 +10177,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_22sample_trees(struct __pyx_obj_5_ __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __pyx_cur_scope->__pyx_v_n = __pyx_v_n; { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_24generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_24generator8, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -10132,10 +10199,11 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject { struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)__pyx_generator->closure); PyObject *__pyx_r = NULL; - size_t __pyx_t_1; - unsigned int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; + std::vector *__pyx_t_1; + size_t __pyx_t_2; + unsigned int __pyx_t_3; PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_5 = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("None", 0); switch (__pyx_generator->resume_label) { @@ -10146,19 +10214,20 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":92 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":105 * def sample_trees(self, unsigned n): + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" * cdef vector[string]* trees = new vector[string]() # <<<<<<<<<<<<<< * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) * cdef unsigned k */ - __pyx_cur_scope->__pyx_v_trees = new std::vector(); + try {__pyx_t_1 = new std::vector();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_cur_scope->__pyx_v_trees = __pyx_t_1; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":93 - * def sample_trees(self, unsigned n): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":106 + * """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" * cdef vector[string]* trees = new vector[string]() * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) # <<<<<<<<<<<<<< * cdef unsigned k @@ -10166,7 +10235,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject */ HypergraphSampler::sample_trees((__pyx_cur_scope->__pyx_v_self->hg[0]), __pyx_cur_scope->__pyx_v_n, ((struct __pyx_vtabstruct_5_cdec_Hypergraph *)__pyx_cur_scope->__pyx_v_self->__pyx_vtab)->_rng(__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_trees); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":95 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":108 * hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) * cdef unsigned k * try: # <<<<<<<<<<<<<< @@ -10175,54 +10244,54 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject */ /*try:*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":96 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":109 * cdef unsigned k * try: * for k in range(trees.size()): # <<<<<<<<<<<<<< * yield unicode(trees[0][k].c_str(), 'utf8') * finally: */ - __pyx_t_1 = __pyx_cur_scope->__pyx_v_trees->size(); - for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { - __pyx_cur_scope->__pyx_v_k = __pyx_t_2; + __pyx_t_2 = __pyx_cur_scope->__pyx_v_trees->size(); + for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { + __pyx_cur_scope->__pyx_v_k = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":97 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":110 * try: * for k in range(trees.size()): * yield unicode(trees[0][k].c_str(), 'utf8') # <<<<<<<<<<<<<< * finally: * del trees */ - __pyx_t_3 = PyBytes_FromString(((__pyx_cur_scope->__pyx_v_trees[0])[__pyx_cur_scope->__pyx_v_k]).c_str()); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); + __pyx_t_4 = PyBytes_FromString(((__pyx_cur_scope->__pyx_v_trees[0])[__pyx_cur_scope->__pyx_v_k]).c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(((PyObject *)__pyx_t_4)); + __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_5); + PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__utf8)); + PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L5;} - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - __pyx_cur_scope->__pyx_t_0 = __pyx_t_1; - __pyx_cur_scope->__pyx_t_1 = __pyx_t_2; + __pyx_t_4 = 0; + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} + __Pyx_GOTREF(__pyx_t_4); + __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; + __pyx_r = __pyx_t_4; + __pyx_t_4 = 0; + __pyx_cur_scope->__pyx_t_0 = __pyx_t_2; + __pyx_cur_scope->__pyx_t_1 = __pyx_t_3; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L9_resume_from_yield:; - __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; - __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L5;} + __pyx_t_2 = __pyx_cur_scope->__pyx_t_0; + __pyx_t_3 = __pyx_cur_scope->__pyx_t_1; + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L5;} } } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":99 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":112 * yield unicode(trees[0][k].c_str(), 'utf8') * finally: * del trees # <<<<<<<<<<<<<< @@ -10237,8 +10306,8 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject __pyx_why = 0; goto __pyx_L6; __pyx_L5: { __pyx_why = 4; + __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); __pyx_exc_lineno = __pyx_lineno; goto __pyx_L6; @@ -10259,8 +10328,8 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("sample_trees", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); @@ -10272,6 +10341,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_24generator8(__pyx_GeneratorObject /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_inp); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_25intersect[] = "hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self, PyObject *__pyx_v_inp) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -10281,12 +10351,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_26intersect(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":101 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":114 * del trees * * def intersect(self, inp): # <<<<<<<<<<<<<< + * """hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference.""" * cdef Lattice lat - * if isinstance(inp, Lattice): */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_inp) { @@ -10301,8 +10371,8 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("intersect", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":103 - * def intersect(self, inp): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":117 + * """hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference.""" * cdef Lattice lat * if isinstance(inp, Lattice): # <<<<<<<<<<<<<< * lat = inp @@ -10314,7 +10384,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":104 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":118 * cdef Lattice lat * if isinstance(inp, Lattice): * lat = inp # <<<<<<<<<<<<<< @@ -10326,7 +10396,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":105 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":119 * if isinstance(inp, Lattice): * lat = inp * elif isinstance(inp, basestring): # <<<<<<<<<<<<<< @@ -10335,23 +10405,23 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde */ __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_IsInstance(__pyx_v_inp, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_IsInstance(__pyx_v_inp, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":106 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":120 * lat = inp * elif isinstance(inp, basestring): * lat = Lattice(inp) # <<<<<<<<<<<<<< * else: * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_inp); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_inp); __Pyx_GIVEREF(__pyx_v_inp); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_v_lat = ((struct __pyx_obj_5_cdec_Lattice *)__pyx_t_3); @@ -10360,30 +10430,30 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":122 * lat = Lattice(inp) * else: * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) # <<<<<<<<<<<<<< * return hypergraph.Intersect(lat.lattice[0], self.hg) * */ - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3)); __Pyx_GIVEREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __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[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":109 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":123 * else: * raise TypeError('cannot intersect hypergraph with %s' % type(inp)) * return hypergraph.Intersect(lat.lattice[0], self.hg) # <<<<<<<<<<<<<< @@ -10391,7 +10461,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde * def prune(self, beam_alpha=0, density=0, **kwargs): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyBool_FromLong(HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_PyBool_FromLong(HG::Intersect((__pyx_v_lat->lattice[0]), __pyx_v_self->hg)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -10413,6 +10483,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_25intersect(struct __pyx_obj_5_cde /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_27prune[] = "hg.prune(beam_alpha=0, density=0): Prune the hypergraph.\n beam_alpha: use beam pruning\n density: use density pruning"; static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_beam_alpha = 0; PyObject *__pyx_v_density = 0; @@ -10450,7 +10521,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, Py } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "prune") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "prune") < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -10465,7 +10536,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, Py } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("prune", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("prune", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0; __Pyx_AddTraceback("_cdec.Hypergraph.prune", __pyx_clineno, __pyx_lineno, __pyx_filename); @@ -10478,12 +10549,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_28prune(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":111 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":125 * return hypergraph.Intersect(lat.lattice[0], self.hg) * * def prune(self, beam_alpha=0, density=0, **kwargs): # <<<<<<<<<<<<<< - * cdef hypergraph.EdgeMask* preserve_mask = NULL - * if 'csplit_preserve_full_word' in kwargs: + * """hg.prune(beam_alpha=0, density=0): Prune the hypergraph. + * beam_alpha: use beam pruning */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_beam_alpha, PyObject *__pyx_v_density, PyObject *__pyx_v_kwargs) { @@ -10498,26 +10569,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy int __pyx_clineno = 0; __Pyx_RefNannySetupContext("prune", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":112 - * - * def prune(self, beam_alpha=0, density=0, **kwargs): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":129 + * beam_alpha: use beam pruning + * density: use density pruning""" * cdef hypergraph.EdgeMask* preserve_mask = NULL # <<<<<<<<<<<<<< * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) */ __pyx_v_preserve_mask = NULL; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":113 - * def prune(self, beam_alpha=0, density=0, **kwargs): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":130 + * density: use density pruning""" * cdef hypergraph.EdgeMask* preserve_mask = NULL * if 'csplit_preserve_full_word' in kwargs: # <<<<<<<<<<<<<< * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True */ - __pyx_t_1 = ((PyDict_Contains(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s_16)))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s_16), ((PyObject *)__pyx_v_kwargs), Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":114 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":131 * cdef hypergraph.EdgeMask* preserve_mask = NULL * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) # <<<<<<<<<<<<<< @@ -10526,7 +10597,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy */ __pyx_v_preserve_mask = new std::vector(__pyx_v_self->hg->edges_.size()); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":115 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":132 * if 'csplit_preserve_full_word' in kwargs: * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True # <<<<<<<<<<<<<< @@ -10538,18 +10609,18 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":116 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":133 * preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) # <<<<<<<<<<<<<< * if preserve_mask: * del preserve_mask */ - __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_beam_alpha); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_density); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_beam_alpha); if (unlikely((__pyx_t_2 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_density); if (unlikely((__pyx_t_3 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->hg->PruneInsideOutside(__pyx_t_2, __pyx_t_3, __pyx_v_preserve_mask, 0, 1.0, 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":117 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":134 * preserve_mask[0][hypergraph.GetFullWordEdgeIndex(self.hg[0])] = True * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) * if preserve_mask: # <<<<<<<<<<<<<< @@ -10559,7 +10630,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy __pyx_t_1 = (__pyx_v_preserve_mask != 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":118 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":135 * self.hg.PruneInsideOutside(beam_alpha, density, preserve_mask, False, 1, False) * if preserve_mask: * del preserve_mask # <<<<<<<<<<<<<< @@ -10584,6 +10655,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_27prune(struct __pyx_obj_5_cdec_Hy /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_30lattice(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_29lattice[] = "hg.lattice() -> Lattice corresponding to the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_30lattice(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -10593,12 +10665,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_30lattice(PyObject *__pyx_v_self, return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":120 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":137 * del preserve_mask * * def lattice(self): # TODO direct hg -> lattice conversion in cdec # <<<<<<<<<<<<<< + * """hg.lattice() -> Lattice corresponding to the hypergraph.""" * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() - * return Lattice(eval(plf)) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -10613,37 +10685,37 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("lattice", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":121 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":139 * def lattice(self): # TODO direct hg -> lattice conversion in cdec + * """hg.lattice() -> Lattice corresponding to the hypergraph.""" * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() # <<<<<<<<<<<<<< * return Lattice(eval(plf)) * */ - __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); __pyx_v_plf = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":122 - * def lattice(self): # TODO direct hg -> lattice conversion in cdec + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":140 + * """hg.lattice() -> Lattice corresponding to the hypergraph.""" * cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() * return Lattice(eval(plf)) # <<<<<<<<<<<<<< * * def plf(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_Globals(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); if (((PyObject *)__pyx_v_plf)) { - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__plf), ((PyObject *)__pyx_v_plf)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__plf), ((PyObject *)__pyx_v_plf)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } if (((PyObject *)__pyx_v_self)) { - if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_v_self)) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(((PyObject *)__pyx_v_plf)); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_plf)); @@ -10654,15 +10726,15 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_ __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_1 = 0; __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_builtin_eval, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Lattice)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -10686,6 +10758,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_29lattice(struct __pyx_obj_5_cdec_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_31plf[] = "hg.plf() -> Lattice PLF representation corresponding to the hypergraph."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -10695,12 +10768,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_32plf(PyObject *__pyx_v_self, CYTH return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":124 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":142 * return Lattice(eval(plf)) * * def plf(self): # <<<<<<<<<<<<<< + * """hg.plf() -> Lattice PLF representation corresponding to the hypergraph.""" * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) - * */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -10713,22 +10786,22 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hype int __pyx_clineno = 0; __Pyx_RefNannySetupContext("plf", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":125 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":144 * def plf(self): + * """hg.plf() -> Lattice PLF representation corresponding to the hypergraph.""" * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) # <<<<<<<<<<<<<< * * def reweight(self, weights): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->hg[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -10750,6 +10823,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_31plf(struct __pyx_obj_5_cdec_Hype /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_33reweight[] = "hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -10759,12 +10833,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_34reweight(PyObject *__pyx_v_self, return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":127 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":146 * return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) * * def reweight(self, weights): # <<<<<<<<<<<<<< + * """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" * if isinstance(weights, SparseVector): - * self.hg.Reweight(( weights).vector[0]) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self, PyObject *__pyx_v_weights) { @@ -10778,9 +10852,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec int __pyx_clineno = 0; __Pyx_RefNannySetupContext("reweight", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":128 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":148 * def reweight(self, weights): + * """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" * if isinstance(weights, SparseVector): # <<<<<<<<<<<<<< * self.hg.Reweight(( weights).vector[0]) * elif isinstance(weights, DenseVector): @@ -10791,8 +10865,8 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":129 - * def reweight(self, weights): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":149 + * """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" * if isinstance(weights, SparseVector): * self.hg.Reweight(( weights).vector[0]) # <<<<<<<<<<<<<< * elif isinstance(weights, DenseVector): @@ -10802,7 +10876,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":130 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":150 * if isinstance(weights, SparseVector): * self.hg.Reweight(( weights).vector[0]) * elif isinstance(weights, DenseVector): # <<<<<<<<<<<<<< @@ -10815,7 +10889,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":131 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":151 * self.hg.Reweight(( weights).vector[0]) * elif isinstance(weights, DenseVector): * self.hg.Reweight(( weights).vector[0]) # <<<<<<<<<<<<<< @@ -10827,26 +10901,26 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_33reweight(struct __pyx_obj_5_cdec } /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":133 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":153 * self.hg.Reweight(( weights).vector[0]) * else: * raise TypeError('cannot reweight hypergraph with %s' % type(weights)) # <<<<<<<<<<<<<< * * property edges: */ - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -10875,7 +10949,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5edges_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":136 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":156 * * property edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -10901,7 +10975,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5edges___get__(struct __pyx_obj_5_ __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5edges_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5edges_2generator9, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -10937,9 +11011,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_Generator return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":138 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":158 * def __get__(self): * cdef unsigned i * for i in range(self.hg.edges_.size()): # <<<<<<<<<<<<<< @@ -10950,16 +11024,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_Generator for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":139 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":159 * cdef unsigned i * for i in range(self.hg.edges_.size()): * yield HypergraphEdge().init(self.hg, i) # <<<<<<<<<<<<<< * * property nodes: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -10974,7 +11048,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5edges_2generator9(__pyx_Generator __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11002,7 +11076,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_5nodes_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":142 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":162 * * property nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -11028,7 +11102,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_5nodes___get__(struct __pyx_obj_5_ __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -11064,9 +11138,9 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_Generato return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":144 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":164 * def __get__(self): * cdef unsigned i * for i in range(self.hg.nodes_.size()): # <<<<<<<<<<<<<< @@ -11077,16 +11151,16 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_Generato for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":145 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":165 * cdef unsigned i * for i in range(self.hg.nodes_.size()): * yield HypergraphNode().init(self.hg, i) # <<<<<<<<<<<<<< * * property goal: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, __pyx_cur_scope->__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -11101,7 +11175,7 @@ static PyObject *__pyx_gb_5_cdec_10Hypergraph_5nodes_2generator10(__pyx_Generato __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11128,7 +11202,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_4goal_1__get__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":148 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":168 * * property goal: * def __get__(self): # <<<<<<<<<<<<<< @@ -11146,7 +11220,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_c int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":149 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":169 * property goal: * def __get__(self): * return HypergraphNode().init(self.hg, self.hg.GoalNode()) # <<<<<<<<<<<<<< @@ -11154,9 +11228,9 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_4goal___get__(struct __pyx_obj_5_c * property npaths: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->hg->GoalNode()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->hg->GoalNode()); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -11187,7 +11261,7 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_6npaths_1__get__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":152 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":172 * * property npaths: * def __get__(self): # <<<<<<<<<<<<<< @@ -11204,7 +11278,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":153 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":173 * property npaths: * def __get__(self): * return self.hg.NumberOfPaths() # <<<<<<<<<<<<<< @@ -11212,7 +11286,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 * def inside_outside(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->hg->NumberOfPaths()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->hg->NumberOfPaths()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11232,6 +11306,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_6npaths___get__(struct __pyx_obj_5 /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_10Hypergraph_35inside_outside[] = "hg.inside_outside() -> SparseVector with inside-outside scores for each feature."; static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -11241,12 +11316,12 @@ static PyObject *__pyx_pw_5_cdec_10Hypergraph_36inside_outside(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":155 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":175 * return self.hg.NumberOfPaths() * * def inside_outside(self): # <<<<<<<<<<<<<< + * """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() - * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) */ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_self) { @@ -11265,17 +11340,17 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("inside_outside", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":156 - * + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":177 * def inside_outside(self): + * """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() # <<<<<<<<<<<<<< * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z */ __pyx_v_result = new FastSparseVector(); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":157 - * def inside_outside(self): + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":178 + * """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) # <<<<<<<<<<<<<< * result[0] /= z @@ -11283,7 +11358,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ __pyx_v_z = InsideOutside, EdgeFeaturesAndProbWeightFunction>((__pyx_v_self->hg[0]), __pyx_v_result); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":158 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":179 * cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z # <<<<<<<<<<<<<< @@ -11292,20 +11367,20 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ (__pyx_v_result[0]) /= __pyx_v_z; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":159 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":180 * cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) * result[0] /= z * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * vector.vector = new FastSparseVector[double]() * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":160 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":181 * result[0] /= z * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double]() # <<<<<<<<<<<<<< @@ -11314,7 +11389,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ __pyx_v_vector->vector = new FastSparseVector(); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":161 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":182 * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double]() * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) # <<<<<<<<<<<<<< @@ -11323,7 +11398,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ __pyx_v_it = new FastSparseVector::const_iterator((__pyx_v_result[0]), 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":163 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":184 * cdef FastSparseVector[prob_t].const_iterator* it = new FastSparseVector[prob_t].const_iterator(result[0], False) * cdef unsigned i * for i in range(result.size()): # <<<<<<<<<<<<<< @@ -11334,7 +11409,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":164 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":185 * cdef unsigned i * for i in range(result.size()): * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) # <<<<<<<<<<<<<< @@ -11343,7 +11418,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ __pyx_v_vector->vector->set_value((__pyx_v_it[0]).operator->()->first, log((__pyx_v_it[0]).operator->()->second)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":165 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":186 * for i in range(result.size()): * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) * pinc(it[0]) # ++it # <<<<<<<<<<<<<< @@ -11353,7 +11428,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ (++(__pyx_v_it[0])); } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":166 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":187 * vector.vector.set_value(it[0].ptr().first, log(it[0].ptr().second)) * pinc(it[0]) # ++it * del it # <<<<<<<<<<<<<< @@ -11362,7 +11437,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ delete __pyx_v_it; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":167 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":188 * pinc(it[0]) # ++it * del it * del result # <<<<<<<<<<<<<< @@ -11371,7 +11446,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ */ delete __pyx_v_result; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":168 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":189 * del it * del result * return vector # <<<<<<<<<<<<<< @@ -11396,7 +11471,7 @@ static PyObject *__pyx_pf_5_cdec_10Hypergraph_35inside_outside(struct __pyx_obj_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":175 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":196 * cdef public TRule trule * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<< @@ -11413,7 +11488,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy int __pyx_clineno = 0; __Pyx_RefNannySetupContext("init", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":176 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":197 * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg # <<<<<<<<<<<<<< @@ -11422,7 +11497,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->hg = __pyx_v_hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":177 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":198 * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg * self.edge = &hg.edges_[i] # <<<<<<<<<<<<<< @@ -11431,23 +11506,23 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->edge = (&(__pyx_v_hg->edges_[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":178 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":199 * self.hg = hg * self.edge = &hg.edges_[i] * self.trule = TRule.__new__(TRule) # <<<<<<<<<<<<<< * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) * return self */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_TRule)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_TRule)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->trule); __Pyx_DECREF(((PyObject *)__pyx_v_self->trule)); __pyx_v_self->trule = ((struct __pyx_obj_5_cdec_TRule *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":179 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":200 * self.edge = &hg.edges_[i] * self.trule = TRule.__new__(TRule) * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) # <<<<<<<<<<<<<< @@ -11456,7 +11531,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphEdge_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->trule->rule = new boost::shared_ptr(__pyx_v_self->edge->rule_); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":180 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":201 * self.trule = TRule.__new__(TRule) * self.trule.rule = new shared_ptr[grammar.TRule](self.edge.rule_) * return self # <<<<<<<<<<<<<< @@ -11491,7 +11566,7 @@ static Py_ssize_t __pyx_pw_5_cdec_14HypergraphEdge_1__len__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":182 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":203 * return self * * def __len__(self): # <<<<<<<<<<<<<< @@ -11504,7 +11579,7 @@ static Py_ssize_t __pyx_pf_5_cdec_14HypergraphEdge___len__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":183 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":204 * * def __len__(self): * return self.edge.tail_nodes_.size() # <<<<<<<<<<<<<< @@ -11531,7 +11606,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_9head_node_1__get__(PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":186 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":207 * * property head_node: * def __get__(self): # <<<<<<<<<<<<<< @@ -11549,7 +11624,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":187 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":208 * property head_node: * def __get__(self): * return HypergraphNode().init(self.hg, self.edge.head_node_) # <<<<<<<<<<<<<< @@ -11557,9 +11632,9 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_9head_node___get__(struct __py * property tail_nodes: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->edge->head_node_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_1), __pyx_v_self->hg, __pyx_v_self->edge->head_node_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -11591,7 +11666,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_10tail_nodes_1__get__(PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":190 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":211 * * property tail_nodes: * def __get__(self): # <<<<<<<<<<<<<< @@ -11617,7 +11692,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_10tail_nodes___get__(struct __ __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -11653,9 +11728,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__py return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":192 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":213 * def __get__(self): * cdef unsigned i * for i in range(self.edge.tail_nodes_.size()): # <<<<<<<<<<<<<< @@ -11666,16 +11741,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__py for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":193 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":214 * cdef unsigned i * for i in range(self.edge.tail_nodes_.size()): * yield HypergraphNode().init(self.hg, self.edge.tail_nodes_[i]) # <<<<<<<<<<<<<< * * property span: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphNode)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->edge->tail_nodes_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphNode *)((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->edge->tail_nodes_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -11690,7 +11765,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphEdge_10tail_nodes_2generator11(__py __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -11717,7 +11792,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4span_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":196 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":217 * * property span: * def __get__(self): # <<<<<<<<<<<<<< @@ -11736,7 +11811,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":197 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":218 * property span: * def __get__(self): * return (self.edge.i_, self.edge.j_) # <<<<<<<<<<<<<< @@ -11744,11 +11819,11 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4span___get__(struct __pyx_obj * property feature_values: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyInt_FromLong(__pyx_v_self->edge->i_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyInt_FromLong(__pyx_v_self->edge->i_); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyInt_FromLong(__pyx_v_self->edge->j_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyInt_FromLong(__pyx_v_self->edge->j_); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 218; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); @@ -11785,7 +11860,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_14feature_values_1__get__(PyOb return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":200 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":221 * * property feature_values: * def __get__(self): # <<<<<<<<<<<<<< @@ -11803,20 +11878,20 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":201 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":222 * property feature_values: * def __get__(self): * cdef SparseVector vector = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< * vector.vector = new FastSparseVector[double](self.edge.feature_values_) * return vector */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_SparseVector)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_SparseVector)))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_vector = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":202 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":223 * def __get__(self): * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double](self.edge.feature_values_) # <<<<<<<<<<<<<< @@ -11825,7 +11900,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_14feature_values___get__(struc */ __pyx_v_vector->vector = new FastSparseVector(__pyx_v_self->edge->feature_values_); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":203 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":224 * cdef SparseVector vector = SparseVector.__new__(SparseVector) * vector.vector = new FastSparseVector[double](self.edge.feature_values_) * return vector # <<<<<<<<<<<<<< @@ -11861,7 +11936,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_4prob_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":206 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":227 * * property prob: * def __get__(self): # <<<<<<<<<<<<<< @@ -11878,7 +11953,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":207 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":228 * property prob: * def __get__(self): * return self.edge.edge_prob_.as_float() # <<<<<<<<<<<<<< @@ -11886,7 +11961,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_4prob___get__(struct __pyx_obj * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->edge->edge_prob_.as_float()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(__pyx_v_self->edge->edge_prob_.as_float()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -11910,8 +11985,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphEdge, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphEdge, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphEdge, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphEdge, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_x), ((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_v_y), ((int)__pyx_v_op)); goto __pyx_L0; __pyx_L1_error:; @@ -11921,7 +11996,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_3__richcmp__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":209 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":230 * return self.edge.edge_prob_.as_float() * * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): # <<<<<<<<<<<<<< @@ -11939,7 +12014,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":212 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":233 * if op == 2: # == * return x.edge == y.edge * elif op == 3: # != # <<<<<<<<<<<<<< @@ -11948,7 +12023,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":210 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":231 * * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -11957,7 +12032,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":211 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":232 * def __richcmp__(HypergraphEdge x, HypergraphEdge y, int op): * if op == 2: # == * return x.edge == y.edge # <<<<<<<<<<<<<< @@ -11965,14 +12040,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->edge == __pyx_v_y->edge)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->edge == __pyx_v_y->edge)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; break; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":212 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":233 * if op == 2: # == * return x.edge == y.edge * elif op == 3: # != # <<<<<<<<<<<<<< @@ -11981,7 +12056,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":213 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":234 * return x.edge == y.edge * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< @@ -11989,11 +12064,10 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ * */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -12001,18 +12075,18 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphEdge_2__richcmp__(struct __pyx_obj_ break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":214 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":235 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<< * * cdef class HypergraphNode: */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_19), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -12037,7 +12111,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphEdge_5trule_1__get__(PyObject *__py return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":173 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":194 * cdef hypergraph.Hypergraph* hg * cdef hypergraph.HypergraphEdge* edge * cdef public TRule trule # <<<<<<<<<<<<<< @@ -12079,7 +12153,7 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_2__set__(struct __pyx_obj_5_c const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5_cdec_TRule))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5_cdec_TRule))))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_INCREF(__pyx_v_value); __Pyx_GIVEREF(__pyx_v_value); __Pyx_GOTREF(__pyx_v_self->trule); @@ -12122,7 +12196,7 @@ static int __pyx_pf_5_cdec_14HypergraphEdge_5trule_4__del__(struct __pyx_obj_5_c return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":220 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":241 * cdef hypergraph.HypergraphNode* node * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): # <<<<<<<<<<<<<< @@ -12135,7 +12209,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("init", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":221 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":242 * * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg # <<<<<<<<<<<<<< @@ -12144,7 +12218,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->hg = __pyx_v_hg; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":222 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":243 * cdef init(self, hypergraph.Hypergraph* hg, unsigned i): * self.hg = hg * self.node = &hg.nodes_[i] # <<<<<<<<<<<<<< @@ -12153,7 +12227,7 @@ static PyObject *__pyx_f_5_cdec_14HypergraphNode_init(struct __pyx_obj_5_cdec_Hy */ __pyx_v_self->node = (&(__pyx_v_hg->nodes_[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":223 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":244 * self.hg = hg * self.node = &hg.nodes_[i] * return self # <<<<<<<<<<<<<< @@ -12184,7 +12258,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_8in_edges_1__get__(PyObject *_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":226 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":247 * * property in_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -12210,7 +12284,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_8in_edges___get__(struct __pyx __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -12246,9 +12320,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_G return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":228 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":249 * def __get__(self): * cdef unsigned i * for i in range(self.node.in_edges_.size()): # <<<<<<<<<<<<<< @@ -12259,16 +12333,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_G for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":229 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":250 * cdef unsigned i * for i in range(self.node.in_edges_.size()): * yield HypergraphEdge().init(self.hg, self.node.in_edges_[i]) # <<<<<<<<<<<<<< * * property out_edges: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->in_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->in_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -12283,7 +12357,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_8in_edges_2generator12(__pyx_G __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -12311,7 +12385,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_9out_edges_1__get__(PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":232 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":253 * * property out_edges: * def __get__(self): # <<<<<<<<<<<<<< @@ -12337,7 +12411,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_9out_edges___get__(struct __py __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -12373,9 +12447,9 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":234 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":255 * def __get__(self): * cdef unsigned i * for i in range(self.node.out_edges_.size()): # <<<<<<<<<<<<<< @@ -12386,16 +12460,16 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":235 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":256 * cdef unsigned i * for i in range(self.node.out_edges_.size()): * yield HypergraphEdge().init(self.hg, self.node.out_edges_[i]) # <<<<<<<<<<<<<< * * property span: */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_HypergraphEdge)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->out_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = ((struct __pyx_vtabstruct_5_cdec_HypergraphEdge *)((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3)->__pyx_vtab)->init(((struct __pyx_obj_5_cdec_HypergraphEdge *)__pyx_t_3), __pyx_cur_scope->__pyx_v_self->hg, (__pyx_cur_scope->__pyx_v_self->node->out_edges_[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_4; @@ -12410,7 +12484,7 @@ static PyObject *__pyx_gb_5_cdec_14HypergraphNode_9out_edges_2generator13(__pyx_ __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 256; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -12437,7 +12511,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_4span_1__get__(PyObject *__pyx return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":238 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":259 * * property span: * def __get__(self): # <<<<<<<<<<<<<< @@ -12455,7 +12529,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":239 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":260 * property span: * def __get__(self): * return next(self.in_edges).span # <<<<<<<<<<<<<< @@ -12463,12 +12537,12 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_4span___get__(struct __pyx_obj * property cat: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__in_edges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__in_edges); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyIter_Next(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__span); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__span); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -12499,7 +12573,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_3cat_1__get__(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":242 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":263 * * property cat: * def __get__(self): # <<<<<<<<<<<<<< @@ -12517,7 +12591,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":243 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":264 * property cat: * def __get__(self): * if self.node.cat_: # <<<<<<<<<<<<<< @@ -12526,7 +12600,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ */ if (__pyx_v_self->node->cat_) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":244 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":265 * def __get__(self): * if self.node.cat_: * return str(TDConvert(-self.node.cat_).c_str()) # <<<<<<<<<<<<<< @@ -12534,14 +12608,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode_3cat___get__(struct __pyx_obj_ * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->node->cat_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(TD::Convert((-__pyx_v_self->node->cat_)).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 265; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -12570,8 +12644,8 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphNode, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphNode, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 246; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_x), __pyx_ptype_5_cdec_HypergraphNode, 1, "x", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_y), __pyx_ptype_5_cdec_HypergraphNode, 1, "y", 0))) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_14HypergraphNode___richcmp__(((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_x), ((struct __pyx_obj_5_cdec_HypergraphNode *)__pyx_v_y), ((int)__pyx_v_op)); goto __pyx_L0; __pyx_L1_error:; @@ -12581,7 +12655,7 @@ static PyObject *__pyx_pw_5_cdec_14HypergraphNode_1__richcmp__(PyObject *__pyx_v return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":246 +/* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":267 * return str(TDConvert(-self.node.cat_).c_str()) * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): # <<<<<<<<<<<<<< @@ -12599,7 +12673,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__richcmp__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":249 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":270 * if op == 2: # == * return x.node == y.node * elif op == 3: # != # <<<<<<<<<<<<<< @@ -12608,7 +12682,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ switch (__pyx_v_op) { - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":247 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":268 * * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): * if op == 2: # == # <<<<<<<<<<<<<< @@ -12617,7 +12691,7 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ case 2: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":248 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":269 * def __richcmp__(HypergraphNode x, HypergraphNode y, int op): * if op == 2: # == * return x.node == y.node # <<<<<<<<<<<<<< @@ -12625,14 +12699,14 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 * return not (x == y) */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->node == __pyx_v_y->node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_x->node == __pyx_v_y->node)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; break; - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":249 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":270 * if op == 2: # == * return x.node == y.node * elif op == 3: # != # <<<<<<<<<<<<<< @@ -12641,18 +12715,17 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 */ case 3: - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":250 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":271 * return x.node == y.node * elif op == 3: # != * return not (x == y) # <<<<<<<<<<<<<< * raise NotImplemented('comparison not implemented for HypergraphNode') */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_RichCompare(((PyObject *)__pyx_v_x), ((PyObject *)__pyx_v_y), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 250; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; @@ -12660,16 +12733,16 @@ static PyObject *__pyx_pf_5_cdec_14HypergraphNode___richcmp__(struct __pyx_obj_5 break; } - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":251 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":272 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphNode') # <<<<<<<<<<<<<< */ - __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplemented, ((PyObject *)__pyx_k_tuple_21), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[3]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; @@ -12697,7 +12770,7 @@ static int __pyx_pw_5_cdec_7Lattice_1__cinit__(PyObject *__pyx_v_self, PyObject return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":6 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":6 * cdef lattice.Lattice* lattice * * def __cinit__(self): # <<<<<<<<<<<<<< @@ -12710,7 +12783,7 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":7 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":7 * * def __cinit__(self): * self.lattice = new lattice.Lattice() # <<<<<<<<<<<<<< @@ -12726,6 +12799,10 @@ static int __pyx_pf_5_cdec_7Lattice___cinit__(struct __pyx_obj_5_cdec_Lattice *_ /* Python wrapper */ static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_7Lattice_2__init__[] = "Lattice(tuple) -> Lattice from node list.\n Lattice(string) -> Lattice from PLF representation."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_7Lattice_2__init__; +#endif static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_inp = 0; int __pyx_r; @@ -12771,12 +12848,12 @@ static int __pyx_pw_5_cdec_7Lattice_3__init__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":9 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":9 * self.lattice = new lattice.Lattice() * * def __init__(self, inp): # <<<<<<<<<<<<<< - * if isinstance(inp, tuple): - * self.lattice.resize(len(inp)) + * """Lattice(tuple) -> Lattice from node list. + * Lattice(string) -> Lattice from PLF representation.""" */ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self, PyObject *__pyx_v_inp) { @@ -12790,17 +12867,15 @@ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *_ PyObject *__pyx_t_4 = NULL; PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - char *__pyx_t_8; + std::string __pyx_t_7; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__init__", 0); - __Pyx_INCREF(__pyx_v_inp); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":10 - * - * def __init__(self, inp): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":12 + * """Lattice(tuple) -> Lattice from node list. + * Lattice(string) -> Lattice from PLF representation.""" * if isinstance(inp, tuple): # <<<<<<<<<<<<<< * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): @@ -12811,22 +12886,22 @@ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":11 - * def __init__(self, inp): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":13 + * Lattice(string) -> Lattice from PLF representation.""" * if isinstance(inp, tuple): * self.lattice.resize(len(inp)) # <<<<<<<<<<<<<< * for i, arcs in enumerate(inp): * self[i] = arcs */ - __pyx_t_3 = PyObject_Length(__pyx_v_inp); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Length(__pyx_v_inp); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_self->lattice->resize(__pyx_t_3); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":12 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":14 * if isinstance(inp, tuple): * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): # <<<<<<<<<<<<<< * self[i] = arcs - * else: + * elif isinstance(inp, basestring): */ __Pyx_INCREF(__pyx_int_0); __pyx_t_1 = __pyx_int_0; @@ -12834,7 +12909,7 @@ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *_ __pyx_t_4 = __pyx_v_inp; __Pyx_INCREF(__pyx_t_4); __pyx_t_3 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_inp); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = Py_TYPE(__pyx_t_4)->tp_iternext; } @@ -12842,23 +12917,23 @@ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *_ if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_4)) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_4)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_4, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_5(__pyx_t_4); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -12870,106 +12945,75 @@ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *_ __Pyx_INCREF(__pyx_t_1); __Pyx_XDECREF(__pyx_v_i); __pyx_v_i = __pyx_t_1; - __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyNumber_Add(__pyx_t_1, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = __pyx_t_6; __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":13 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":15 * self.lattice.resize(len(inp)) * for i, arcs in enumerate(inp): * self[i] = arcs # <<<<<<<<<<<<<< - * else: - * if isinstance(inp, unicode): + * elif isinstance(inp, basestring): + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) */ - if (PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_i, __pyx_v_arcs) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetItem(((PyObject *)__pyx_v_self), __pyx_v_i, __pyx_v_arcs) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } - /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":15 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":16 + * for i, arcs in enumerate(inp): * self[i] = arcs + * elif isinstance(inp, basestring): # <<<<<<<<<<<<<< + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) * else: - * if isinstance(inp, unicode): # <<<<<<<<<<<<<< - * inp = inp.encode('utf8') - * if not isinstance(inp, str): */ - __pyx_t_1 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_inp, __pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_2) { + __pyx_t_1 = __pyx_builtin_basestring; + __Pyx_INCREF(__pyx_t_1); + __pyx_t_2 = PyObject_IsInstance(__pyx_v_inp, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":16 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":17 + * self[i] = arcs + * elif isinstance(inp, basestring): + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) # <<<<<<<<<<<<<< * else: - * if isinstance(inp, unicode): - * inp = inp.encode('utf8') # <<<<<<<<<<<<<< - * if not isinstance(inp, str): - * raise TypeError('cannot create lattice from %s' % type(inp)) - */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_inp, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_v_inp); - __pyx_v_inp = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L6; - } - __pyx_L6:; - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":17 - * if isinstance(inp, unicode): - * inp = inp.encode('utf8') - * if not isinstance(inp, str): # <<<<<<<<<<<<<< - * raise TypeError('cannot create lattice from %s' % type(inp)) - * lattice.ConvertTextOrPLF(string(inp), self.lattice) - */ - __pyx_t_4 = ((PyObject *)((PyObject*)(&PyString_Type))); - __Pyx_INCREF(__pyx_t_4); - __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_inp, __pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_7 = (!__pyx_t_2); - if (__pyx_t_7) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":18 - * inp = inp.encode('utf8') - * if not isinstance(inp, str): - * raise TypeError('cannot create lattice from %s' % type(inp)) # <<<<<<<<<<<<<< - * lattice.ConvertTextOrPLF(string(inp), self.lattice) - * + * raise TypeError('cannot create lattice from %s' % type(inp)) */ - __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_4)); - __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); - __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __Pyx_Raise(__pyx_t_4, 0, 0, 0); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - goto __pyx_L7; - } - __pyx_L7:; + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_inp, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + LatticeTools::ConvertTextOrPLF(__pyx_t_7, __pyx_v_self->lattice); + goto __pyx_L3; + } + /*else*/ { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":19 - * if not isinstance(inp, str): - * raise TypeError('cannot create lattice from %s' % type(inp)) - * lattice.ConvertTextOrPLF(string(inp), self.lattice) # <<<<<<<<<<<<<< + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":19 + * lattice.ConvertTextOrPLF(as_str(inp), self.lattice) + * else: + * raise TypeError('cannot create lattice from %s' % type(inp)) # <<<<<<<<<<<<<< * * def __dealloc__(self): */ - __pyx_t_8 = PyBytes_AsString(__pyx_v_inp); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - LatticeTools::ConvertTextOrPLF(std::string(((char *)__pyx_t_8)), __pyx_v_self->lattice); + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), ((PyObject *)Py_TYPE(__pyx_v_inp))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_4); + PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1)); + __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = 0; + __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); + __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; + __Pyx_Raise(__pyx_t_1, 0, 0, 0); + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -12984,7 +13028,6 @@ static int __pyx_pf_5_cdec_7Lattice_2__init__(struct __pyx_obj_5_cdec_Lattice *_ __pyx_L0:; __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_arcs); - __Pyx_XDECREF(__pyx_v_inp); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -12998,8 +13041,8 @@ static void __pyx_pw_5_cdec_7Lattice_5__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":21 - * lattice.ConvertTextOrPLF(string(inp), self.lattice) +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":21 + * raise TypeError('cannot create lattice from %s' % type(inp)) * * def __dealloc__(self): # <<<<<<<<<<<<<< * del self.lattice @@ -13010,7 +13053,7 @@ static void __pyx_pf_5_cdec_7Lattice_4__dealloc__(CYTHON_UNUSED struct __pyx_obj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":22 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":22 * * def __dealloc__(self): * del self.lattice # <<<<<<<<<<<<<< @@ -13043,7 +13086,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_7__getitem__(PyObject *__pyx_v_self, P return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":24 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":24 * del self.lattice * * def __getitem__(self, int index): # <<<<<<<<<<<<<< @@ -13073,7 +13116,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":25 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":25 * * def __getitem__(self, int index): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -13088,14 +13131,14 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":26 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_24), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -13104,7 +13147,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":27 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":27 * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') * arcs = [] # <<<<<<<<<<<<<< @@ -13116,7 +13159,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L __pyx_v_arcs = __pyx_t_4; __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":28 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":28 * raise IndexError('lattice index out of range') * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] # <<<<<<<<<<<<<< @@ -13125,7 +13168,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L */ __pyx_v_arc_vector = ((__pyx_v_self->lattice[0])[__pyx_v_index]); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":31 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":31 * cdef lattice.LatticeArc* arc * cdef unsigned i * for i in range(arc_vector.size()): # <<<<<<<<<<<<<< @@ -13136,7 +13179,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) { __pyx_v_i = __pyx_t_6; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":32 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":32 * cdef unsigned i * for i in range(arc_vector.size()): * arc = &arc_vector[i] # <<<<<<<<<<<<<< @@ -13145,7 +13188,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L */ __pyx_v_arc = (&(__pyx_v_arc_vector[__pyx_v_i])); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":33 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":33 * for i in range(arc_vector.size()): * arc = &arc_vector[i] * label = unicode(TDConvert(arc.label).c_str(), 'utf8') # <<<<<<<<<<<<<< @@ -13169,7 +13212,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L __pyx_v_label = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":34 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":34 * arc = &arc_vector[i] * label = unicode(TDConvert(arc.label).c_str(), 'utf8') * arcs.append((label, arc.cost, arc.dist2next)) # <<<<<<<<<<<<<< @@ -13195,7 +13238,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_6__getitem__(struct __pyx_obj_5_cdec_L __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":35 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":35 * label = unicode(TDConvert(arc.label).c_str(), 'utf8') * arcs.append((label, arc.cost, arc.dist2next)) * return tuple(arcs) # <<<<<<<<<<<<<< @@ -13251,7 +13294,7 @@ static int __pyx_pw_5_cdec_7Lattice_9__setitem__(PyObject *__pyx_v_self, PyObjec return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":37 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":37 * return tuple(arcs) * * def __setitem__(self, int index, tuple arcs): # <<<<<<<<<<<<<< @@ -13264,6 +13307,7 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice PyObject *__pyx_v_label = NULL; PyObject *__pyx_v_cost = NULL; PyObject *__pyx_v_dist2next = NULL; + PyObject *__pyx_v_label_str = NULL; int __pyx_r; __Pyx_RefNannyDeclarations int __pyx_t_1; @@ -13284,7 +13328,7 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__setitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":38 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":38 * * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -13299,14 +13343,14 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":39 * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_26), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -13315,12 +13359,12 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":41 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":41 * raise IndexError('lattice index out of range') * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: # <<<<<<<<<<<<<< - * if isinstance(label, unicode): - * label = label.encode('utf8') + * label_str = as_str(label) + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) */ if (unlikely(((PyObject *)__pyx_v_arcs) == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); @@ -13330,9 +13374,9 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice for (;;) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; + __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_5 = PySequence_ITEM(__pyx_t_4, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { PyObject* sequence = __pyx_t_5; @@ -13399,61 +13443,42 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice __pyx_v_dist2next = __pyx_t_8; __pyx_t_8 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":42 * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: - * if isinstance(label, unicode): # <<<<<<<<<<<<<< - * label = label.encode('utf8') - * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) - */ - __pyx_t_5 = ((PyObject *)((PyObject*)(&PyUnicode_Type))); - __Pyx_INCREF(__pyx_t_5); - __pyx_t_3 = __Pyx_TypeCheck(__pyx_v_label, __pyx_t_5); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if (__pyx_t_3) { - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43 - * for (label, cost, dist2next) in arcs: - * if isinstance(label, unicode): - * label = label.encode('utf8') # <<<<<<<<<<<<<< - * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) + * label_str = as_str(label) # <<<<<<<<<<<<<< + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) */ - __pyx_t_5 = PyObject_GetAttr(__pyx_v_label, __pyx_n_s__encode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_k_tuple_27), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_v_label); - __pyx_v_label = __pyx_t_8; - __pyx_t_8 = 0; - goto __pyx_L8; - } - __pyx_L8:; + __pyx_t_5 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_label, NULL)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_5); + __Pyx_XDECREF(((PyObject *)__pyx_v_label_str)); + __pyx_v_label_str = ((PyObject*)__pyx_t_5); + __pyx_t_5 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":44 - * if isinstance(label, unicode): - * label = label.encode('utf8') - * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) # <<<<<<<<<<<<<< + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":43 + * for (label, cost, dist2next) in arcs: + * label_str = as_str(label) + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) # <<<<<<<<<<<<<< * self.lattice[0][index].push_back(arc[0]) * del arc */ - __pyx_t_11 = PyBytes_AsString(__pyx_v_label); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_arc = new LatticeArc(TD::Convert(((char *)__pyx_t_11)), __pyx_t_12, __pyx_t_13); + __pyx_t_11 = PyBytes_AsString(((PyObject *)__pyx_v_label_str)); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = __pyx_PyFloat_AsDouble(__pyx_v_cost); if (unlikely((__pyx_t_12 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_v_dist2next); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_arc = new LatticeArc(TD::Convert(__pyx_t_11), __pyx_t_12, __pyx_t_13); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":45 - * label = label.encode('utf8') - * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":44 + * label_str = as_str(label) + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) # <<<<<<<<<<<<<< * del arc * */ ((__pyx_v_self->lattice[0])[__pyx_v_index]).push_back((__pyx_v_arc[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":46 - * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":45 + * arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) * self.lattice[0][index].push_back(arc[0]) * del arc # <<<<<<<<<<<<<< * @@ -13478,6 +13503,7 @@ static int __pyx_pf_5_cdec_7Lattice_8__setitem__(struct __pyx_obj_5_cdec_Lattice __Pyx_XDECREF(__pyx_v_label); __Pyx_XDECREF(__pyx_v_cost); __Pyx_XDECREF(__pyx_v_dist2next); + __Pyx_XDECREF(__pyx_v_label_str); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -13493,7 +13519,7 @@ static Py_ssize_t __pyx_pw_5_cdec_7Lattice_11__len__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":47 * del arc * * def __len__(self): # <<<<<<<<<<<<<< @@ -13506,7 +13532,7 @@ static Py_ssize_t __pyx_pf_5_cdec_7Lattice_10__len__(struct __pyx_obj_5_cdec_Lat __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":49 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":48 * * def __len__(self): * return self.lattice.size() # <<<<<<<<<<<<<< @@ -13533,7 +13559,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_13__str__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":51 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":50 * return self.lattice.size() * * def __str__(self): # <<<<<<<<<<<<<< @@ -13551,7 +13577,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_12__str__(struct __pyx_obj_5_cdec_Latt int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__str__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":52 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":51 * * def __str__(self): * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) # <<<<<<<<<<<<<< @@ -13559,14 +13585,14 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_12__str__(struct __pyx_obj_5_cdec_Latt * def __unicode__(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(HypergraphIO::AsPLF((__pyx_v_self->lattice[0]), 1).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __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 = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -13597,7 +13623,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_15__unicode__(PyObject *__pyx_v_self, return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":54 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":53 * return str(hypergraph.AsPLF(self.lattice[0], True).c_str()) * * def __unicode__(self): # <<<<<<<<<<<<<< @@ -13615,7 +13641,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__unicode__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":55 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":54 * * def __unicode__(self): * return unicode(str(self), 'utf8') # <<<<<<<<<<<<<< @@ -13623,15 +13649,15 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_ * def __iter__(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __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 = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); @@ -13639,7 +13665,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_14__unicode__(struct __pyx_obj_5_cdec_ PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyUnicode_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -13671,7 +13697,7 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_17__iter__(PyObject *__pyx_v_self) { return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":56 * return unicode(str(self), 'utf8') * * def __iter__(self): # <<<<<<<<<<<<<< @@ -13697,7 +13723,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_16__iter__(struct __pyx_obj_5_cdec_Lat __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_18generator14, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Lattice_18generator14, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -13732,27 +13758,27 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__pyx_GeneratorObject *_ return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":58 * def __iter__(self): * cdef unsigned i * for i in range(len(self)): # <<<<<<<<<<<<<< * yield self[i] * */ - __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Length(((PyObject *)__pyx_cur_scope->__pyx_v_self)); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":59 * cdef unsigned i * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< * * def todot(self): */ - __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_self), __pyx_cur_scope->__pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; @@ -13766,7 +13792,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__pyx_GeneratorObject *_ __pyx_L6_resume_from_yield:; __pyx_t_1 = __pyx_cur_scope->__pyx_t_0; __pyx_t_2 = __pyx_cur_scope->__pyx_t_1; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; @@ -13783,6 +13809,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_18generator14(__pyx_GeneratorObject *_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Lattice_20todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_7Lattice_19todot[] = "lattice.todot() -> Representation of the lattice in GraphViz dot format."; static PyObject *__pyx_pw_5_cdec_7Lattice_20todot(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -13805,9 +13832,9 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_5todot_1lines(PyObject *__pyx_self, CY return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 - * +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' @@ -13882,15 +13909,15 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":64 - * def todot(self): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":64 + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): * yield 'digraph lattice {' # <<<<<<<<<<<<<< * yield 'rankdir = LR;' * yield 'node [shape=circle];' */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_28)); - __pyx_r = ((PyObject *)__pyx_kp_s_28); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_26)); + __pyx_r = ((PyObject *)__pyx_kp_s_26); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ @@ -13899,15 +13926,15 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_L4_resume_from_yield:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":65 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":65 * def lines(): * yield 'digraph lattice {' * yield 'rankdir = LR;' # <<<<<<<<<<<<<< * yield 'node [shape=circle];' * for i in range(len(self)): */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_29)); - __pyx_r = ((PyObject *)__pyx_kp_s_29); + __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 */ @@ -13916,15 +13943,15 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_L5_resume_from_yield:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":66 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":66 * yield 'digraph lattice {' * yield 'rankdir = LR;' * yield 'node [shape=circle];' # <<<<<<<<<<<<<< * for i in range(len(self)): * for label, weight, delta in self[i]: */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_30)); - __pyx_r = ((PyObject *)__pyx_kp_s_30); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_28)); + __pyx_r = ((PyObject *)__pyx_kp_s_28); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ @@ -13933,7 +13960,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_L6_resume_from_yield:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":67 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":67 * yield 'rankdir = LR;' * yield 'node [shape=circle];' * for i in range(len(self)): # <<<<<<<<<<<<<< @@ -13968,16 +13995,16 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_4(__pyx_t_3); @@ -13996,7 +14023,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_cur_scope->__pyx_v_i = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":68 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":68 * yield 'node [shape=circle];' * for i in range(len(self)): * for label, weight, delta in self[i]: # <<<<<<<<<<<<<< @@ -14018,16 +14045,16 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_5)) { if (__pyx_t_6 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; + __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_5)) { if (__pyx_t_6 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; + __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_6); __Pyx_INCREF(__pyx_t_1); __pyx_t_6++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_1 = PySequence_ITEM(__pyx_t_5, __pyx_t_6); __pyx_t_6++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_1 = __pyx_t_7(__pyx_t_5); @@ -14111,7 +14138,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_cur_scope->__pyx_v_delta = __pyx_t_10; __pyx_t_10 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":69 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":69 * for i in range(len(self)): * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) # <<<<<<<<<<<<<< @@ -14122,7 +14149,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_GOTREF(__pyx_t_1); __pyx_t_10 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_label, __pyx_n_s__replace); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_10); - __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_34), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyTuple_New(3); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -14136,7 +14163,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_GIVEREF(__pyx_t_9); __pyx_t_1 = 0; __pyx_t_9 = 0; - __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_29), ((PyObject *)__pyx_t_10)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_9)); __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0; __pyx_r = ((PyObject *)__pyx_t_9); @@ -14171,7 +14198,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":70 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":70 * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) # <<<<<<<<<<<<<< @@ -14184,7 +14211,7 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_35), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_5)); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = ((PyObject *)__pyx_t_5); @@ -14197,15 +14224,15 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj __pyx_L14_resume_from_yield:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":71 * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) * yield '%d [shape=doublecircle]' % len(self) * yield '}' # <<<<<<<<<<<<<< * return '\n'.join(lines()).encode('utf8') * */ - __Pyx_INCREF(((PyObject *)__pyx_kp_s_36)); - __pyx_r = ((PyObject *)__pyx_kp_s_36); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_34)); + __pyx_r = ((PyObject *)__pyx_kp_s_34); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); /* return from generator, yielding value */ @@ -14232,12 +14259,12 @@ static PyObject *__pyx_gb_5_cdec_7Lattice_5todot_2generator20(__pyx_GeneratorObj return NULL; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":62 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":61 * yield self[i] * * def todot(self): # <<<<<<<<<<<<<< + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): - * yield 'digraph lattice {' */ static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { @@ -14262,19 +14289,19 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattic __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_v_self); __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_v_self); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 - * + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ - __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_cdec_7Lattice_5todot_1lines, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s___cdec, ((PyObject *)__pyx_k_codeobj_38)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5_cdec_7Lattice_5todot_1lines, 0, ((PyObject*)__pyx_cur_scope), __pyx_n_s___cdec, ((PyObject *)__pyx_k_codeobj_36)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_lines = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":72 * yield '%d [shape=doublecircle]' % len(self) * yield '}' * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<< @@ -14282,7 +14309,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattic * def as_hypergraph(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_40), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_38), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyObject_Call(__pyx_v_lines, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); @@ -14298,7 +14325,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattic __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_2; @@ -14323,6 +14350,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_19todot(struct __pyx_obj_5_cdec_Lattic /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_7Lattice_21as_hypergraph[] = "lattice.as_hypergraph() -> Hypergraph representation of the lattice."; static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -14332,12 +14360,12 @@ static PyObject *__pyx_pw_5_cdec_7Lattice_22as_hypergraph(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":74 +/* "/home/vchahune/tools/cdec/python/src/lattice.pxi":74 * return '\n'.join(lines()).encode('utf8') * * def as_hypergraph(self): # <<<<<<<<<<<<<< + * """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) - * result.hg = new hypergraph.Hypergraph() */ static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(struct __pyx_obj_5_cdec_Lattice *__pyx_v_self) { @@ -14347,65 +14375,65 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(struct __pyx_obj_5_cde __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; - char *__pyx_t_3; + std::string __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("as_hypergraph", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":75 - * + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":76 * def as_hypergraph(self): + * """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) # <<<<<<<<<<<<<< * result.hg = new hypergraph.Hypergraph() * cdef bytes plf = str(self) */ - __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_Hypergraph)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_Hypergraph)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_Hypergraph)))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5_cdec_Hypergraph)))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_result = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":76 - * def as_hypergraph(self): + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":77 + * """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) * result.hg = new hypergraph.Hypergraph() # <<<<<<<<<<<<<< * cdef bytes plf = str(self) - * hypergraph.ReadFromPLF(string(plf), result.hg) + * hypergraph.ReadFromPLF(plf, result.hg) */ __pyx_v_result->hg = new Hypergraph(); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":77 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":78 * cdef Hypergraph result = Hypergraph.__new__(Hypergraph) * result.hg = new hypergraph.Hypergraph() * cdef bytes plf = str(self) # <<<<<<<<<<<<<< - * hypergraph.ReadFromPLF(string(plf), result.hg) + * hypergraph.ReadFromPLF(plf, result.hg) * return result */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; __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 = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_plf = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":78 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":79 * result.hg = new hypergraph.Hypergraph() * cdef bytes plf = str(self) - * hypergraph.ReadFromPLF(string(plf), result.hg) # <<<<<<<<<<<<<< + * hypergraph.ReadFromPLF(plf, result.hg) # <<<<<<<<<<<<<< * return result */ - __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_plf)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - HypergraphIO::ReadFromPLF(std::string(__pyx_t_3), __pyx_v_result->hg); + __pyx_t_3 = __pyx_convert_string_from_py_(((PyObject *)__pyx_v_plf)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + HypergraphIO::ReadFromPLF(__pyx_t_3, __pyx_v_result->hg); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":79 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":80 * cdef bytes plf = str(self) - * hypergraph.ReadFromPLF(string(plf), result.hg) + * hypergraph.ReadFromPLF(plf, result.hg) * return result # <<<<<<<<<<<<<< */ __Pyx_XDECREF(__pyx_r); @@ -14428,7 +14456,7 @@ static PyObject *__pyx_pf_5_cdec_7Lattice_21as_hypergraph(struct __pyx_obj_5_cde return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":3 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":3 * cimport mteval * * cdef SufficientStats as_stats(x, y): # <<<<<<<<<<<<<< @@ -14449,7 +14477,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject int __pyx_clineno = 0; __Pyx_RefNannySetupContext("as_stats", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":4 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":4 * * cdef SufficientStats as_stats(x, y): * if isinstance(x, SufficientStats): # <<<<<<<<<<<<<< @@ -14462,7 +14490,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":5 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":5 * cdef SufficientStats as_stats(x, y): * if isinstance(x, SufficientStats): * return x # <<<<<<<<<<<<<< @@ -14477,15 +14505,14 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject goto __pyx_L3; } - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":6 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":6 * if isinstance(x, SufficientStats): * return x * elif x == 0 and isinstance(y, SufficientStats): # <<<<<<<<<<<<<< * stats = SufficientStats() * stats.stats = new mteval.SufficientStats() */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_1); + __pyx_t_1 = PyObject_RichCompare(__pyx_v_x, __pyx_int_0, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { @@ -14499,7 +14526,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject } if (__pyx_t_4) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":7 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":7 * return x * elif x == 0 and isinstance(y, SufficientStats): * stats = SufficientStats() # <<<<<<<<<<<<<< @@ -14511,7 +14538,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject __pyx_v_stats = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":8 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":8 * elif x == 0 and isinstance(y, SufficientStats): * stats = SufficientStats() * stats.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<< @@ -14520,7 +14547,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject */ __pyx_v_stats->stats = new SufficientStats(); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":9 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":9 * stats = SufficientStats() * stats.stats = new mteval.SufficientStats() * stats.metric = ( y).metric # <<<<<<<<<<<<<< @@ -14529,7 +14556,7 @@ static struct __pyx_obj_5_cdec_SufficientStats *__pyx_f_5_cdec_as_stats(PyObject */ __pyx_v_stats->metric = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_v_y)->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":10 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":10 * stats.stats = new mteval.SufficientStats() * stats.metric = ( y).metric * return stats # <<<<<<<<<<<<<< @@ -14568,7 +14595,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5words_1__get__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":17 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":17 * * property words: * def __get__(self): # <<<<<<<<<<<<<< @@ -14587,7 +14614,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_5words___get__(struct __pyx_obj_5_cd int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":18 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":18 * property words: * def __get__(self): * return unicode(GetString(self.candidate.ewords).c_str(), encoding='utf8') # <<<<<<<<<<<<<< @@ -14638,7 +14665,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_4fmap_1__get__(PyObject *__pyx_v_sel return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":21 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":21 * * property fmap: * def __get__(self): # <<<<<<<<<<<<<< @@ -14656,7 +14683,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":22 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":22 * property fmap: * def __get__(self): * cdef SparseVector fmap = SparseVector.__new__(SparseVector) # <<<<<<<<<<<<<< @@ -14669,7 +14696,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde __pyx_v_fmap = ((struct __pyx_obj_5_cdec_SparseVector *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":23 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":23 * def __get__(self): * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) # <<<<<<<<<<<<<< @@ -14678,7 +14705,7 @@ static PyObject *__pyx_pf_5_cdec_9Candidate_4fmap___get__(struct __pyx_obj_5_cde */ __pyx_v_fmap->vector = new FastSparseVector(__pyx_v_self->candidate->fmap); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":24 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":24 * cdef SparseVector fmap = SparseVector.__new__(SparseVector) * fmap.vector = new FastSparseVector[weight_t](self.candidate.fmap) * return fmap # <<<<<<<<<<<<<< @@ -14714,7 +14741,7 @@ static PyObject *__pyx_pw_5_cdec_9Candidate_5score_1__get__(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":14 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":14 * cdef class Candidate: * cdef mteval.const_Candidate* candidate * cdef public float score # <<<<<<<<<<<<<< @@ -14790,7 +14817,7 @@ static void __pyx_pw_5_cdec_15SufficientStats_1__dealloc__(PyObject *__pyx_v_sel __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":30 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":30 * cdef mteval.EvaluationMetric* metric * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -14802,7 +14829,7 @@ static void __pyx_pf_5_cdec_15SufficientStats___dealloc__(CYTHON_UNUSED struct _ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":31 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":31 * * def __dealloc__(self): * del self.stats # <<<<<<<<<<<<<< @@ -14825,7 +14852,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5score_1__get__(PyObject *__p return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":34 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":34 * * property score: * def __get__(self): # <<<<<<<<<<<<<< @@ -14842,7 +14869,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_5score___get__(struct __pyx_o int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":35 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":35 * property score: * def __get__(self): * return self.metric.ComputeScore(self.stats[0]) # <<<<<<<<<<<<<< @@ -14879,7 +14906,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_6detail_1__get__(PyObject *__ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":38 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":38 * * property detail: * def __get__(self): # <<<<<<<<<<<<<< @@ -14897,7 +14924,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":39 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":39 * property detail: * def __get__(self): * return str(self.metric.DetailedScore(self.stats[0]).c_str()) # <<<<<<<<<<<<<< @@ -14943,7 +14970,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":41 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":41 * return str(self.metric.DetailedScore(self.stats[0]).c_str()) * * def __len__(self): # <<<<<<<<<<<<<< @@ -14956,7 +14983,7 @@ static Py_ssize_t __pyx_pf_5_cdec_15SufficientStats_2__len__(struct __pyx_obj_5_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":42 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":42 * * def __len__(self): * return self.stats.size() # <<<<<<<<<<<<<< @@ -14984,7 +15011,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_5__iter__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":44 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":44 * return self.stats.size() * * def __iter__(self): # <<<<<<<<<<<<<< @@ -15048,7 +15075,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator15(__pyx_GeneratorO __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":45 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":45 * * def __iter__(self): * for i in range(len(self)): # <<<<<<<<<<<<<< @@ -15079,16 +15106,16 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator15(__pyx_GeneratorO if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_3)) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_3)) { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_2); __pyx_t_1++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_4(__pyx_t_3); @@ -15107,7 +15134,7 @@ static PyObject *__pyx_gb_5_cdec_15SufficientStats_6generator15(__pyx_GeneratorO __pyx_cur_scope->__pyx_v_i = __pyx_t_2; __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":46 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":46 * def __iter__(self): * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< @@ -15171,7 +15198,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_8__getitem__(PyObject *__pyx_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":48 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":48 * yield self[i] * * def __getitem__(self, int index): # <<<<<<<<<<<<<< @@ -15191,7 +15218,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":49 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":49 * * def __getitem__(self, int index): * if not 0 <= index < len(self): # <<<<<<<<<<<<<< @@ -15206,14 +15233,14 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj __pyx_t_3 = (!__pyx_t_1); if (__pyx_t_3) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":50 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('sufficient stats vector index out of range') # <<<<<<<<<<<<<< * return self.stats[0][index] * */ - __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; @@ -15222,7 +15249,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_7__getitem__(struct __pyx_obj } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":51 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":51 * if not 0 <= index < len(self): * raise IndexError('sufficient stats vector index out of range') * return self.stats[0][index] # <<<<<<<<<<<<<< @@ -15264,7 +15291,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_10__iadd__(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":53 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":53 * return self.stats[0][index] * * def __iadd__(SufficientStats self, SufficientStats other): # <<<<<<<<<<<<<< @@ -15277,7 +15304,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__iadd__(struct __pyx_obj_5_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__iadd__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":54 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":54 * * def __iadd__(SufficientStats self, SufficientStats other): * self.stats[0] += other.stats[0] # <<<<<<<<<<<<<< @@ -15286,7 +15313,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_9__iadd__(struct __pyx_obj_5_ */ (__pyx_v_self->stats[0]) += (__pyx_v_other->stats[0]); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":55 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":55 * def __iadd__(SufficientStats self, SufficientStats other): * self.stats[0] += other.stats[0] * return self # <<<<<<<<<<<<<< @@ -15316,7 +15343,7 @@ static PyObject *__pyx_pw_5_cdec_15SufficientStats_12__add__(PyObject *__pyx_v_x return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":57 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":57 * return self * * def __add__(x, y): # <<<<<<<<<<<<<< @@ -15336,7 +15363,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__add__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":58 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":58 * * def __add__(x, y): * cdef SufficientStats sx = as_stats(x, y) # <<<<<<<<<<<<<< @@ -15348,7 +15375,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x __pyx_v_sx = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":59 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":59 * def __add__(x, y): * cdef SufficientStats sx = as_stats(x, y) * cdef SufficientStats sy = as_stats(y, x) # <<<<<<<<<<<<<< @@ -15360,7 +15387,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x __pyx_v_sy = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":60 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":60 * cdef SufficientStats sx = as_stats(x, y) * cdef SufficientStats sy = as_stats(y, x) * cdef SufficientStats result = SufficientStats() # <<<<<<<<<<<<<< @@ -15372,7 +15399,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x __pyx_v_result = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":61 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":61 * cdef SufficientStats sy = as_stats(y, x) * cdef SufficientStats result = SufficientStats() * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) # <<<<<<<<<<<<<< @@ -15381,7 +15408,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x */ __pyx_v_result->stats = new SufficientStats(operator+((__pyx_v_sx->stats[0]), (__pyx_v_sy->stats[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":62 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":62 * cdef SufficientStats result = SufficientStats() * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) * result.metric = sx.metric # <<<<<<<<<<<<<< @@ -15390,7 +15417,7 @@ static PyObject *__pyx_pf_5_cdec_15SufficientStats_11__add__(PyObject *__pyx_v_x */ __pyx_v_result->metric = __pyx_v_sx->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":63 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":63 * result.stats = new mteval.SufficientStats(mteval.add(sx.stats[0], sy.stats[0])) * result.metric = sx.metric * return result # <<<<<<<<<<<<<< @@ -15469,7 +15496,7 @@ static int __pyx_pw_5_cdec_12CandidateSet_1__cinit__(PyObject *__pyx_v_self, PyO return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":70 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":70 * cdef mteval.CandidateSet* cs * * def __cinit__(self, SegmentEvaluator evaluator): # <<<<<<<<<<<<<< @@ -15482,7 +15509,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":71 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":71 * * def __cinit__(self, SegmentEvaluator evaluator): * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) # <<<<<<<<<<<<<< @@ -15491,7 +15518,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand */ __pyx_v_self->scorer = new boost::shared_ptr((__pyx_v_evaluator->scorer[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":72 * def __cinit__(self, SegmentEvaluator evaluator): * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) * self.metric = evaluator.metric # <<<<<<<<<<<<<< @@ -15500,7 +15527,7 @@ static int __pyx_pf_5_cdec_12CandidateSet___cinit__(struct __pyx_obj_5_cdec_Cand */ __pyx_v_self->metric = __pyx_v_evaluator->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":73 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":73 * self.scorer = new shared_ptr[mteval.SegmentEvaluator](evaluator.scorer[0]) * self.metric = evaluator.metric * self.cs = new mteval.CandidateSet() # <<<<<<<<<<<<<< @@ -15523,7 +15550,7 @@ static void __pyx_pw_5_cdec_12CandidateSet_3__dealloc__(PyObject *__pyx_v_self) __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":75 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":75 * self.cs = new mteval.CandidateSet() * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -15535,7 +15562,7 @@ static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __p __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":76 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":76 * * def __dealloc__(self): * del self.scorer # <<<<<<<<<<<<<< @@ -15544,7 +15571,7 @@ static void __pyx_pf_5_cdec_12CandidateSet_2__dealloc__(CYTHON_UNUSED struct __p */ delete __pyx_v_self->scorer; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":77 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":77 * def __dealloc__(self): * del self.scorer * del self.cs # <<<<<<<<<<<<<< @@ -15567,7 +15594,7 @@ static Py_ssize_t __pyx_pw_5_cdec_12CandidateSet_5__len__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":79 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":79 * del self.cs * * def __len__(self): # <<<<<<<<<<<<<< @@ -15580,7 +15607,7 @@ static Py_ssize_t __pyx_pf_5_cdec_12CandidateSet_4__len__(struct __pyx_obj_5_cde __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":80 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":80 * * def __len__(self): * return self.cs.size() # <<<<<<<<<<<<<< @@ -15617,7 +15644,7 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_7__getitem__(PyObject *__pyx_v_s return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":82 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":82 * return self.cs.size() * * def __getitem__(self,int k): # <<<<<<<<<<<<<< @@ -15637,7 +15664,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__getitem__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":83 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":83 * * def __getitem__(self,int k): * if not 0 <= k < self.cs.size(): # <<<<<<<<<<<<<< @@ -15651,14 +15678,14 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":84 * def __getitem__(self,int k): * if not 0 <= k < self.cs.size(): * raise IndexError('candidate set index out of range') # <<<<<<<<<<<<<< * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] */ - __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_builtin_IndexError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; @@ -15667,7 +15694,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":85 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":85 * if not 0 <= k < self.cs.size(): * raise IndexError('candidate set index out of range') * cdef Candidate candidate = Candidate() # <<<<<<<<<<<<<< @@ -15679,7 +15706,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ __pyx_v_candidate = ((struct __pyx_obj_5_cdec_Candidate *)__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":86 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":86 * raise IndexError('candidate set index out of range') * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] # <<<<<<<<<<<<<< @@ -15688,7 +15715,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ */ __pyx_v_candidate->candidate = (&((__pyx_v_self->cs[0])[__pyx_v_k])); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":87 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":87 * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats) # <<<<<<<<<<<<<< @@ -15697,7 +15724,7 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_6__getitem__(struct __pyx_obj_5_ */ __pyx_v_candidate->score = __pyx_v_self->metric->ComputeScore(((__pyx_v_self->cs[0])[__pyx_v_k]).eval_feats); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":88 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":88 * candidate.candidate = &self.cs[0][k] * candidate.score = self.metric.ComputeScore(self.cs[0][k].eval_feats) * return candidate # <<<<<<<<<<<<<< @@ -15734,7 +15761,7 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_9__iter__(PyObject *__pyx_v_self return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":90 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":90 * return candidate * * def __iter__(self): # <<<<<<<<<<<<<< @@ -15797,7 +15824,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator16(__pyx_GeneratorObj __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":92 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":92 * def __iter__(self): * cdef unsigned i * for i in range(len(self)): # <<<<<<<<<<<<<< @@ -15808,7 +15835,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator16(__pyx_GeneratorObj for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_2; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":93 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":93 * cdef unsigned i * for i in range(len(self)): * yield self[i] # <<<<<<<<<<<<<< @@ -15846,6 +15873,7 @@ static PyObject *__pyx_gb_5_cdec_12CandidateSet_10generator16(__pyx_GeneratorObj /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_12CandidateSet_11add_kbest[] = "cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses \n from the hypergraph and add them to the candidate set."; static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_hypergraph = 0; unsigned int __pyx_v_k; @@ -15905,12 +15933,12 @@ static PyObject *__pyx_pw_5_cdec_12CandidateSet_12add_kbest(PyObject *__pyx_v_se return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":95 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":95 * yield self[i] * * def add_kbest(self, Hypergraph hypergraph, unsigned k): # <<<<<<<<<<<<<< - * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) - * + * """cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses + * from the hypergraph and add them to the candidate set.""" */ static PyObject *__pyx_pf_5_cdec_12CandidateSet_11add_kbest(struct __pyx_obj_5_cdec_CandidateSet *__pyx_v_self, struct __pyx_obj_5_cdec_Hypergraph *__pyx_v_hypergraph, unsigned int __pyx_v_k) { @@ -15918,9 +15946,9 @@ static PyObject *__pyx_pf_5_cdec_12CandidateSet_11add_kbest(struct __pyx_obj_5_c __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("add_kbest", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":96 - * - * def add_kbest(self, Hypergraph hypergraph, unsigned k): + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":98 + * """cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses + * from the hypergraph and add them to the candidate set.""" * self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) # <<<<<<<<<<<<<< * * cdef class SegmentEvaluator: @@ -15942,7 +15970,7 @@ static void __pyx_pw_5_cdec_16SegmentEvaluator_1__dealloc__(PyObject *__pyx_v_se __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":102 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":104 * cdef mteval.EvaluationMetric* metric * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -15954,7 +15982,7 @@ static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":103 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":105 * * def __dealloc__(self): * del self.scorer # <<<<<<<<<<<<<< @@ -15968,6 +15996,7 @@ static void __pyx_pf_5_cdec_16SegmentEvaluator___dealloc__(CYTHON_UNUSED struct /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence); /*proto*/ +static char __pyx_doc_5_cdec_16SegmentEvaluator_2evaluate[] = "se.evaluate(sentence) -> SufficientStats for the given hypothesis."; static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_self, PyObject *__pyx_v_sentence) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -15977,12 +16006,12 @@ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate(PyObject *__pyx_v_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":105 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":107 * del self.scorer * * def evaluate(self, sentence): # <<<<<<<<<<<<<< + * """se.evaluate(sentence) -> SufficientStats for the given hypothesis.""" * cdef vector[WordID] hyp - * cdef SufficientStats sf = SufficientStats() */ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self, PyObject *__pyx_v_sentence) { @@ -15992,67 +16021,72 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5 __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + std::string __pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("evaluate", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":107 - * def evaluate(self, sentence): + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":110 + * """se.evaluate(sentence) -> SufficientStats for the given hypothesis.""" * cdef vector[WordID] hyp * cdef SufficientStats sf = SufficientStats() # <<<<<<<<<<<<<< * sf.metric = self.metric * sf.stats = new mteval.SufficientStats() */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SufficientStats)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_sf = ((struct __pyx_obj_5_cdec_SufficientStats *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":108 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":111 * cdef vector[WordID] hyp * cdef SufficientStats sf = SufficientStats() * sf.metric = self.metric # <<<<<<<<<<<<<< * sf.stats = new mteval.SufficientStats() - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + * ConvertSentence(as_str(sentence.strip()), &hyp) */ __pyx_v_sf->metric = __pyx_v_self->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":109 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":112 * cdef SufficientStats sf = SufficientStats() * sf.metric = self.metric * sf.stats = new mteval.SufficientStats() # <<<<<<<<<<<<<< - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + * ConvertSentence(as_str(sentence.strip()), &hyp) * self.scorer.get().Evaluate(hyp, sf.stats) */ __pyx_v_sf->stats = new SufficientStats(); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":110 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":113 * sf.metric = self.metric * sf.stats = new mteval.SufficientStats() - * ConvertSentence(string(as_str(sentence.strip())), &hyp) # <<<<<<<<<<<<<< + * ConvertSentence(as_str(sentence.strip()), &hyp) # <<<<<<<<<<<<<< * self.scorer.get().Evaluate(hyp, sf.stats) * return sf */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - TD::ConvertSentence(std::string(__pyx_f_5_cdec_as_str(__pyx_t_2, NULL)), (&__pyx_v_hyp)); + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_2, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + __pyx_t_3 = __pyx_convert_string_from_py_(__pyx_t_1); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; + TD::ConvertSentence(__pyx_t_3, (&__pyx_v_hyp)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":111 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":114 * sf.stats = new mteval.SufficientStats() - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + * ConvertSentence(as_str(sentence.strip()), &hyp) * self.scorer.get().Evaluate(hyp, sf.stats) # <<<<<<<<<<<<<< * return sf * */ __pyx_v_self->scorer->get()->Evaluate(__pyx_v_hyp, __pyx_v_sf->stats); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":112 - * ConvertSentence(string(as_str(sentence.strip())), &hyp) + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":115 + * ConvertSentence(as_str(sentence.strip()), &hyp) * self.scorer.get().Evaluate(hyp, sf.stats) * return sf # <<<<<<<<<<<<<< * @@ -16079,6 +16113,7 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_2evaluate(struct __pyx_obj_5 /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ +static char __pyx_doc_5_cdec_16SegmentEvaluator_4candidate_set[] = "se.candidate_set() -> Candidate set using this segment evaluator for scoring."; static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -16088,12 +16123,12 @@ static PyObject *__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set(PyObject *__p return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":114 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":117 * return sf * * def candidate_set(self): # <<<<<<<<<<<<<< + * """se.candidate_set() -> Candidate set using this segment evaluator for scoring.""" * return CandidateSet(self) - * */ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_obj_5_cdec_SegmentEvaluator *__pyx_v_self) { @@ -16106,20 +16141,20 @@ static PyObject *__pyx_pf_5_cdec_16SegmentEvaluator_4candidate_set(struct __pyx_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("candidate_set", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":115 - * + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":119 * def candidate_set(self): + * """se.candidate_set() -> Candidate set using this segment evaluator for scoring.""" * return CandidateSet(self) # <<<<<<<<<<<<<< * * cdef class Scorer: */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(((PyObject *)__pyx_v_self)); PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self)); __Pyx_GIVEREF(((PyObject *)__pyx_v_self)); - __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_CandidateSet)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_CandidateSet)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -16150,7 +16185,7 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject * static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__name,0}; PyObject* values[1] = {0}; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":121 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":125 * cdef mteval.EvaluationMetric* metric * * def __cinit__(self, bytes name=None): # <<<<<<<<<<<<<< @@ -16175,7 +16210,7 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject * } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -16188,13 +16223,13 @@ static int __pyx_pw_5_cdec_6Scorer_1__cinit__(PyObject *__pyx_v_self, PyObject * } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Scorer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyBytes_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyBytes_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = __pyx_pf_5_cdec_6Scorer___cinit__(((struct __pyx_obj_5_cdec_Scorer *)__pyx_v_self), __pyx_v_name); goto __pyx_L0; __pyx_L1_error:; @@ -16209,12 +16244,13 @@ static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__p __Pyx_RefNannyDeclarations int __pyx_t_1; char *__pyx_t_2; + std::string *__pyx_t_3; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":122 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":126 * * def __cinit__(self, bytes name=None): * if name: # <<<<<<<<<<<<<< @@ -16224,17 +16260,18 @@ static int __pyx_pf_5_cdec_6Scorer___cinit__(struct __pyx_obj_5_cdec_Scorer *__p __pyx_t_1 = (((PyObject *)__pyx_v_name) != Py_None) && (PyBytes_GET_SIZE(((PyObject *)__pyx_v_name)) != 0); if (__pyx_t_1) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":123 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":127 * def __cinit__(self, bytes name=None): * if name: * self.name = new string(name) # <<<<<<<<<<<<<< * self.metric = mteval.MetricInstance(self.name[0]) * */ - __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_name)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->name = new std::string(__pyx_t_2); + __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_name)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + try {__pyx_t_3 = new std::string(__pyx_t_2);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->name = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":124 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":128 * if name: * self.name = new string(name) * self.metric = mteval.MetricInstance(self.name[0]) # <<<<<<<<<<<<<< @@ -16265,7 +16302,7 @@ static void __pyx_pw_5_cdec_6Scorer_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":126 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":130 * self.metric = mteval.MetricInstance(self.name[0]) * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -16277,7 +16314,7 @@ static void __pyx_pf_5_cdec_6Scorer_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_ __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":127 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":131 * * def __dealloc__(self): * del self.name # <<<<<<<<<<<<<< @@ -16314,7 +16351,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -16325,7 +16362,7 @@ static PyObject *__pyx_pw_5_cdec_6Scorer_5__call__(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -16336,7 +16373,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":129 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":133 * del self.name * * def __call__(self, refs): # <<<<<<<<<<<<<< @@ -16353,17 +16390,20 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; int __pyx_t_2; - Py_ssize_t __pyx_t_3; - PyObject *(*__pyx_t_4)(PyObject *); - PyObject *__pyx_t_5 = NULL; + std::vector > *__pyx_t_3; + Py_ssize_t __pyx_t_4; + PyObject *(*__pyx_t_5)(PyObject *); PyObject *__pyx_t_6 = NULL; + std::vector *__pyx_t_7; + PyObject *__pyx_t_8 = NULL; + std::string __pyx_t_9; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__call__", 0); __Pyx_INCREF(__pyx_v_refs); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":130 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":134 * * def __call__(self, refs): * if isinstance(refs, basestring): # <<<<<<<<<<<<<< @@ -16372,18 +16412,18 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_IsInstance(__pyx_v_refs, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_IsInstance(__pyx_v_refs, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":131 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":135 * def __call__(self, refs): * if isinstance(refs, basestring): * refs = [refs] # <<<<<<<<<<<<<< * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() * cdef vector[WordID]* refv */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_refs); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_refs); @@ -16395,95 +16435,101 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score } __pyx_L3:; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":132 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":136 * if isinstance(refs, basestring): * refs = [refs] * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() # <<<<<<<<<<<<<< * cdef vector[WordID]* refv * for ref in refs: */ - __pyx_v_refsv = new std::vector >(); + try {__pyx_t_3 = new std::vector >();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_refsv = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":134 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":138 * cdef vector[vector[WordID]]* refsv = new vector[vector[WordID]]() * cdef vector[WordID]* refv * for ref in refs: # <<<<<<<<<<<<<< * refv = new vector[WordID]() - * ConvertSentence(string(as_str(ref.strip())), refv) + * ConvertSentence(as_str(ref.strip()), refv) */ if (PyList_CheckExact(__pyx_v_refs) || PyTuple_CheckExact(__pyx_v_refs)) { - __pyx_t_1 = __pyx_v_refs; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; - __pyx_t_4 = NULL; + __pyx_t_1 = __pyx_v_refs; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; + __pyx_t_5 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_refs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; + __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; } for (;;) { - if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) { - if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; + if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) { + if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif - } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { - if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; + } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) { + if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_6); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { - __pyx_t_5 = __pyx_t_4(__pyx_t_1); - if (unlikely(!__pyx_t_5)) { + __pyx_t_6 = __pyx_t_5(__pyx_t_1); + if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[5]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[5]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } - __Pyx_GOTREF(__pyx_t_5); + __Pyx_GOTREF(__pyx_t_6); } __Pyx_XDECREF(__pyx_v_ref); - __pyx_v_ref = __pyx_t_5; - __pyx_t_5 = 0; + __pyx_v_ref = __pyx_t_6; + __pyx_t_6 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":135 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":139 * cdef vector[WordID]* refv * for ref in refs: * refv = new vector[WordID]() # <<<<<<<<<<<<<< - * ConvertSentence(string(as_str(ref.strip())), refv) + * ConvertSentence(as_str(ref.strip()), refv) * refsv.push_back(refv[0]) */ - __pyx_v_refv = new std::vector(); + try {__pyx_t_7 = new std::vector();} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_refv = __pyx_t_7; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":136 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":140 * for ref in refs: * refv = new vector[WordID]() - * ConvertSentence(string(as_str(ref.strip())), refv) # <<<<<<<<<<<<<< + * ConvertSentence(as_str(ref.strip()), refv) # <<<<<<<<<<<<<< * refsv.push_back(refv[0]) * del refv */ - __pyx_t_5 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_GetAttr(__pyx_v_ref, __pyx_n_s__strip); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - TD::ConvertSentence(std::string(__pyx_f_5_cdec_as_str(__pyx_t_6, NULL)), __pyx_v_refv); + __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + __pyx_t_6 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_8, NULL)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_6); + __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; + __pyx_t_9 = __pyx_convert_string_from_py_(__pyx_t_6); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; + TD::ConvertSentence(__pyx_t_9, __pyx_v_refv); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":137 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":141 * refv = new vector[WordID]() - * ConvertSentence(string(as_str(ref.strip())), refv) + * ConvertSentence(as_str(ref.strip()), refv) * refsv.push_back(refv[0]) # <<<<<<<<<<<<<< * del refv * cdef unsigned i */ __pyx_v_refsv->push_back((__pyx_v_refv[0])); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":138 - * ConvertSentence(string(as_str(ref.strip())), refv) + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":142 + * ConvertSentence(as_str(ref.strip()), refv) * refsv.push_back(refv[0]) * del refv # <<<<<<<<<<<<<< * cdef unsigned i @@ -16493,19 +16539,19 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":140 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":144 * del refv * cdef unsigned i * cdef SegmentEvaluator evaluator = SegmentEvaluator() # <<<<<<<<<<<<<< * evaluator.metric = self.metric * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SegmentEvaluator)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_SegmentEvaluator)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_evaluator = ((struct __pyx_obj_5_cdec_SegmentEvaluator *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":141 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":145 * cdef unsigned i * cdef SegmentEvaluator evaluator = SegmentEvaluator() * evaluator.metric = self.metric # <<<<<<<<<<<<<< @@ -16514,7 +16560,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ __pyx_v_evaluator->metric = __pyx_v_self->metric; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":142 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":146 * cdef SegmentEvaluator evaluator = SegmentEvaluator() * evaluator.metric = self.metric * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( # <<<<<<<<<<<<<< @@ -16523,7 +16569,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ __pyx_v_evaluator->scorer = new boost::shared_ptr(__pyx_v_self->metric->CreateSegmentEvaluator((__pyx_v_refsv[0]))); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":144 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":148 * evaluator.scorer = new shared_ptr[mteval.SegmentEvaluator]( * self.metric.CreateSegmentEvaluator(refsv[0])) * del refsv # in theory should not delete but store in SegmentEvaluator # <<<<<<<<<<<<<< @@ -16532,7 +16578,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score */ delete __pyx_v_refsv; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":145 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":149 * self.metric.CreateSegmentEvaluator(refsv[0])) * del refsv # in theory should not delete but store in SegmentEvaluator * return evaluator # <<<<<<<<<<<<<< @@ -16548,8 +16594,8 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_4__call__(struct __pyx_obj_5_cdec_Score goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("_cdec.Scorer.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; @@ -16572,7 +16618,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":147 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":151 * return evaluator * * def __str__(self): # <<<<<<<<<<<<<< @@ -16590,7 +16636,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":148 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":152 * * def __str__(self): * return str(self.name.c_str()) # <<<<<<<<<<<<<< @@ -16598,14 +16644,14 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(__pyx_v_self->name->c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(__pyx_v_self->name->c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -16625,7 +16671,7 @@ static PyObject *__pyx_pf_5_cdec_6Scorer_6__str__(struct __pyx_obj_5_cdec_Scorer return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":150 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":154 * return str(self.name.c_str()) * * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): # <<<<<<<<<<<<<< @@ -16651,7 +16697,7 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_compute_score", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":151 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":155 * * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): * cdef Metric metric = metric_ # <<<<<<<<<<<<<< @@ -16661,19 +16707,19 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat __Pyx_INCREF(((PyObject *)((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_))); __pyx_v_metric = ((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":152 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":156 * cdef float _compute_score(void* metric_, mteval.SufficientStats* stats): * cdef Metric metric = metric_ * cdef list ss = [] # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(stats.size()): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_ss = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":154 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":158 * cdef list ss = [] * cdef unsigned i * for i in range(stats.size()): # <<<<<<<<<<<<<< @@ -16684,38 +16730,38 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":155 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":159 * cdef unsigned i * for i in range(stats.size()): * ss.append(stats[0][i]) # <<<<<<<<<<<<<< * return metric.score(ss) * */ - __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_stats[0])[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyFloat_FromDouble(((__pyx_v_stats[0])[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyList_Append(__pyx_v_ss, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyList_Append(__pyx_v_ss, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":156 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":160 * for i in range(stats.size()): * ss.append(stats[0][i]) * return metric.score(ss) # <<<<<<<<<<<<<< * * cdef void _compute_sufficient_stats(void* metric_, */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__score); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_5); __Pyx_INCREF(((PyObject *)__pyx_v_ss)); PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_ss)); __Pyx_GIVEREF(((PyObject *)__pyx_v_ss)); - __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0; - __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = __pyx_PyFloat_AsFloat(__pyx_t_6); if (unlikely((__pyx_t_7 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_r = __pyx_t_7; goto __pyx_L0; @@ -16735,7 +16781,7 @@ static float __pyx_f_5_cdec__compute_score(void *__pyx_v_metric_, SufficientStat return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":158 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":162 * return metric.score(ss) * * cdef void _compute_sufficient_stats(void* metric_, # <<<<<<<<<<<<<< @@ -16762,7 +16808,7 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: int __pyx_clineno = 0; __Pyx_RefNannySetupContext("_compute_sufficient_stats", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":162 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":166 * vector[string]* refs, * mteval.SufficientStats* out): * cdef Metric metric = metric_ # <<<<<<<<<<<<<< @@ -16772,19 +16818,19 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: __Pyx_INCREF(((PyObject *)((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_))); __pyx_v_metric = ((struct __pyx_obj_5_cdec_Metric *)__pyx_v_metric_); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":163 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":167 * mteval.SufficientStats* out): * cdef Metric metric = metric_ * cdef list refs_ = [] # <<<<<<<<<<<<<< * cdef unsigned i * for i in range(refs.size()): */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_v_refs_ = __pyx_t_1; __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":165 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":169 * cdef list refs_ = [] * cdef unsigned i * for i in range(refs.size()): # <<<<<<<<<<<<<< @@ -16795,47 +16841,47 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":166 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":170 * cdef unsigned i * for i in range(refs.size()): * refs_.append(str(refs[0][i].c_str())) # <<<<<<<<<<<<<< * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) * out.fields.resize(len(ss)) */ - __pyx_t_1 = PyBytes_FromString(((__pyx_v_refs[0])[__pyx_v_i]).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(((__pyx_v_refs[0])[__pyx_v_i]).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_5 = PyList_Append(__pyx_v_refs_, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PyList_Append(__pyx_v_refs_, __pyx_t_1); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":167 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":171 * for i in range(refs.size()): * refs_.append(str(refs[0][i].c_str())) * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) # <<<<<<<<<<<<<< * out.fields.resize(len(ss)) * for i in range(len(ss)): */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__evaluate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_metric), __pyx_n_s__evaluate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyBytes_FromString(__pyx_v_hyp->c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyBytes_FromString(__pyx_v_hyp->c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_4)); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4)); __Pyx_GIVEREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); @@ -16843,15 +16889,15 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_v_refs_)); __Pyx_GIVEREF(((PyObject *)__pyx_v_refs_)); __pyx_t_4 = 0; - __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyList_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected list, got %.200s", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_ss = ((PyObject*)__pyx_t_4); __pyx_t_4 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":168 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":172 * refs_.append(str(refs[0][i].c_str())) * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) * out.fields.resize(len(ss)) # <<<<<<<<<<<<<< @@ -16860,12 +16906,12 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: */ if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[5]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_out->fields.resize(__pyx_t_7); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":169 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":173 * cdef list ss = metric.evaluate(str(hyp.c_str()), refs_) * out.fields.resize(len(ss)) * for i in range(len(ss)): # <<<<<<<<<<<<<< @@ -16874,13 +16920,13 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: */ if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyList_GET_SIZE(((PyObject *)__pyx_v_ss)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_7; __pyx_t_3+=1) { __pyx_v_i = __pyx_t_3; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":170 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":174 * out.fields.resize(len(ss)) * for i in range(len(ss)): * out.fields[i] = ss[i] # <<<<<<<<<<<<<< @@ -16889,11 +16935,11 @@ static void __pyx_f_5_cdec__compute_sufficient_stats(void *__pyx_v_metric_, std: */ if (unlikely(((PyObject *)__pyx_v_ss) == Py_None)) { PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_4 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_ss), __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_ss), __pyx_v_i, sizeof(unsigned int)+1, PyLong_FromUnsignedLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_4); - __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = __pyx_PyFloat_AsFloat(__pyx_t_4); if (unlikely((__pyx_t_8 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; (__pyx_v_out->fields[__pyx_v_i]) = __pyx_t_8; } @@ -16925,32 +16971,35 @@ static int __pyx_pw_5_cdec_6Metric_1__cinit__(PyObject *__pyx_v_self, PyObject * return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":174 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":178 * cdef class Metric: * cdef Scorer scorer * def __cinit__(self): # <<<<<<<<<<<<<< * self.scorer = Scorer() - * self.scorer.name = new string(as_str(self.__class__.__name__)) + * cdef bytes class_name = self.__class__.__name__ */ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__pyx_v_self) { + PyObject *__pyx_v_class_name = 0; int __pyx_r; __Pyx_RefNannyDeclarations PyObject *__pyx_t_1 = NULL; PyObject *__pyx_t_2 = NULL; + char *__pyx_t_3; + std::string *__pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__cinit__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":175 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":179 * cdef Scorer scorer * def __cinit__(self): * self.scorer = Scorer() # <<<<<<<<<<<<<< - * self.scorer.name = new string(as_str(self.__class__.__name__)) - * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], + * cdef bytes class_name = self.__class__.__name__ + * self.scorer.name = new string(class_name) */ - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_GIVEREF(__pyx_t_1); __Pyx_GOTREF(__pyx_v_self->scorer); @@ -16958,24 +17007,36 @@ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__p __pyx_v_self->scorer = ((struct __pyx_obj_5_cdec_Scorer *)__pyx_t_1); __pyx_t_1 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":176 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":180 * def __cinit__(self): * self.scorer = Scorer() - * self.scorer.name = new string(as_str(self.__class__.__name__)) # <<<<<<<<<<<<<< + * cdef bytes class_name = self.__class__.__name__ # <<<<<<<<<<<<<< + * self.scorer.name = new string(class_name) * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], - * self, _compute_sufficient_stats, _compute_score) */ - __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____class__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____name__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_self->scorer->name = new std::string(__pyx_f_5_cdec_as_str(__pyx_t_2, NULL)); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; + if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_class_name = ((PyObject*)__pyx_t_2); + __pyx_t_2 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":177 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":181 * self.scorer = Scorer() - * self.scorer.name = new string(as_str(self.__class__.__name__)) + * cdef bytes class_name = self.__class__.__name__ + * self.scorer.name = new string(class_name) # <<<<<<<<<<<<<< + * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], + * self, _compute_sufficient_stats, _compute_score) + */ + __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_class_name)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + try {__pyx_t_4 = new std::string(__pyx_t_3);} catch(...) {__Pyx_CppExn2PyErr(); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}} + __pyx_v_self->scorer->name = __pyx_t_4; + + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":182 + * cdef bytes class_name = self.__class__.__name__ + * self.scorer.name = new string(class_name) * self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], # <<<<<<<<<<<<<< * self, _compute_sufficient_stats, _compute_score) * @@ -16990,6 +17051,7 @@ static int __pyx_pf_5_cdec_6Metric___cinit__(struct __pyx_obj_5_cdec_Metric *__p __Pyx_AddTraceback("_cdec.Metric.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_class_name); __Pyx_RefNannyFinishContext(); return __pyx_r; } @@ -17019,7 +17081,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__call__") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { goto __pyx_L5_argtuple_error; @@ -17030,7 +17092,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__call__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Metric.__call__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -17041,7 +17103,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_3__call__(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":180 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":185 * self, _compute_sufficient_stats, _compute_score) * * def __call__(self, refs): # <<<<<<<<<<<<<< @@ -17059,7 +17121,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_2__call__(struct __pyx_obj_5_cdec_Metri int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__call__", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":181 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":186 * * def __call__(self, refs): * return self.scorer(refs) # <<<<<<<<<<<<<< @@ -17067,12 +17129,12 @@ static PyObject *__pyx_pf_5_cdec_6Metric_2__call__(struct __pyx_obj_5_cdec_Metri * def score(SufficientStats stats): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_refs); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_refs); __Pyx_GIVEREF(__pyx_v_refs); - __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_self->scorer), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_self->scorer), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; @@ -17103,7 +17165,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_5score(PyObject *__pyx_v_stats, CYTHON_ return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":183 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":188 * return self.scorer(refs) * * def score(SufficientStats stats): # <<<<<<<<<<<<<< @@ -17116,7 +17178,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_4score(CYTHON_UNUSED struct __pyx_obj_5 __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("score", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":184 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":189 * * def score(SufficientStats stats): * return 0 # <<<<<<<<<<<<<< @@ -17163,11 +17225,11 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj case 1: if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__refs)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, 1); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "evaluate") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "evaluate") < 0)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { goto __pyx_L5_argtuple_error; @@ -17180,7 +17242,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("evaluate", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_AddTraceback("_cdec.Metric.evaluate", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); @@ -17191,7 +17253,7 @@ static PyObject *__pyx_pw_5_cdec_6Metric_7evaluate(PyObject *__pyx_v_self, PyObj return __pyx_r; } -/* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":186 +/* "/home/vchahune/tools/cdec/python/src/mteval.pxi":191 * return 0 * * def evaluate(self, hyp, refs): # <<<<<<<<<<<<<< @@ -17208,7 +17270,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_ob int __pyx_clineno = 0; __Pyx_RefNannySetupContext("evaluate", 0); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":187 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":192 * * def evaluate(self, hyp, refs): * return [] # <<<<<<<<<<<<<< @@ -17216,7 +17278,7 @@ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_ob * BLEU = Scorer('IBM_BLEU') */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_r = ((PyObject *)__pyx_t_1); __pyx_t_1 = 0; @@ -17236,7 +17298,8 @@ static PyObject *__pyx_pf_5_cdec_6Metric_6evaluate(CYTHON_UNUSED struct __pyx_ob /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_3set_silent(PyObject *__pyx_self, PyObject *__pyx_v_yn); /*proto*/ -static PyMethodDef __pyx_mdef_5_cdec_3set_silent = {__Pyx_NAMESTR("set_silent"), (PyCFunction)__pyx_pw_5_cdec_3set_silent, METH_O, __Pyx_DOCSTR(0)}; +static char __pyx_doc_5_cdec_2set_silent[] = "set_silent(bool): Configure the verbosity of cdec."; +static PyMethodDef __pyx_mdef_5_cdec_3set_silent = {__Pyx_NAMESTR("set_silent"), (PyCFunction)__pyx_pw_5_cdec_3set_silent, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_2set_silent)}; static PyObject *__pyx_pw_5_cdec_3set_silent(PyObject *__pyx_self, PyObject *__pyx_v_yn) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -17250,8 +17313,8 @@ static PyObject *__pyx_pw_5_cdec_3set_silent(PyObject *__pyx_self, PyObject *__p * class ParseFailed(Exception): pass * * def set_silent(yn): # <<<<<<<<<<<<<< + * """set_silent(bool): Configure the verbosity of cdec.""" * SetSilent(yn) - * */ static PyObject *__pyx_pf_5_cdec_2set_silent(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_yn) { @@ -17263,14 +17326,14 @@ static PyObject *__pyx_pf_5_cdec_2set_silent(CYTHON_UNUSED PyObject *__pyx_self, int __pyx_clineno = 0; __Pyx_RefNannySetupContext("set_silent", 0); - /* "_cdec.pyx":29 - * + /* "_cdec.pyx":30 * def set_silent(yn): + * """set_silent(bool): Configure the verbosity of cdec.""" * SetSilent(yn) # <<<<<<<<<<<<<< * * def _make_config(config): */ - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_yn); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_yn); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;} SetSilent(__pyx_t_1); __pyx_r = Py_None; __Pyx_INCREF(Py_None); @@ -17297,7 +17360,7 @@ static PyObject *__pyx_pw_5_cdec_5_make_config(PyObject *__pyx_self, PyObject *_ return __pyx_r; } -/* "_cdec.pyx":31 +/* "_cdec.pyx":32 * SetSilent(yn) * * def _make_config(config): # <<<<<<<<<<<<<< @@ -17323,7 +17386,7 @@ static PyObject *__pyx_pf_5_cdec_4_make_config(CYTHON_UNUSED PyObject *__pyx_sel __Pyx_INCREF(__pyx_cur_scope->__pyx_v_config); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_config); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_6generator17, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_6generator17, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -17369,25 +17432,25 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "_cdec.pyx":32 + /* "_cdec.pyx":33 * * def _make_config(config): * for key, value in config.items(): # <<<<<<<<<<<<<< * if isinstance(value, dict): * for name, info in value.items(): */ - __pyx_t_1 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) { __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = NULL; } else { - __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -17396,23 +17459,23 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) { if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_2 = __pyx_t_4(__pyx_t_1); if (unlikely(!__pyx_t_2)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -17428,7 +17491,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -17441,14 +17504,14 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } else { Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext; @@ -17456,7 +17519,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; goto __pyx_L7_unpacking_done; @@ -17464,7 +17527,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_key); @@ -17478,7 +17541,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __pyx_cur_scope->__pyx_v_value = __pyx_t_6; __pyx_t_6 = 0; - /* "_cdec.pyx":33 + /* "_cdec.pyx":34 * def _make_config(config): * for key, value in config.items(): * if isinstance(value, dict): # <<<<<<<<<<<<<< @@ -17491,23 +17554,23 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { - /* "_cdec.pyx":34 + /* "_cdec.pyx":35 * for key, value in config.items(): * if isinstance(value, dict): * for name, info in value.items(): # <<<<<<<<<<<<<< * yield key, '%s %s' % (name, info) * elif isinstance(value, list): */ - __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_value, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_value, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) { __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { - __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -17516,23 +17579,23 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -17548,7 +17611,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -17561,14 +17624,14 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(__pyx_t_7); #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else { Py_ssize_t index = -1; - __pyx_t_12 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_12 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_12); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_8 = Py_TYPE(__pyx_t_12)->tp_iternext; @@ -17576,7 +17639,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_GOTREF(__pyx_t_5); index = 1; __pyx_t_7 = __pyx_t_8(__pyx_t_12); if (unlikely(!__pyx_t_7)) goto __pyx_L11_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_8 = NULL; __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; goto __pyx_L12_unpacking_done; @@ -17584,7 +17647,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0; __pyx_t_8 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L12_unpacking_done:; } __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_name); @@ -17598,14 +17661,14 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __pyx_cur_scope->__pyx_v_info = __pyx_t_7; __pyx_t_7 = 0; - /* "_cdec.pyx":35 + /* "_cdec.pyx":36 * if isinstance(value, dict): * for name, info in value.items(): * yield key, '%s %s' % (name, info) # <<<<<<<<<<<<<< * elif isinstance(value, list): * for name in value: */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_name); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_name); @@ -17613,10 +17676,10 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_INCREF(__pyx_cur_scope->__pyx_v_info); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_info); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_info); - __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_44), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_7)); __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_key); @@ -17650,13 +17713,13 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __pyx_t_4 = __pyx_cur_scope->__pyx_t_3; __pyx_t_10 = __pyx_cur_scope->__pyx_t_4; __pyx_t_11 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8; } - /* "_cdec.pyx":36 + /* "_cdec.pyx":37 * for name, info in value.items(): * yield key, '%s %s' % (name, info) * elif isinstance(value, list): # <<<<<<<<<<<<<< @@ -17669,7 +17732,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_9) { - /* "_cdec.pyx":37 + /* "_cdec.pyx":38 * yield key, '%s %s' % (name, info) * elif isinstance(value, list): * for name in value: # <<<<<<<<<<<<<< @@ -17680,7 +17743,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __pyx_t_2 = __pyx_cur_scope->__pyx_v_value; __Pyx_INCREF(__pyx_t_2); __pyx_t_10 = 0; __pyx_t_11 = NULL; } else { - __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_10 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_11 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -17688,23 +17751,23 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; + __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; + __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_10); __Pyx_INCREF(__pyx_t_6); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_6 = __pyx_t_11(__pyx_t_2); if (unlikely(!__pyx_t_6)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -17716,14 +17779,14 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __pyx_cur_scope->__pyx_v_name = __pyx_t_6; __pyx_t_6 = 0; - /* "_cdec.pyx":38 + /* "_cdec.pyx":39 * elif isinstance(value, list): * for name in value: * yield key, name # <<<<<<<<<<<<<< * else: * yield key, str(value) */ - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_key); @@ -17757,29 +17820,29 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __pyx_t_4 = __pyx_cur_scope->__pyx_t_3; __pyx_t_10 = __pyx_cur_scope->__pyx_t_4; __pyx_t_11 = __pyx_cur_scope->__pyx_t_5; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; goto __pyx_L8; } /*else*/ { - /* "_cdec.pyx":40 + /* "_cdec.pyx":41 * yield key, name * else: * yield key, str(value) # <<<<<<<<<<<<<< * * cdef class Decoder: */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_value); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_value); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_value); - __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_key); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_v_key); @@ -17804,7 +17867,7 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener __Pyx_XGOTREF(__pyx_t_1); __pyx_t_3 = __pyx_cur_scope->__pyx_t_2; __pyx_t_4 = __pyx_cur_scope->__pyx_t_3; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L8:; } @@ -17828,25 +17891,29 @@ static PyObject *__pyx_gb_5_cdec_6generator17(__pyx_GeneratorObject *__pyx_gener } /* Python wrapper */ -static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { +static int __pyx_pw_5_cdec_7Decoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_7Decoder___init__[] = "Decoder('formalism = scfg') -> initialize from configuration string\n Decoder(formalism='scfg') -> initialize from named parameters\n Create a decoder using a given configuration. Formalism is required."; +#if CYTHON_COMPILING_IN_CPYTHON +struct wrapperbase __pyx_wrapperbase_5_cdec_7Decoder___init__; +#endif +static int __pyx_pw_5_cdec_7Decoder_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_config_str = 0; PyObject *__pyx_v_config = 0; int __pyx_r; __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); + __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); __pyx_v_config = PyDict_New(); if (unlikely(!__pyx_v_config)) return -1; __Pyx_GOTREF(__pyx_v_config); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__config_str,0}; PyObject* values[1] = {0}; - /* "_cdec.pyx":46 + /* "_cdec.pyx":47 * cdef DenseVector weights * - * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<< - * """ Configuration can be given as a string: - * Decoder('formalism = scfg') + * def __init__(self, config_str=None, **config): # <<<<<<<<<<<<<< + * """Decoder('formalism = scfg') -> initialize from configuration string + * Decoder(formalism='scfg') -> initialize from named parameters */ values[0] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -17866,7 +17933,7 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_config, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_config, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;} } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -17879,21 +17946,21 @@ static int __pyx_pw_5_cdec_7Decoder_1__cinit__(PyObject *__pyx_v_self, PyObject } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L3_error;} + __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;} __pyx_L3_error:; __Pyx_CLEAR(__pyx_v_config); - __Pyx_AddTraceback("_cdec.Decoder.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Decoder.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5_cdec_7Decoder___cinit__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), __pyx_v_config_str, __pyx_v_config); + __pyx_r = __pyx_pf_5_cdec_7Decoder___init__(((struct __pyx_obj_5_cdec_Decoder *)__pyx_v_self), __pyx_v_config_str, __pyx_v_config); __Pyx_XDECREF(__pyx_v_config); __Pyx_RefNannyFinishContext(); return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ +static PyObject *__pyx_gb_5_cdec_7Decoder_8__init___2generator21(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */ -/* "_cdec.pyx":57 +/* "_cdec.pyx":56 * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< @@ -17901,7 +17968,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato * self.dec = new decoder.Decoder(config_stream) */ -static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_self) { +static PyObject *__pyx_pf_5_cdec_7Decoder_8__init___genexpr(PyObject *__pyx_self) { struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations @@ -17915,11 +17982,11 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_sel return NULL; } __Pyx_GOTREF(__pyx_cur_scope); - __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *) __pyx_self; + __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *) __pyx_self; __Pyx_INCREF(((PyObject *)__pyx_cur_scope->__pyx_outer_scope)); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope); { - __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Decoder_9__cinit___2generator21, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_5_cdec_7Decoder_8__init___2generator21, (PyObject *) __pyx_cur_scope); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; @@ -17928,7 +17995,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_sel __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; - __Pyx_AddTraceback("_cdec.Decoder.__cinit__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Decoder.__init__.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); @@ -17937,7 +18004,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(PyObject *__pyx_sel return __pyx_r; } -static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ +static PyObject *__pyx_gb_5_cdec_7Decoder_8__init___2generator21(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */ { struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *__pyx_cur_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)__pyx_generator->closure); PyObject *__pyx_r = NULL; @@ -17956,16 +18023,16 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato return NULL; } __pyx_L3_first_run:; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___make_config); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___make_config); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config)) { __Pyx_RaiseClosureNameError("config"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config)) { __Pyx_RaiseClosureNameError("config"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_config); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_config); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; @@ -17973,7 +18040,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato __pyx_t_2 = __pyx_t_3; __Pyx_INCREF(__pyx_t_2); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __pyx_t_5 = Py_TYPE(__pyx_t_2)->tp_iternext; } @@ -17982,23 +18049,23 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_2)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_2)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PySequence_ITEM(__pyx_t_2, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_2); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -18009,7 +18076,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato __Pyx_GIVEREF(__pyx_t_3); __pyx_cur_scope->__pyx_v_kv = __pyx_t_3; __pyx_t_3 = 0; - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), __pyx_cur_scope->__pyx_v_kv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), __pyx_cur_scope->__pyx_v_kv); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); __pyx_r = ((PyObject *)__pyx_t_3); __pyx_t_3 = 0; @@ -18028,7 +18095,7 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato __Pyx_XGOTREF(__pyx_t_2); __pyx_t_4 = __pyx_cur_scope->__pyx_t_1; __pyx_t_5 = __pyx_cur_scope->__pyx_t_2; - if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; PyErr_SetNone(PyExc_StopIteration); @@ -18046,16 +18113,16 @@ static PyObject *__pyx_gb_5_cdec_7Decoder_9__cinit___2generator21(__pyx_Generato return NULL; } -/* "_cdec.pyx":46 +/* "_cdec.pyx":47 * cdef DenseVector weights * - * def __cinit__(self, config_str=None, **config): # <<<<<<<<<<<<<< - * """ Configuration can be given as a string: - * Decoder('formalism = scfg') + * def __init__(self, config_str=None, **config): # <<<<<<<<<<<<<< + * """Decoder('formalism = scfg') -> initialize from configuration string + * Decoder(formalism='scfg') -> initialize from named parameters */ -static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *__pyx_cur_scope; +static int __pyx_pf_5_cdec_7Decoder___init__(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_config_str, PyObject *__pyx_v_config) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *__pyx_cur_scope; PyObject *__pyx_v_formalism = NULL; std::istringstream *__pyx_v_config_stream; int __pyx_r; @@ -18070,8 +18137,8 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; - __Pyx_RefNannySetupContext("__cinit__", 0); - __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *)__pyx_ptype_5_cdec___pyx_scope_struct_24___cinit__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_24___cinit__, __pyx_empty_tuple, NULL); + __Pyx_RefNannySetupContext("__init__", 0); + __pyx_cur_scope = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)__pyx_ptype_5_cdec___pyx_scope_struct_24___init__->tp_new(__pyx_ptype_5_cdec___pyx_scope_struct_24___init__, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __Pyx_RefNannyFinishContext(); return -1; @@ -18082,9 +18149,9 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_config); __Pyx_INCREF(__pyx_v_config_str); - /* "_cdec.pyx":52 - * Decoder(formalism='scfg') - * """ + /* "_cdec.pyx":51 + * Decoder(formalism='scfg') -> initialize from named parameters + * Create a decoder using a given configuration. Formalism is required.""" * if config_str is None: # <<<<<<<<<<<<<< * formalism = config.get('formalism', None) * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', @@ -18092,22 +18159,22 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __pyx_t_1 = (__pyx_v_config_str == Py_None); if (__pyx_t_1) { - /* "_cdec.pyx":53 - * """ + /* "_cdec.pyx":52 + * Create a decoder using a given configuration. Formalism is required.""" * if config_str is None: * formalism = config.get('formalism', None) # <<<<<<<<<<<<<< * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): */ - __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(__pyx_cur_scope->__pyx_v_config, __pyx_n_s__get); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_46), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_v_formalism = __pyx_t_3; __pyx_t_3 = 0; - /* "_cdec.pyx":54 + /* "_cdec.pyx":53 * if config_str is None: * formalism = config.get('formalism', None) * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', # <<<<<<<<<<<<<< @@ -18116,39 +18183,53 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __Pyx_INCREF(__pyx_v_formalism); __pyx_t_3 = __pyx_v_formalism; - __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__scfg), Py_NE); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__scfg), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (((int)__pyx_t_1)) { - __pyx_t_4 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__fst), Py_NE); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__fst), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = ((int)__pyx_t_4); } else { __pyx_t_5 = ((int)__pyx_t_1); } if (__pyx_t_5) { - __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__lextrans), Py_NE); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__lextrans), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = ((int)__pyx_t_1); } else { __pyx_t_4 = __pyx_t_5; } if (__pyx_t_4) { - __pyx_t_5 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__pb), Py_NE); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__pb), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = ((int)__pyx_t_5); } else { __pyx_t_1 = __pyx_t_4; } if (__pyx_t_1) { - __pyx_t_4 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__csplit), Py_NE); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__csplit), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_5 = ((int)__pyx_t_4); } else { __pyx_t_5 = __pyx_t_1; } if (__pyx_t_5) { - __pyx_t_1 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__tagger), Py_NE); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__tagger), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_4 = ((int)__pyx_t_1); } else { __pyx_t_4 = __pyx_t_5; } if (__pyx_t_4) { - __pyx_t_5 = __Pyx_PyString_Equals(__pyx_t_3, ((PyObject *)__pyx_n_s__lexalign), Py_NE); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__lexalign), Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_1 = ((int)__pyx_t_5); } else { __pyx_t_1 = __pyx_t_4; @@ -18157,50 +18238,50 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __pyx_t_4 = __pyx_t_1; if (__pyx_t_4) { - /* "_cdec.pyx":56 + /* "_cdec.pyx":55 * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) # <<<<<<<<<<<<<< * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) * cdef istringstream* config_stream = new istringstream(config_str) */ - __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__InvalidConfig); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__InvalidConfig); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_v_formalism); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_47), __pyx_v_formalism); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_2)); - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2)); __Pyx_GIVEREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; - __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L4; } __pyx_L4:; - /* "_cdec.pyx":57 + /* "_cdec.pyx":56 * 'csplit', 'tagger', 'lexalign'): * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) # <<<<<<<<<<<<<< * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) */ - __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_40), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_38), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = __pyx_pf_5_cdec_7Decoder_9__cinit___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __pyx_pf_5_cdec_7Decoder_8__init___genexpr(((PyObject*)__pyx_cur_scope)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; @@ -18211,17 +18292,17 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ } __pyx_L3:; - /* "_cdec.pyx":58 + /* "_cdec.pyx":57 * raise InvalidConfig('formalism "%s" unknown' % formalism) * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) * cdef istringstream* config_stream = new istringstream(config_str) # <<<<<<<<<<<<<< * self.dec = new decoder.Decoder(config_stream) * del config_stream */ - __pyx_t_7 = PyBytes_AsString(__pyx_v_config_str); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PyBytes_AsString(__pyx_v_config_str); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_config_stream = new std::istringstream(__pyx_t_7); - /* "_cdec.pyx":59 + /* "_cdec.pyx":58 * config_str = '\n'.join('%s = %s' % kv for kv in _make_config(config)) * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) # <<<<<<<<<<<<<< @@ -18230,7 +18311,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __pyx_v_self->dec = new Decoder(__pyx_v_config_stream); - /* "_cdec.pyx":60 + /* "_cdec.pyx":59 * cdef istringstream* config_stream = new istringstream(config_str) * self.dec = new decoder.Decoder(config_stream) * del config_stream # <<<<<<<<<<<<<< @@ -18239,23 +18320,23 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ delete __pyx_v_config_stream; - /* "_cdec.pyx":61 + /* "_cdec.pyx":60 * self.dec = new decoder.Decoder(config_stream) * del config_stream * self.weights = DenseVector.__new__(DenseVector) # <<<<<<<<<<<<<< * self.weights.vector = &self.dec.CurrentWeightVector() * self.weights.owned = True */ - __pyx_t_6 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_DenseVector)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5_cdec_DenseVector)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_6); - if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5_cdec_DenseVector)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(__Pyx_TypeTest(__pyx_t_6, __pyx_ptype_5_cdec_DenseVector)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GIVEREF(__pyx_t_6); __Pyx_GOTREF(__pyx_v_self->weights); __Pyx_DECREF(((PyObject *)__pyx_v_self->weights)); __pyx_v_self->weights = ((struct __pyx_obj_5_cdec_DenseVector *)__pyx_t_6); __pyx_t_6 = 0; - /* "_cdec.pyx":62 + /* "_cdec.pyx":61 * del config_stream * self.weights = DenseVector.__new__(DenseVector) * self.weights.vector = &self.dec.CurrentWeightVector() # <<<<<<<<<<<<<< @@ -18264,7 +18345,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ */ __pyx_v_self->weights->vector = (&__pyx_v_self->dec->CurrentWeightVector()); - /* "_cdec.pyx":63 + /* "_cdec.pyx":62 * self.weights = DenseVector.__new__(DenseVector) * self.weights.vector = &self.dec.CurrentWeightVector() * self.weights.owned = True # <<<<<<<<<<<<<< @@ -18279,7 +18360,7 @@ static int __pyx_pf_5_cdec_7Decoder___cinit__(struct __pyx_obj_5_cdec_Decoder *_ __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("_cdec.Decoder.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); + __Pyx_AddTraceback("_cdec.Decoder.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_formalism); @@ -18298,7 +18379,7 @@ static void __pyx_pw_5_cdec_7Decoder_3__dealloc__(PyObject *__pyx_v_self) { __Pyx_RefNannyFinishContext(); } -/* "_cdec.pyx":65 +/* "_cdec.pyx":64 * self.weights.owned = True * * def __dealloc__(self): # <<<<<<<<<<<<<< @@ -18310,7 +18391,7 @@ static void __pyx_pf_5_cdec_7Decoder_2__dealloc__(CYTHON_UNUSED struct __pyx_obj __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__", 0); - /* "_cdec.pyx":66 + /* "_cdec.pyx":65 * * def __dealloc__(self): * del self.dec # <<<<<<<<<<<<<< @@ -18333,7 +18414,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7weights_1__get__(PyObject *__pyx_v_se return __pyx_r; } -/* "_cdec.pyx":69 +/* "_cdec.pyx":68 * * property weights: * def __get__(self): # <<<<<<<<<<<<<< @@ -18346,7 +18427,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_7weights___get__(struct __pyx_obj_5_cd __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__", 0); - /* "_cdec.pyx":70 + /* "_cdec.pyx":69 * property weights: * def __get__(self): * return self.weights # <<<<<<<<<<<<<< @@ -18376,7 +18457,7 @@ static int __pyx_pw_5_cdec_7Decoder_7weights_3__set__(PyObject *__pyx_v_self, Py return __pyx_r; } -/* "_cdec.pyx":72 +/* "_cdec.pyx":71 * return self.weights * * def __set__(self, weights): # <<<<<<<<<<<<<< @@ -18403,7 +18484,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__set__", 0); - /* "_cdec.pyx":73 + /* "_cdec.pyx":72 * * def __set__(self, weights): * if isinstance(weights, DenseVector): # <<<<<<<<<<<<<< @@ -18416,7 +18497,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "_cdec.pyx":74 + /* "_cdec.pyx":73 * def __set__(self, weights): * if isinstance(weights, DenseVector): * self.weights.vector[0] = ( weights).vector[0] # <<<<<<<<<<<<<< @@ -18427,7 +18508,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De goto __pyx_L3; } - /* "_cdec.pyx":75 + /* "_cdec.pyx":74 * if isinstance(weights, DenseVector): * self.weights.vector[0] = ( weights).vector[0] * elif isinstance(weights, SparseVector): # <<<<<<<<<<<<<< @@ -18440,7 +18521,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "_cdec.pyx":76 + /* "_cdec.pyx":75 * self.weights.vector[0] = ( weights).vector[0] * elif isinstance(weights, SparseVector): * self.weights.vector.clear() # <<<<<<<<<<<<<< @@ -18449,7 +18530,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De */ __pyx_v_self->weights->vector->clear(); - /* "_cdec.pyx":77 + /* "_cdec.pyx":76 * elif isinstance(weights, SparseVector): * self.weights.vector.clear() * (( weights).vector[0]).init_vector(self.weights.vector) # <<<<<<<<<<<<<< @@ -18460,7 +18541,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De goto __pyx_L3; } - /* "_cdec.pyx":78 + /* "_cdec.pyx":77 * self.weights.vector.clear() * (( weights).vector[0]).init_vector(self.weights.vector) * elif isinstance(weights, dict): # <<<<<<<<<<<<<< @@ -18473,7 +18554,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "_cdec.pyx":79 + /* "_cdec.pyx":78 * (( weights).vector[0]).init_vector(self.weights.vector) * elif isinstance(weights, dict): * self.weights.vector.clear() # <<<<<<<<<<<<<< @@ -18482,23 +18563,23 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De */ __pyx_v_self->weights->vector->clear(); - /* "_cdec.pyx":80 + /* "_cdec.pyx":79 * elif isinstance(weights, dict): * self.weights.vector.clear() * for fname, fval in weights.items(): # <<<<<<<<<<<<<< * self.weights[fname] = fval * else: */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_weights, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_weights, __pyx_n_s__items); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) { __pyx_t_1 = __pyx_t_3; __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = 0; __pyx_t_5 = NULL; } else { - __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_4 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __pyx_t_5 = Py_TYPE(__pyx_t_1)->tp_iternext; } @@ -18507,23 +18588,23 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De if (!__pyx_t_5 && PyList_CheckExact(__pyx_t_1)) { if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; + __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else if (!__pyx_t_5 && PyTuple_CheckExact(__pyx_t_1)) { if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_1)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; + __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #else - __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_4); __pyx_t_4++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif } else { __pyx_t_3 = __pyx_t_5(__pyx_t_1); if (unlikely(!__pyx_t_3)) { if (PyErr_Occurred()) { if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear(); - else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } break; } @@ -18539,7 +18620,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De if (unlikely(size != 2)) { if (size > 2) __Pyx_RaiseTooManyValuesError(2); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } #if CYTHON_COMPILING_IN_CPYTHON if (likely(PyTuple_CheckExact(sequence))) { @@ -18552,14 +18633,14 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else - __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #endif __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } else { Py_ssize_t index = -1; - __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; @@ -18567,7 +18648,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_GOTREF(__pyx_t_6); index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L6_unpacking_failed; __Pyx_GOTREF(__pyx_t_7); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_t_9 = NULL; __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; goto __pyx_L7_unpacking_done; @@ -18575,7 +18656,7 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_9 = NULL; if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_L7_unpacking_done:; } __Pyx_XDECREF(__pyx_v_fname); @@ -18585,40 +18666,40 @@ static int __pyx_pf_5_cdec_7Decoder_7weights_2__set__(struct __pyx_obj_5_cdec_De __pyx_v_fval = __pyx_t_7; __pyx_t_7 = 0; - /* "_cdec.pyx":81 + /* "_cdec.pyx":80 * self.weights.vector.clear() * for fname, fval in weights.items(): * self.weights[fname] = fval # <<<<<<<<<<<<<< * else: * raise TypeError('cannot initialize weights with %s' % type(weights)) */ - if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_v_fname, __pyx_v_fval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetItem(((PyObject *)__pyx_v_self->weights), __pyx_v_fname, __pyx_v_fval) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } /*else*/ { - /* "_cdec.pyx":83 + /* "_cdec.pyx":82 * self.weights[fname] = fval * else: * raise TypeError('cannot initialize weights with %s' % type(weights)) # <<<<<<<<<<<<<< * * property formalism: */ - __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_50), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), ((PyObject *)Py_TYPE(__pyx_v_weights))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; @@ -18650,7 +18731,7 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_9formalism_1__get__(PyObject *__pyx_v_ return __pyx_r; } -/* "_cdec.pyx":86 +/* "_cdec.pyx":85 * * property formalism: * def __get__(self): # <<<<<<<<<<<<<< @@ -18669,7 +18750,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__get__", 0); - /* "_cdec.pyx":87 + /* "_cdec.pyx":86 * property formalism: * def __get__(self): * cdef variables_map* conf = &self.dec.GetConf() # <<<<<<<<<<<<<< @@ -18678,7 +18759,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ */ __pyx_v_conf = (&__pyx_v_self->dec->GetConf()); - /* "_cdec.pyx":88 + /* "_cdec.pyx":87 * def __get__(self): * cdef variables_map* conf = &self.dec.GetConf() * return str(conf[0]['formalism'].as_str().c_str()) # <<<<<<<<<<<<<< @@ -18686,14 +18767,14 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ * def read_weights(self, weights): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = PyBytes_FromString(((__pyx_v_conf[0])[__pyx_k__formalism]).as().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyBytes_FromString(((__pyx_v_conf[0])[__pyx_k__formalism]).as().c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_1)); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1)); __Pyx_GIVEREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; @@ -18715,6 +18796,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_9formalism___get__(struct __pyx_obj_5_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_weights); /*proto*/ +static char __pyx_doc_5_cdec_7Decoder_4read_weights[] = "decoder.read_weights(filename): Read decoder weights from a file."; static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, PyObject *__pyx_v_weights) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations @@ -18724,12 +18806,12 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_5read_weights(PyObject *__pyx_v_self, return __pyx_r; } -/* "_cdec.pyx":90 +/* "_cdec.pyx":89 * return str(conf[0]['formalism'].as_str().c_str()) * * def read_weights(self, weights): # <<<<<<<<<<<<<< + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: - * for line in fp: */ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_Decoder *__pyx_v_self, PyObject *__pyx_v_weights) { @@ -18761,8 +18843,8 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __Pyx_RefNannySetupContext("read_weights", 0); /* "_cdec.pyx":91 - * * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: # <<<<<<<<<<<<<< * for line in fp: * if line.strip().startswith('#'): continue @@ -18796,7 +18878,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; /* "_cdec.pyx":92 - * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: * for line in fp: # <<<<<<<<<<<<<< * if line.strip().startswith('#'): continue @@ -18814,16 +18896,16 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ if (!__pyx_t_9 && PyList_CheckExact(__pyx_t_4)) { if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; + __pyx_t_2 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #endif } else if (!__pyx_t_9 && PyTuple_CheckExact(__pyx_t_4)) { if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break; #if CYTHON_COMPILING_IN_CPYTHON - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; + __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_2); __pyx_t_8++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;}; + __pyx_t_2 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L7_error;} #endif } else { __pyx_t_2 = __pyx_t_9(__pyx_t_4); @@ -18855,7 +18937,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__startswith); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_52), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} + __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L7_error;} @@ -18968,8 +19050,8 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; /* "_cdec.pyx":91 - * * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: # <<<<<<<<<<<<<< * for line in fp: * if line.strip().startswith('#'): continue @@ -19031,7 +19113,7 @@ 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_53, NULL); + __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_k_tuple_51, NULL); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_7); @@ -19069,6 +19151,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_4read_weights(struct __pyx_obj_5_cdec_ /* Python wrapper */ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ +static char __pyx_doc_5_cdec_7Decoder_6translate[] = "decoder.translate(sentence, grammar=None) -> Hypergraph\n Translate a sentence (string/Lattice) with a grammar (string/list of rules)."; static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_sentence = 0; PyObject *__pyx_v_grammar = 0; @@ -19083,8 +19166,8 @@ static PyObject *__pyx_pw_5_cdec_7Decoder_7translate(PyObject *__pyx_v_self, PyO * self.weights[fname.strip()] = float(value) * * def translate(self, sentence, grammar=None): # <<<<<<<<<<<<<< - * cdef bytes input_str - * if isinstance(sentence, basestring): + * """decoder.translate(sentence, grammar=None) -> Hypergraph + * Translate a sentence (string/Lattice) with a grammar (string/list of rules).""" */ values[1] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { @@ -19143,14 +19226,14 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec PyObject *__pyx_t_1 = NULL; int __pyx_t_2; PyObject *__pyx_t_3 = NULL; - char *__pyx_t_4; + std::string __pyx_t_4; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("translate", 0); - /* "_cdec.pyx":99 - * def translate(self, sentence, grammar=None): + /* "_cdec.pyx":101 + * Translate a sentence (string/Lattice) with a grammar (string/list of rules).""" * cdef bytes input_str * if isinstance(sentence, basestring): # <<<<<<<<<<<<<< * input_str = as_str(sentence.strip()) @@ -19158,31 +19241,31 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec */ __pyx_t_1 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_1); - __pyx_t_2 = PyObject_IsInstance(__pyx_v_sentence, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_IsInstance(__pyx_v_sentence, __pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { - /* "_cdec.pyx":100 + /* "_cdec.pyx":102 * cdef bytes input_str * if isinstance(sentence, basestring): * input_str = as_str(sentence.strip()) # <<<<<<<<<<<<<< * elif isinstance(sentence, Lattice): * input_str = str(sentence) # PLF format */ - __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_GetAttr(__pyx_v_sentence, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __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 = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyBytes_FromString(__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(((PyObject *)__pyx_t_1)); + __pyx_t_1 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_t_3, NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_input_str = __pyx_t_1; + __pyx_v_input_str = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L3; } - /* "_cdec.pyx":101 + /* "_cdec.pyx":103 * if isinstance(sentence, basestring): * input_str = as_str(sentence.strip()) * elif isinstance(sentence, Lattice): # <<<<<<<<<<<<<< @@ -19195,99 +19278,103 @@ 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":102 + /* "_cdec.pyx":104 * input_str = as_str(sentence.strip()) * elif isinstance(sentence, Lattice): * input_str = str(sentence) # PLF format # <<<<<<<<<<<<<< * else: * raise TypeError('Cannot translate input type %s' % type(sentence)) */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_sentence); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_sentence); __Pyx_GIVEREF(__pyx_v_sentence); - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __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 = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_input_str = ((PyObject*)__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L3; } /*else*/ { - /* "_cdec.pyx":104 + /* "_cdec.pyx":106 * input_str = str(sentence) # PLF format * else: * raise TypeError('Cannot translate input type %s' % type(sentence)) # <<<<<<<<<<<<<< * if grammar: * if isinstance(grammar, basestring): */ - __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), ((PyObject *)Py_TYPE(__pyx_v_sentence))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(((PyObject *)__pyx_t_3)); - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __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 = 106; __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 = 104; __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 = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} } __pyx_L3:; - /* "_cdec.pyx":105 + /* "_cdec.pyx":107 * else: * raise TypeError('Cannot translate input type %s' % type(sentence)) * if grammar: # <<<<<<<<<<<<<< * if isinstance(grammar, basestring): - * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) */ - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_grammar); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __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 = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__pyx_t_2) { - /* "_cdec.pyx":106 + /* "_cdec.pyx":108 * raise TypeError('Cannot translate input type %s' % type(sentence)) * if grammar: * if isinstance(grammar, basestring): # <<<<<<<<<<<<<< - * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) * else: */ __pyx_t_3 = __pyx_builtin_basestring; __Pyx_INCREF(__pyx_t_3); - __pyx_t_2 = PyObject_IsInstance(__pyx_v_grammar, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_IsInstance(__pyx_v_grammar, __pyx_t_3); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (__pyx_t_2) { - /* "_cdec.pyx":107 + /* "_cdec.pyx":109 * if grammar: * if isinstance(grammar, basestring): - * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) # <<<<<<<<<<<<<< + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) # <<<<<<<<<<<<<< * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) */ - __pyx_v_self->dec->AddSupplementalGrammarFromString(std::string(__pyx_f_5_cdec_as_str(__pyx_v_grammar, NULL))); + __pyx_t_3 = ((PyObject *)__pyx_f_5_cdec_as_str(__pyx_v_grammar, NULL)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_t_3); + __pyx_t_4 = __pyx_convert_string_from_py_(__pyx_t_3); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; + __pyx_v_self->dec->AddSupplementalGrammarFromString(__pyx_t_4); goto __pyx_L5; } /*else*/ { - /* "_cdec.pyx":109 - * self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) + /* "_cdec.pyx":111 + * self.dec.AddSupplementalGrammarFromString(as_str(grammar)) * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) # <<<<<<<<<<<<<< * cdef decoder.BasicObserver observer = decoder.BasicObserver() - * self.dec.Decode(string(input_str), &observer) + * self.dec.Decode(input_str, &observer) */ - __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_v_grammar); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_grammar); __Pyx_GIVEREF(__pyx_v_grammar); - __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_TextGrammar)), ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; __pyx_v_self->dec->AddSupplementalGrammar((((struct __pyx_obj_5_cdec_TextGrammar *)__pyx_t_1)->__pyx_base.grammar[0])); @@ -19298,28 +19385,28 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec } __pyx_L4:; - /* "_cdec.pyx":110 + /* "_cdec.pyx":112 * else: * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) * cdef decoder.BasicObserver observer = decoder.BasicObserver() # <<<<<<<<<<<<<< - * self.dec.Decode(string(input_str), &observer) + * self.dec.Decode(input_str, &observer) * if observer.hypergraph == NULL: */ __pyx_v_observer = BasicObserver(); - /* "_cdec.pyx":111 + /* "_cdec.pyx":113 * self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) * cdef decoder.BasicObserver observer = decoder.BasicObserver() - * self.dec.Decode(string(input_str), &observer) # <<<<<<<<<<<<<< + * self.dec.Decode(input_str, &observer) # <<<<<<<<<<<<<< * if observer.hypergraph == NULL: * raise ParseFailed() */ - __pyx_t_4 = PyBytes_AsString(((PyObject *)__pyx_v_input_str)); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_v_self->dec->Decode(std::string(__pyx_t_4), (&__pyx_v_observer)); + __pyx_t_4 = __pyx_convert_string_from_py_(((PyObject *)__pyx_v_input_str)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_v_self->dec->Decode(__pyx_t_4, (&__pyx_v_observer)); - /* "_cdec.pyx":112 + /* "_cdec.pyx":114 * cdef decoder.BasicObserver observer = decoder.BasicObserver() - * self.dec.Decode(string(input_str), &observer) + * self.dec.Decode(input_str, &observer) * if observer.hypergraph == NULL: # <<<<<<<<<<<<<< * raise ParseFailed() * cdef Hypergraph hg = Hypergraph() @@ -19327,38 +19414,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":113 - * self.dec.Decode(string(input_str), &observer) + /* "_cdec.pyx":115 + * self.dec.Decode(input_str, &observer) * if observer.hypergraph == NULL: * raise ParseFailed() # <<<<<<<<<<<<<< * cdef Hypergraph hg = Hypergraph() * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) */ - __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ParseFailed); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __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 = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;} goto __pyx_L6; } __pyx_L6:; - /* "_cdec.pyx":114 + /* "_cdec.pyx":116 * if observer.hypergraph == NULL: * raise ParseFailed() * cdef Hypergraph hg = Hypergraph() # <<<<<<<<<<<<<< * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) * return hg */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Hypergraph)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __pyx_v_hg = ((struct __pyx_obj_5_cdec_Hypergraph *)__pyx_t_3); __pyx_t_3 = 0; - /* "_cdec.pyx":115 + /* "_cdec.pyx":117 * raise ParseFailed() * cdef Hypergraph hg = Hypergraph() * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) # <<<<<<<<<<<<<< @@ -19366,7 +19453,7 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec */ __pyx_v_hg->hg = new Hypergraph((__pyx_v_observer.hypergraph[0])); - /* "_cdec.pyx":116 + /* "_cdec.pyx":118 * cdef Hypergraph hg = Hypergraph() * hg.hg = new hypergraph.Hypergraph(observer.hypergraph[0]) * return hg # <<<<<<<<<<<<<< @@ -19391,6 +19478,44 @@ static PyObject *__pyx_pf_5_cdec_7Decoder_6translate(struct __pyx_obj_5_cdec_Dec return __pyx_r; } +/* "string.from_py":11 + * + * @cname("__pyx_convert_string_from_py_") + * cdef string __pyx_convert_string_from_py_(object o) except *: # <<<<<<<<<<<<<< + * return string(o, len(o)) + * + */ + +static std::string __pyx_convert_string_from_py_(PyObject *__pyx_v_o) { + std::string __pyx_r; + __Pyx_RefNannyDeclarations + char *__pyx_t_1; + Py_ssize_t __pyx_t_2; + int __pyx_lineno = 0; + const char *__pyx_filename = NULL; + int __pyx_clineno = 0; + __Pyx_RefNannySetupContext("__pyx_convert_string_from_py_", 0); + + /* "string.from_py":12 + * @cname("__pyx_convert_string_from_py_") + * cdef string __pyx_convert_string_from_py_(object o) except *: + * return string(o, len(o)) # <<<<<<<<<<<<<< + * + * + */ + __pyx_t_1 = PyBytes_AsString(__pyx_v_o); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_2 = PyObject_Length(__pyx_v_o); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_r = std::string(((char *)__pyx_t_1), __pyx_t_2); + goto __pyx_L0; + + goto __pyx_L0; + __pyx_L1_error:; + __Pyx_AddTraceback("string.from_py.__pyx_convert_string_from_py_", __pyx_clineno, __pyx_lineno, __pyx_filename); + __pyx_L0:; + __Pyx_RefNannyFinishContext(); + return __pyx_r; +} + static PyObject *__pyx_tp_new_5_cdec_DenseVector(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; @@ -19429,8 +19554,8 @@ static int __pyx_mp_ass_subscript_5_cdec_DenseVector(PyObject *o, PyObject *i, P } static PyMethodDef __pyx_methods_5_cdec_DenseVector[] = { - {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_14dot, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("tosparse"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_16tosparse, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_14dot, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_11DenseVector_13dot)}, + {__Pyx_NAMESTR("tosparse"), (PyCFunction)__pyx_pw_5_cdec_11DenseVector_16tosparse, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_11DenseVector_15tosparse)}, {0, 0, 0, 0} }; @@ -19626,8 +19751,8 @@ static int __pyx_mp_ass_subscript_5_cdec_SparseVector(PyObject *o, PyObject *i, } static PyMethodDef __pyx_methods_5_cdec_SparseVector[] = { - {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_5copy, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_14dot, METH_O, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("copy"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_5copy, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_12SparseVector_4copy)}, + {__Pyx_NAMESTR("dot"), (PyCFunction)__pyx_pw_5_cdec_12SparseVector_14dot, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_12SparseVector_13dot)}, {0, 0, 0, 0} }; @@ -19796,7 +19921,7 @@ static PyObject *__pyx_tp_new_5_cdec_NT(PyTypeObject *t, CYTHON_UNUSED PyObject static void __pyx_tp_dealloc_5_cdec_NT(PyObject *o) { struct __pyx_obj_5_cdec_NT *p = (struct __pyx_obj_5_cdec_NT *)o; - Py_XDECREF(((PyObject *)p->cat)); + Py_CLEAR(p->cat); (*Py_TYPE(o)->tp_free)(o); } @@ -20824,9 +20949,6 @@ static PyTypeObject __pyx_type_5_cdec_Grammar = { static PyObject *__pyx_tp_new_5_cdec_TextGrammar(PyTypeObject *t, PyObject *a, PyObject *k) { PyObject *o = __pyx_tp_new_5_cdec_Grammar(t, a, k); if (!o) return 0; - if (__pyx_pw_5_cdec_11TextGrammar_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } return o; } @@ -20976,7 +21098,7 @@ static PyTypeObject __pyx_type_5_cdec_TextGrammar = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_5_cdec_11TextGrammar_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5_cdec_TextGrammar, /*tp_new*/ 0, /*tp_free*/ @@ -21032,21 +21154,21 @@ static PyObject *__pyx_getprop_5_cdec_10Hypergraph_npaths(PyObject *o, CYTHON_UN } static PyMethodDef __pyx_methods_5_cdec_Hypergraph[] = { - {__Pyx_NAMESTR("viterbi"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_3viterbi, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("viterbi_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("viterbi_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_7viterbi_features, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("viterbi_joshua"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("kbest"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_11kbest, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("kbest_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_14kbest_trees, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("kbest_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_17kbest_features, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_20sample, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("sample_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_23sample_trees, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_26intersect, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("prune"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_28prune, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("lattice"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_30lattice, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("plf"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_32plf, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("reweight"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_34reweight, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("inside_outside"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_36inside_outside, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("viterbi"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_3viterbi, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_2viterbi)}, + {__Pyx_NAMESTR("viterbi_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_5viterbi_trees, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_4viterbi_trees)}, + {__Pyx_NAMESTR("viterbi_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_7viterbi_features, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_6viterbi_features)}, + {__Pyx_NAMESTR("viterbi_joshua"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_9viterbi_joshua, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_8viterbi_joshua)}, + {__Pyx_NAMESTR("kbest"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_11kbest, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_10kbest)}, + {__Pyx_NAMESTR("kbest_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_14kbest_trees, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_13kbest_trees)}, + {__Pyx_NAMESTR("kbest_features"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_17kbest_features, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_16kbest_features)}, + {__Pyx_NAMESTR("sample"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_20sample, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_19sample)}, + {__Pyx_NAMESTR("sample_trees"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_23sample_trees, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_22sample_trees)}, + {__Pyx_NAMESTR("intersect"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_26intersect, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_25intersect)}, + {__Pyx_NAMESTR("prune"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_28prune, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_27prune)}, + {__Pyx_NAMESTR("lattice"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_30lattice, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_29lattice)}, + {__Pyx_NAMESTR("plf"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_32plf, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_31plf)}, + {__Pyx_NAMESTR("reweight"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_34reweight, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_33reweight)}, + {__Pyx_NAMESTR("inside_outside"), (PyCFunction)__pyx_pw_5_cdec_10Hypergraph_36inside_outside, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_10Hypergraph_35inside_outside)}, {0, 0, 0, 0} }; @@ -21225,7 +21347,7 @@ static PyObject *__pyx_tp_new_5_cdec_HypergraphEdge(PyTypeObject *t, CYTHON_UNUS static void __pyx_tp_dealloc_5_cdec_HypergraphEdge(PyObject *o) { struct __pyx_obj_5_cdec_HypergraphEdge *p = (struct __pyx_obj_5_cdec_HypergraphEdge *)o; - Py_XDECREF(((PyObject *)p->trule)); + Py_CLEAR(p->trule); (*Py_TYPE(o)->tp_free)(o); } @@ -21686,8 +21808,8 @@ static int __pyx_mp_ass_subscript_5_cdec_Lattice(PyObject *o, PyObject *i, PyObj static PyMethodDef __pyx_methods_5_cdec_Lattice[] = { {__Pyx_NAMESTR("__unicode__"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_15__unicode__, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_20todot, METH_NOARGS, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("as_hypergraph"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_22as_hypergraph, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("todot"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_20todot, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Lattice_19todot)}, + {__Pyx_NAMESTR("as_hypergraph"), (PyCFunction)__pyx_pw_5_cdec_7Lattice_22as_hypergraph, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Lattice_21as_hypergraph)}, {0, 0, 0, 0} }; @@ -22270,7 +22392,7 @@ static PyObject *__pyx_sq_item_5_cdec_CandidateSet(PyObject *o, Py_ssize_t i) { } static PyMethodDef __pyx_methods_5_cdec_CandidateSet[] = { - {__Pyx_NAMESTR("add_kbest"), (PyCFunction)__pyx_pw_5_cdec_12CandidateSet_12add_kbest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("add_kbest"), (PyCFunction)__pyx_pw_5_cdec_12CandidateSet_12add_kbest, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5_cdec_12CandidateSet_11add_kbest)}, {0, 0, 0, 0} }; @@ -22448,8 +22570,8 @@ static void __pyx_tp_dealloc_5_cdec_SegmentEvaluator(PyObject *o) { } static PyMethodDef __pyx_methods_5_cdec_SegmentEvaluator[] = { - {__Pyx_NAMESTR("evaluate"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("candidate_set"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set, METH_NOARGS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("evaluate"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_3evaluate, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_16SegmentEvaluator_2evaluate)}, + {__Pyx_NAMESTR("candidate_set"), (PyCFunction)__pyx_pw_5_cdec_16SegmentEvaluator_5candidate_set, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5_cdec_16SegmentEvaluator_4candidate_set)}, {0, 0, 0, 0} }; @@ -22801,7 +22923,7 @@ static PyObject *__pyx_tp_new_5_cdec_Metric(PyTypeObject *t, CYTHON_UNUSED PyObj static void __pyx_tp_dealloc_5_cdec_Metric(PyObject *o) { struct __pyx_obj_5_cdec_Metric *p = (struct __pyx_obj_5_cdec_Metric *)o; - Py_XDECREF(((PyObject *)p->scorer)); + Py_CLEAR(p->scorer); (*Py_TYPE(o)->tp_free)(o); } @@ -22983,15 +23105,12 @@ static PyTypeObject __pyx_type_5_cdec_Metric = { #endif }; -static PyObject *__pyx_tp_new_5_cdec_Decoder(PyTypeObject *t, PyObject *a, PyObject *k) { +static PyObject *__pyx_tp_new_5_cdec_Decoder(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { struct __pyx_obj_5_cdec_Decoder *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; p = ((struct __pyx_obj_5_cdec_Decoder *)o); p->weights = ((struct __pyx_obj_5_cdec_DenseVector *)Py_None); Py_INCREF(Py_None); - if (__pyx_pw_5_cdec_7Decoder_1__cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } return o; } @@ -23006,7 +23125,7 @@ static void __pyx_tp_dealloc_5_cdec_Decoder(PyObject *o) { --Py_REFCNT(o); PyErr_Restore(etype, eval, etb); } - Py_XDECREF(((PyObject *)p->weights)); + Py_CLEAR(p->weights); (*Py_TYPE(o)->tp_free)(o); } @@ -23047,8 +23166,8 @@ static PyObject *__pyx_getprop_5_cdec_7Decoder_formalism(PyObject *o, CYTHON_UNU } static PyMethodDef __pyx_methods_5_cdec_Decoder[] = { - {__Pyx_NAMESTR("read_weights"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_5read_weights, METH_O, __Pyx_DOCSTR(0)}, - {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_7translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)}, + {__Pyx_NAMESTR("read_weights"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_5read_weights, METH_O, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Decoder_4read_weights)}, + {__Pyx_NAMESTR("translate"), (PyCFunction)__pyx_pw_5_cdec_7Decoder_7translate, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5_cdec_7Decoder_6translate)}, {0, 0, 0, 0} }; @@ -23196,7 +23315,7 @@ static PyTypeObject __pyx_type_5_cdec_Decoder = { 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ - 0, /*tp_init*/ + __pyx_pw_5_cdec_7Decoder_1__init__, /*tp_init*/ 0, /*tp_alloc*/ __pyx_tp_new_5_cdec_Decoder, /*tp_new*/ 0, /*tp_free*/ @@ -23223,7 +23342,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct____iter__(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct____iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct____iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -23414,7 +23533,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_1___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_1___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_1___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -23605,7 +23724,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_2__phrase(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_2__phrase(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_2__phrase *)o; - Py_XDECREF(p->__pyx_v_phrase); + Py_CLEAR(p->__pyx_v_phrase); (*Py_TYPE(o)->tp_free)(o); } @@ -23798,9 +23917,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_3_genexpr(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_3_genexpr(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_3_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_w); - Py_XDECREF(p->__pyx_t_0); + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_w); + Py_CLEAR(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } @@ -24003,7 +24122,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_4___get__(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_4___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_4___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -24194,7 +24313,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_5___str__(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_5___str__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_5___str__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -24387,9 +24506,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_6_genexpr(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_6_genexpr(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_6_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_feat); - Py_XDECREF(p->__pyx_t_0); + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_feat); + Py_CLEAR(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } @@ -24593,8 +24712,8 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_7___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_7___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_7___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(((PyObject *)p->__pyx_v_trule)); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_trule); (*Py_TYPE(o)->tp_free)(o); } @@ -24792,8 +24911,8 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_8_kbest(PyTypeObject *t, static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_8_kbest(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_8_kbest *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_v_size); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_size); (*Py_TYPE(o)->tp_free)(o); } @@ -24993,10 +25112,10 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_9_kbest_trees(PyTypeObje static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_9_kbest_trees(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_9_kbest_trees *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_e_tree)); - Py_XDECREF(((PyObject *)p->__pyx_v_f_tree)); - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_v_size); + Py_CLEAR(p->__pyx_v_e_tree); + Py_CLEAR(p->__pyx_v_f_tree); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_size); (*Py_TYPE(o)->tp_free)(o); } @@ -25207,9 +25326,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_10_kbest_features(PyType static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_10_kbest_features(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_10_kbest_features *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_fmap)); - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_v_size); + Py_CLEAR(p->__pyx_v_fmap); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_v_size); (*Py_TYPE(o)->tp_free)(o); } @@ -25412,7 +25531,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_11_sample(PyTypeObject * static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_11_sample(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_11_sample *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25603,7 +25722,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_12_sample_trees(PyTypeOb static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_12_sample_trees(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_12_sample_trees *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25794,7 +25913,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_13___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_13___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_13___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -25985,7 +26104,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_14___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_14___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_14___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -26176,7 +26295,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_15___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_15___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_15___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -26367,7 +26486,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_16___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_16___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_16___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -26558,7 +26677,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_17___get__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_17___get__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_17___get__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -26749,7 +26868,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_18___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_18___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_18___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -26940,7 +27059,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_19_todot(PyTypeObject *t static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_19_todot(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_19_todot *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -27137,13 +27256,13 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_20_lines(PyTypeObject *t static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_20_lines(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_20_lines *)o; - Py_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_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_delta); + Py_CLEAR(p->__pyx_v_i); + Py_CLEAR(p->__pyx_v_label); + Py_CLEAR(p->__pyx_v_weight); + Py_CLEAR(p->__pyx_t_1); + Py_CLEAR(p->__pyx_t_3); (*Py_TYPE(o)->tp_free)(o); } @@ -27372,9 +27491,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_21___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_21___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_21___iter__ *)o; - Py_XDECREF(p->__pyx_v_i); - Py_XDECREF(((PyObject *)p->__pyx_v_self)); - Py_XDECREF(p->__pyx_t_1); + Py_CLEAR(p->__pyx_v_i); + Py_CLEAR(p->__pyx_v_self); + Py_CLEAR(p->__pyx_t_1); (*Py_TYPE(o)->tp_free)(o); } @@ -27577,7 +27696,7 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_22___iter__(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_22___iter__(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_22___iter__ *)o; - Py_XDECREF(((PyObject *)p->__pyx_v_self)); + Py_CLEAR(p->__pyx_v_self); (*Py_TYPE(o)->tp_free)(o); } @@ -27774,13 +27893,13 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_23__make_config(PyTypeOb static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_23__make_config(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_23__make_config *)o; - Py_XDECREF(p->__pyx_v_config); - Py_XDECREF(p->__pyx_v_info); - Py_XDECREF(p->__pyx_v_key); - Py_XDECREF(p->__pyx_v_name); - Py_XDECREF(p->__pyx_v_value); - Py_XDECREF(p->__pyx_t_0); - Py_XDECREF(p->__pyx_t_1); + Py_CLEAR(p->__pyx_v_config); + Py_CLEAR(p->__pyx_v_info); + Py_CLEAR(p->__pyx_v_key); + Py_CLEAR(p->__pyx_v_name); + Py_CLEAR(p->__pyx_v_value); + Py_CLEAR(p->__pyx_t_0); + Py_CLEAR(p->__pyx_t_1); (*Py_TYPE(o)->tp_free)(o); } @@ -27996,32 +28115,32 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_23__make_config = { #endif }; -static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_24___cinit__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *p; +static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_24___init__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p; PyObject *o = (*t->tp_alloc)(t, 0); if (!o) return 0; - p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *)o); + p = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o); p->__pyx_v_config = 0; return o; } -static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24___cinit__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *)o; - Py_XDECREF(p->__pyx_v_config); +static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24___init__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o; + Py_CLEAR(p->__pyx_v_config); (*Py_TYPE(o)->tp_free)(o); } -static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_24___cinit__(PyObject *o, visitproc v, void *a) { +static int __pyx_tp_traverse_5_cdec___pyx_scope_struct_24___init__(PyObject *o, visitproc v, void *a) { int e; - struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *)o; + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o; if (p->__pyx_v_config) { e = (*v)(p->__pyx_v_config, a); if (e) return e; } return 0; } -static int __pyx_tp_clear_5_cdec___pyx_scope_struct_24___cinit__(PyObject *o) { - struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *)o; +static int __pyx_tp_clear_5_cdec___pyx_scope_struct_24___init__(PyObject *o) { + struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_v_config); p->__pyx_v_config = Py_None; Py_INCREF(Py_None); @@ -28029,11 +28148,11 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_24___cinit__(PyObject *o) { return 0; } -static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_24___cinit__[] = { +static PyMethodDef __pyx_methods_5_cdec___pyx_scope_struct_24___init__[] = { {0, 0, 0, 0} }; -static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24___cinit__ = { +static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24___init__ = { 0, /*nb_add*/ 0, /*nb_subtract*/ 0, /*nb_multiply*/ @@ -28091,7 +28210,7 @@ static PyNumberMethods __pyx_tp_as_number___pyx_scope_struct_24___cinit__ = { #endif }; -static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_24___cinit__ = { +static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_24___init__ = { 0, /*sq_length*/ 0, /*sq_concat*/ 0, /*sq_repeat*/ @@ -28104,13 +28223,13 @@ static PySequenceMethods __pyx_tp_as_sequence___pyx_scope_struct_24___cinit__ = 0, /*sq_inplace_repeat*/ }; -static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_24___cinit__ = { +static PyMappingMethods __pyx_tp_as_mapping___pyx_scope_struct_24___init__ = { 0, /*mp_length*/ 0, /*mp_subscript*/ 0, /*mp_ass_subscript*/ }; -static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24___cinit__ = { +static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24___init__ = { #if PY_MAJOR_VERSION < 3 0, /*bf_getreadbuffer*/ #endif @@ -28131,12 +28250,12 @@ static PyBufferProcs __pyx_tp_as_buffer___pyx_scope_struct_24___cinit__ = { #endif }; -static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24___cinit__ = { +static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24___init__ = { PyVarObject_HEAD_INIT(0, 0) - __Pyx_NAMESTR("_cdec.__pyx_scope_struct_24___cinit__"), /*tp_name*/ - sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__), /*tp_basicsize*/ + __Pyx_NAMESTR("_cdec.__pyx_scope_struct_24___init__"), /*tp_name*/ + sizeof(struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__), /*tp_basicsize*/ 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24___cinit__, /*tp_dealloc*/ + __pyx_tp_dealloc_5_cdec___pyx_scope_struct_24___init__, /*tp_dealloc*/ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ @@ -28146,24 +28265,24 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24___cinit__ = { 0, /*reserved*/ #endif 0, /*tp_repr*/ - &__pyx_tp_as_number___pyx_scope_struct_24___cinit__, /*tp_as_number*/ - &__pyx_tp_as_sequence___pyx_scope_struct_24___cinit__, /*tp_as_sequence*/ - &__pyx_tp_as_mapping___pyx_scope_struct_24___cinit__, /*tp_as_mapping*/ + &__pyx_tp_as_number___pyx_scope_struct_24___init__, /*tp_as_number*/ + &__pyx_tp_as_sequence___pyx_scope_struct_24___init__, /*tp_as_sequence*/ + &__pyx_tp_as_mapping___pyx_scope_struct_24___init__, /*tp_as_mapping*/ 0, /*tp_hash*/ 0, /*tp_call*/ 0, /*tp_str*/ 0, /*tp_getattro*/ 0, /*tp_setattro*/ - &__pyx_tp_as_buffer___pyx_scope_struct_24___cinit__, /*tp_as_buffer*/ + &__pyx_tp_as_buffer___pyx_scope_struct_24___init__, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ 0, /*tp_doc*/ - __pyx_tp_traverse_5_cdec___pyx_scope_struct_24___cinit__, /*tp_traverse*/ - __pyx_tp_clear_5_cdec___pyx_scope_struct_24___cinit__, /*tp_clear*/ + __pyx_tp_traverse_5_cdec___pyx_scope_struct_24___init__, /*tp_traverse*/ + __pyx_tp_clear_5_cdec___pyx_scope_struct_24___init__, /*tp_clear*/ 0, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ 0, /*tp_iter*/ 0, /*tp_iternext*/ - __pyx_methods_5_cdec___pyx_scope_struct_24___cinit__, /*tp_methods*/ + __pyx_methods_5_cdec___pyx_scope_struct_24___init__, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ 0, /*tp_base*/ @@ -28173,7 +28292,7 @@ static PyTypeObject __pyx_type_5_cdec___pyx_scope_struct_24___cinit__ = { 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - __pyx_tp_new_5_cdec___pyx_scope_struct_24___cinit__, /*tp_new*/ + __pyx_tp_new_5_cdec___pyx_scope_struct_24___init__, /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ 0, /*tp_bases*/ @@ -28200,9 +28319,9 @@ static PyObject *__pyx_tp_new_5_cdec___pyx_scope_struct_25_genexpr(PyTypeObject static void __pyx_tp_dealloc_5_cdec___pyx_scope_struct_25_genexpr(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)o; - Py_XDECREF(((PyObject *)p->__pyx_outer_scope)); - Py_XDECREF(p->__pyx_v_kv); - Py_XDECREF(p->__pyx_t_0); + Py_CLEAR(p->__pyx_outer_scope); + Py_CLEAR(p->__pyx_v_kv); + Py_CLEAR(p->__pyx_t_0); (*Py_TYPE(o)->tp_free)(o); } @@ -28225,7 +28344,7 @@ static int __pyx_tp_clear_5_cdec___pyx_scope_struct_25_genexpr(PyObject *o) { struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *p = (struct __pyx_obj_5_cdec___pyx_scope_struct_25_genexpr *)o; PyObject* tmp; tmp = ((PyObject*)p->__pyx_outer_scope); - p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24___cinit__ *)Py_None); Py_INCREF(Py_None); + p->__pyx_outer_scope = ((struct __pyx_obj_5_cdec___pyx_scope_struct_24___init__ *)Py_None); Py_INCREF(Py_None); Py_XDECREF(tmp); tmp = ((PyObject*)p->__pyx_v_kv); p->__pyx_v_kv = Py_None; Py_INCREF(Py_None); @@ -28422,32 +28541,32 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0}, {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0}, {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0}, + {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0}, {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0}, - {&__pyx_kp_s_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_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0}, {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0}, {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0}, {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0}, {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0}, - {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0}, {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0}, - {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0}, - {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0}, - {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0}, + {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0}, + {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0}, + {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0}, {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0}, {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0}, {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0}, {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0}, - {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0}, + {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0}, {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0}, + {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0}, {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0}, - {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0}, - {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0}, - {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0}, - {&__pyx_n_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 1}, - {&__pyx_n_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 1}, - {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0}, - {&__pyx_kp_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 0}, + {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0}, + {&__pyx_n_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 1}, + {&__pyx_n_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 1}, + {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0}, + {&__pyx_kp_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 0}, {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0}, {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0}, {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0}, @@ -28546,14 +28665,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = { static int __Pyx_InitCachedBuiltins(void) { __pyx_builtin_Exception = __Pyx_GetName(__pyx_b, __pyx_n_s__Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 22; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_NotImplemented = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_basestring = __Pyx_GetName(__pyx_b, __pyx_n_s__basestring); if (!__pyx_builtin_basestring) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 34; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_NotImplemented = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplemented); if (!__pyx_builtin_NotImplemented) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_super = __Pyx_GetName(__pyx_b, __pyx_n_s__super); if (!__pyx_builtin_super) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_basestring = __Pyx_GetName(__pyx_b, __pyx_n_s__basestring); if (!__pyx_builtin_basestring) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_eval = __Pyx_GetName(__pyx_b, __pyx_n_s__eval); if (!__pyx_builtin_eval) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_IndexError = __Pyx_GetName(__pyx_b, __pyx_n_s__IndexError); if (!__pyx_builtin_IndexError) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} return 0; @@ -28579,21 +28698,21 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2)); - /* "/Users/vchahun/Sandbox/cdec/python/src/vectors.pxi":89 + /* "/home/vchahune/tools/cdec/python/src/vectors.pxi":95 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for SparseVector') # <<<<<<<<<<<<<< * * def __len__(self): */ - __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_5 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_5); __Pyx_INCREF(((PyObject *)__pyx_kp_s_4)); PyTuple_SET_ITEM(__pyx_k_tuple_5, 0, ((PyObject *)__pyx_kp_s_4)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_4)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_5)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":6 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":6 * * def _phrase(phrase): * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) # <<<<<<<<<<<<<< @@ -28607,200 +28726,172 @@ static int __Pyx_InitCachedConstants(void) { __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_6)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":209 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":226 * trule = convert_rule(trule) * elif not isinstance(trule, TRule): * raise ValueError('the grammar should contain TRule objects') # <<<<<<<<<<<<<< * _g.AddRule(( trule).rule[0]) */ - __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_14 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_14); __Pyx_INCREF(((PyObject *)__pyx_kp_s_13)); PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":214 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":235 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphEdge') # <<<<<<<<<<<<<< * * cdef class HypergraphNode: */ - __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 214; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_19 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_19)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_19); __Pyx_INCREF(((PyObject *)__pyx_kp_s_18)); PyTuple_SET_ITEM(__pyx_k_tuple_19, 0, ((PyObject *)__pyx_kp_s_18)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_19)); - /* "/Users/vchahun/Sandbox/cdec/python/src/hypergraph.pxi":251 + /* "/home/vchahune/tools/cdec/python/src/hypergraph.pxi":272 * elif op == 3: # != * return not (x == y) * raise NotImplemented('comparison not implemented for HypergraphNode') # <<<<<<<<<<<<<< */ - __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_k_tuple_21 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_21)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 272; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_k_tuple_21); __Pyx_INCREF(((PyObject *)__pyx_kp_s_20)); PyTuple_SET_ITEM(__pyx_k_tuple_21, 0, ((PyObject *)__pyx_kp_s_20)); __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20)); __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_21)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":16 - * else: - * if isinstance(inp, unicode): - * inp = inp.encode('utf8') # <<<<<<<<<<<<<< - * if not isinstance(inp, str): - * raise TypeError('cannot create lattice from %s' % type(inp)) - */ - __pyx_k_tuple_22 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_22); - __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_22, 0, ((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":26 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":26 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * arcs = [] * cdef vector[lattice.LatticeArc] arc_vector = self.lattice[0][index] */ - __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_25); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_24)); - PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_kp_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); + __pyx_k_tuple_24 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_24)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_24); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_23)); + PyTuple_SET_ITEM(__pyx_k_tuple_24, 0, ((PyObject *)__pyx_kp_s_23)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_24)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":39 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":39 * def __setitem__(self, int index, tuple arcs): * if not 0 <= index < len(self): * raise IndexError('lattice index out of range') # <<<<<<<<<<<<<< * cdef lattice.LatticeArc* arc * for (label, cost, dist2next) in arcs: */ - __pyx_k_tuple_26 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_26)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_26); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_24)); - PyTuple_SET_ITEM(__pyx_k_tuple_26, 0, ((PyObject *)__pyx_kp_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_26)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":43 - * for (label, cost, dist2next) in arcs: - * if isinstance(label, unicode): - * label = label.encode('utf8') # <<<<<<<<<<<<<< - * arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) - * self.lattice[0][index].push_back(arc[0]) - */ - __pyx_k_tuple_27 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_27)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_27); - __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_27, 0, ((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s__utf8)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_27)); + __pyx_k_tuple_25 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_25); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_23)); + PyTuple_SET_ITEM(__pyx_k_tuple_25, 0, ((PyObject *)__pyx_kp_s_23)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25)); - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":69 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":69 * for i in range(len(self)): * for label, weight, delta in self[i]: * yield '%d -> %d [label="%s"];' % (i, i+delta, label.replace('"', '\\"')) # <<<<<<<<<<<<<< * yield '%d [shape=doublecircle]' % len(self) * yield '}' */ - __pyx_k_tuple_34 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_34); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_32)); - PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, ((PyObject *)__pyx_kp_s_32)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32)); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_33)); - PyTuple_SET_ITEM(__pyx_k_tuple_34, 1, ((PyObject *)__pyx_kp_s_33)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34)); - - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":63 - * + __pyx_k_tuple_32 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_32); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_30)); + PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_30)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30)); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_31)); + PyTuple_SET_ITEM(__pyx_k_tuple_32, 1, ((PyObject *)__pyx_kp_s_31)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32)); + + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":63 * def todot(self): + * """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" * def lines(): # <<<<<<<<<<<<<< * yield 'digraph lattice {' * yield 'rankdir = LR;' */ - __pyx_k_tuple_37 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_37); + __pyx_k_tuple_35 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_35)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_35); __Pyx_INCREF(((PyObject *)__pyx_n_s__i)); - PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_n_s__i)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 0, ((PyObject *)__pyx_n_s__i)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__i)); __Pyx_INCREF(((PyObject *)__pyx_n_s__label)); - PyTuple_SET_ITEM(__pyx_k_tuple_37, 1, ((PyObject *)__pyx_n_s__label)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 1, ((PyObject *)__pyx_n_s__label)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__label)); __Pyx_INCREF(((PyObject *)__pyx_n_s__weight)); - PyTuple_SET_ITEM(__pyx_k_tuple_37, 2, ((PyObject *)__pyx_n_s__weight)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 2, ((PyObject *)__pyx_n_s__weight)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__weight)); __Pyx_INCREF(((PyObject *)__pyx_n_s__delta)); - PyTuple_SET_ITEM(__pyx_k_tuple_37, 3, ((PyObject *)__pyx_n_s__delta)); + PyTuple_SET_ITEM(__pyx_k_tuple_35, 3, ((PyObject *)__pyx_n_s__delta)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__delta)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37)); - __pyx_k_codeobj_38 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_37, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_39, __pyx_n_s__lines, 63, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_38)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_35)); + __pyx_k_codeobj_36 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_35, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_37, __pyx_n_s__lines, 63, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_36)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/lattice.pxi":72 + /* "/home/vchahune/tools/cdec/python/src/lattice.pxi":72 * yield '%d [shape=doublecircle]' % len(self) * yield '}' * return '\n'.join(lines()).encode('utf8') # <<<<<<<<<<<<<< * * def as_hypergraph(self): */ - __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_41); + __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_39); __Pyx_INCREF(((PyObject *)__pyx_n_s__utf8)); - PyTuple_SET_ITEM(__pyx_k_tuple_41, 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_41)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":50 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":50 * def __getitem__(self, int index): * if not 0 <= index < len(self): * raise IndexError('sufficient stats vector index out of range') # <<<<<<<<<<<<<< * return self.stats[0][index] * */ - __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_43); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_42)); - PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_42)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43)); + __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_41); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_40)); + PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_40)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":84 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":84 * def __getitem__(self,int k): * if not 0 <= k < self.cs.size(): * raise IndexError('candidate set index out of range') # <<<<<<<<<<<<<< * cdef Candidate candidate = Candidate() * candidate.candidate = &self.cs[0][k] */ - __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_45); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_44)); - PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_s_44)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45)); + __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_43); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_42)); + PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_42)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43)); - /* "_cdec.pyx":53 - * """ + /* "_cdec.pyx":52 + * Create a decoder using a given configuration. Formalism is required.""" * if config_str is None: * formalism = config.get('formalism', None) # <<<<<<<<<<<<<< * if formalism not in ('scfg', 'fst', 'lextrans', 'pb', * 'csplit', 'tagger', 'lexalign'): */ - __pyx_k_tuple_48 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_48); + __pyx_k_tuple_46 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_46)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_46); __Pyx_INCREF(((PyObject *)__pyx_n_s__formalism)); - PyTuple_SET_ITEM(__pyx_k_tuple_48, 0, ((PyObject *)__pyx_n_s__formalism)); + PyTuple_SET_ITEM(__pyx_k_tuple_46, 0, ((PyObject *)__pyx_n_s__formalism)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__formalism)); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_48, 1, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_46, 1, Py_None); __Pyx_GIVEREF(Py_None); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_46)); /* "_cdec.pyx":93 * with open(weights) as fp: @@ -28809,134 +28900,134 @@ static int __Pyx_InitCachedConstants(void) { * fname, value = line.split() * self.weights[fname.strip()] = float(value) */ - __pyx_k_tuple_52 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_52); - __Pyx_INCREF(((PyObject *)__pyx_kp_s_51)); - PyTuple_SET_ITEM(__pyx_k_tuple_52, 0, ((PyObject *)__pyx_kp_s_51)); - __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52)); + __pyx_k_tuple_50 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_50); + __Pyx_INCREF(((PyObject *)__pyx_kp_s_49)); + PyTuple_SET_ITEM(__pyx_k_tuple_50, 0, ((PyObject *)__pyx_kp_s_49)); + __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_49)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50)); /* "_cdec.pyx":91 - * * def read_weights(self, weights): + * """decoder.read_weights(filename): Read decoder weights from a file.""" * with open(weights) as fp: # <<<<<<<<<<<<<< * for line in fp: * if line.strip().startswith('#'): continue */ - __pyx_k_tuple_53 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_53); + __pyx_k_tuple_51 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_51); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_53, 0, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, Py_None); __Pyx_GIVEREF(Py_None); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_53, 1, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 1, Py_None); __Pyx_GIVEREF(Py_None); __Pyx_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_k_tuple_53, 2, Py_None); + PyTuple_SET_ITEM(__pyx_k_tuple_51, 2, Py_None); __Pyx_GIVEREF(Py_None); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51)); - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< * return ' '.join(w.encode('utf8') if isinstance(w, unicode) else str(w) for w in phrase) * */ - __pyx_k_tuple_57 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_57); + __pyx_k_tuple_55 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_55); __Pyx_INCREF(((PyObject *)__pyx_n_s__phrase)); - PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_n_s__phrase)); + PyTuple_SET_ITEM(__pyx_k_tuple_55, 0, ((PyObject *)__pyx_n_s__phrase)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__phrase)); __Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr)); - PyTuple_SET_ITEM(__pyx_k_tuple_57, 1, ((PyObject *)__pyx_n_s__genexpr)); + PyTuple_SET_ITEM(__pyx_k_tuple_55, 1, ((PyObject *)__pyx_n_s__genexpr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr)); __Pyx_INCREF(((PyObject *)__pyx_n_s__genexpr)); - PyTuple_SET_ITEM(__pyx_k_tuple_57, 2, ((PyObject *)__pyx_n_s__genexpr)); + PyTuple_SET_ITEM(__pyx_k_tuple_55, 2, ((PyObject *)__pyx_n_s__genexpr)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__genexpr)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57)); - __pyx_k_codeobj_58 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_59, __pyx_n_s___phrase, 5, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_58)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55)); + __pyx_k_codeobj_56 = (PyObject*)__Pyx_PyCode_New(1, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_55, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_57, __pyx_n_s___phrase, 5, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_56)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":189 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":194 * return [] * * BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<< * TER = Scorer('TER') * CER = Scorer('CER') */ - __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_60); + __pyx_k_tuple_58 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_58)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_58); __Pyx_INCREF(((PyObject *)__pyx_n_s__IBM_BLEU)); - PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__IBM_BLEU)); + PyTuple_SET_ITEM(__pyx_k_tuple_58, 0, ((PyObject *)__pyx_n_s__IBM_BLEU)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IBM_BLEU)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_58)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":195 * * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') # <<<<<<<<<<<<<< * CER = Scorer('CER') */ - __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_61); + __pyx_k_tuple_59 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_59); __Pyx_INCREF(((PyObject *)__pyx_n_s__TER)); - PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__TER)); + PyTuple_SET_ITEM(__pyx_k_tuple_59, 0, ((PyObject *)__pyx_n_s__TER)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__TER)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59)); - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":196 * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') * CER = Scorer('CER') # <<<<<<<<<<<<<< */ - __pyx_k_tuple_62 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_62)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_62); + __pyx_k_tuple_60 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_60); __Pyx_INCREF(((PyObject *)__pyx_n_s__CER)); - PyTuple_SET_ITEM(__pyx_k_tuple_62, 0, ((PyObject *)__pyx_n_s__CER)); + PyTuple_SET_ITEM(__pyx_k_tuple_60, 0, ((PyObject *)__pyx_n_s__CER)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CER)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_62)); + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60)); /* "_cdec.pyx":28 * class ParseFailed(Exception): pass * * def set_silent(yn): # <<<<<<<<<<<<<< + * """set_silent(bool): Configure the verbosity of cdec.""" * SetSilent(yn) - * */ - __pyx_k_tuple_63 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_63); + __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_61); __Pyx_INCREF(((PyObject *)__pyx_n_s__yn)); - PyTuple_SET_ITEM(__pyx_k_tuple_63, 0, ((PyObject *)__pyx_n_s__yn)); + PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_n_s__yn)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__yn)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63)); - __pyx_k_codeobj_64 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_65, __pyx_n_s__set_silent, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61)); + __pyx_k_codeobj_62 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s__set_silent, 28, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_62)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - /* "_cdec.pyx":31 + /* "_cdec.pyx":32 * SetSilent(yn) * * def _make_config(config): # <<<<<<<<<<<<<< * for key, value in config.items(): * if isinstance(value, dict): */ - __pyx_k_tuple_66 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __Pyx_GOTREF(__pyx_k_tuple_66); + __pyx_k_tuple_64 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GOTREF(__pyx_k_tuple_64); __Pyx_INCREF(((PyObject *)__pyx_n_s__config)); - PyTuple_SET_ITEM(__pyx_k_tuple_66, 0, ((PyObject *)__pyx_n_s__config)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 0, ((PyObject *)__pyx_n_s__config)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__config)); __Pyx_INCREF(((PyObject *)__pyx_n_s__key)); - PyTuple_SET_ITEM(__pyx_k_tuple_66, 1, ((PyObject *)__pyx_n_s__key)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 1, ((PyObject *)__pyx_n_s__key)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__key)); __Pyx_INCREF(((PyObject *)__pyx_n_s__value)); - PyTuple_SET_ITEM(__pyx_k_tuple_66, 2, ((PyObject *)__pyx_n_s__value)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 2, ((PyObject *)__pyx_n_s__value)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__value)); __Pyx_INCREF(((PyObject *)__pyx_n_s__name)); - PyTuple_SET_ITEM(__pyx_k_tuple_66, 3, ((PyObject *)__pyx_n_s__name)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 3, ((PyObject *)__pyx_n_s__name)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__name)); __Pyx_INCREF(((PyObject *)__pyx_n_s__info)); - PyTuple_SET_ITEM(__pyx_k_tuple_66, 4, ((PyObject *)__pyx_n_s__info)); + PyTuple_SET_ITEM(__pyx_k_tuple_64, 4, ((PyObject *)__pyx_n_s__info)); __Pyx_GIVEREF(((PyObject *)__pyx_n_s__info)); - __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_66)); - __pyx_k_codeobj_67 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_66, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_65, __pyx_n_s___make_config, 31, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64)); + __pyx_k_codeobj_65 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_64, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_63, __pyx_n_s___make_config, 32, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_RefNannyFinishContext(); return 0; __pyx_L1_error:; @@ -28997,16 +29088,12 @@ PyMODINIT_FUNC PyInit__cdec(void) #endif /*--- Module creation code ---*/ #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_cdec"), __pyx_methods, 0, 0, PYTHON_API_VERSION); + __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_cdec"), __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); #else __pyx_m = PyModule_Create(&__pyx_moduledef); #endif - if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; - #if PY_MAJOR_VERSION < 3 - Py_INCREF(__pyx_m); - #endif - __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); - if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}; + if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} #if CYTHON_COMPILING_IN_PYPY Py_INCREF(__pyx_b); #endif @@ -29025,30 +29112,100 @@ PyMODINIT_FUNC PyInit__cdec(void) /*--- Function export code ---*/ /*--- Type init code ---*/ if (PyType_Ready(&__pyx_type_5_cdec_DenseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_DenseVector, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_11DenseVector___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_11DenseVector___init__.doc = __pyx_doc_5_cdec_11DenseVector___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_11DenseVector___init__; + } + } + #endif if (__Pyx_SetAttrString(__pyx_m, "DenseVector", (PyObject *)&__pyx_type_5_cdec_DenseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_DenseVector = &__pyx_type_5_cdec_DenseVector; - if (PyType_Ready(&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "SparseVector", (PyObject *)&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_SparseVector, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_12SparseVector___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_12SparseVector___init__.doc = __pyx_doc_5_cdec_12SparseVector___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_12SparseVector___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "SparseVector", (PyObject *)&__pyx_type_5_cdec_SparseVector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_SparseVector = &__pyx_type_5_cdec_SparseVector; if (PyType_Ready(&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_NT, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_2NT___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_2NT___init__.doc = __pyx_doc_5_cdec_2NT___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_2NT___init__; + } + } + #endif if (__Pyx_SetAttrString(__pyx_m, "NT", (PyObject *)&__pyx_type_5_cdec_NT) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_NT = &__pyx_type_5_cdec_NT; - if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_NTRef, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_5NTRef___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_5NTRef___init__.doc = __pyx_doc_5_cdec_5NTRef___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_5NTRef___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "NTRef", (PyObject *)&__pyx_type_5_cdec_NTRef) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_NTRef = &__pyx_type_5_cdec_NTRef; - if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_TRule, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_5TRule___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_5TRule___init__.doc = __pyx_doc_5_cdec_5TRule___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_5TRule___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "TRule", (PyObject *)&__pyx_type_5_cdec_TRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_TRule = &__pyx_type_5_cdec_TRule; __pyx_type_5_cdec_MRule.tp_base = __pyx_ptype_5_cdec_TRule; - if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 166; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_MRule, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_5MRule___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_5MRule___init__.doc = __pyx_doc_5_cdec_5MRule___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_5MRule___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "MRule", (PyObject *)&__pyx_type_5_cdec_MRule) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_MRule = &__pyx_type_5_cdec_MRule; - if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Grammar", (PyObject *)&__pyx_type_5_cdec_Grammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Grammar = &__pyx_type_5_cdec_Grammar; __pyx_type_5_cdec_TextGrammar.tp_base = __pyx_ptype_5_cdec_Grammar; - if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 201; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_TextGrammar, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_11TextGrammar___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_11TextGrammar___init__.doc = __pyx_doc_5_cdec_11TextGrammar___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_11TextGrammar___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "TextGrammar", (PyObject *)&__pyx_type_5_cdec_TextGrammar) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_TextGrammar = &__pyx_type_5_cdec_TextGrammar; __pyx_vtabptr_5_cdec_Hypergraph = &__pyx_vtable_5_cdec_Hypergraph; __pyx_vtable_5_cdec_Hypergraph._rng = (MT19937 *(*)(struct __pyx_obj_5_cdec_Hypergraph *))__pyx_f_5_cdec_10Hypergraph__rng; @@ -29058,17 +29215,27 @@ PyMODINIT_FUNC PyInit__cdec(void) __pyx_ptype_5_cdec_Hypergraph = &__pyx_type_5_cdec_Hypergraph; __pyx_vtabptr_5_cdec_HypergraphEdge = &__pyx_vtable_5_cdec_HypergraphEdge; __pyx_vtable_5_cdec_HypergraphEdge.init = (PyObject *(*)(struct __pyx_obj_5_cdec_HypergraphEdge *, Hypergraph *, unsigned int))__pyx_f_5_cdec_14HypergraphEdge_init; - if (PyType_Ready(&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphEdge.tp_dict, __pyx_vtabptr_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HypergraphEdge", (PyObject *)&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphEdge.tp_dict, __pyx_vtabptr_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HypergraphEdge", (PyObject *)&__pyx_type_5_cdec_HypergraphEdge) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_HypergraphEdge = &__pyx_type_5_cdec_HypergraphEdge; __pyx_vtabptr_5_cdec_HypergraphNode = &__pyx_vtable_5_cdec_HypergraphNode; __pyx_vtable_5_cdec_HypergraphNode.init = (PyObject *(*)(struct __pyx_obj_5_cdec_HypergraphNode *, Hypergraph *, unsigned int))__pyx_f_5_cdec_14HypergraphNode_init; - if (PyType_Ready(&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphNode.tp_dict, __pyx_vtabptr_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "HypergraphNode", (PyObject *)&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetVtable(__pyx_type_5_cdec_HypergraphNode.tp_dict, __pyx_vtabptr_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "HypergraphNode", (PyObject *)&__pyx_type_5_cdec_HypergraphNode) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 237; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_HypergraphNode = &__pyx_type_5_cdec_HypergraphNode; if (PyType_Ready(&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_Lattice, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_7Lattice_2__init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_7Lattice_2__init__.doc = __pyx_doc_5_cdec_7Lattice_2__init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_7Lattice_2__init__; + } + } + #endif if (__Pyx_SetAttrString(__pyx_m, "Lattice", (PyObject *)&__pyx_type_5_cdec_Lattice) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Lattice = &__pyx_type_5_cdec_Lattice; if (PyType_Ready(&__pyx_type_5_cdec_Candidate) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -29080,57 +29247,67 @@ PyMODINIT_FUNC PyInit__cdec(void) if (PyType_Ready(&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} if (__Pyx_SetAttrString(__pyx_m, "CandidateSet", (PyObject *)&__pyx_type_5_cdec_CandidateSet) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_CandidateSet = &__pyx_type_5_cdec_CandidateSet; - if (PyType_Ready(&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "SegmentEvaluator", (PyObject *)&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "SegmentEvaluator", (PyObject *)&__pyx_type_5_cdec_SegmentEvaluator) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_SegmentEvaluator = &__pyx_type_5_cdec_SegmentEvaluator; - if (PyType_Ready(&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Scorer", (PyObject *)&__pyx_type_5_cdec_Scorer) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Scorer = &__pyx_type_5_cdec_Scorer; - if (PyType_Ready(&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - if (__Pyx_SetAttrString(__pyx_m, "Metric", (PyObject *)&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (__Pyx_SetAttrString(__pyx_m, "Metric", (PyObject *)&__pyx_type_5_cdec_Metric) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Metric = &__pyx_type_5_cdec_Metric; - if (PyType_Ready(&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __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 = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + #if CYTHON_COMPILING_IN_CPYTHON + { + PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5_cdec_Decoder, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) { + __pyx_wrapperbase_5_cdec_7Decoder___init__ = *((PyWrapperDescrObject *)wrapper)->d_base; + __pyx_wrapperbase_5_cdec_7Decoder___init__.doc = __pyx_doc_5_cdec_7Decoder___init__; + ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5_cdec_7Decoder___init__; + } + } + #endif + if (__Pyx_SetAttrString(__pyx_m, "Decoder", (PyObject *)&__pyx_type_5_cdec_Decoder) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec_Decoder = &__pyx_type_5_cdec_Decoder; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct____iter__ = &__pyx_type_5_cdec___pyx_scope_struct____iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_1___iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_1___iter__) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_1___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_1___iter__; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_2__phrase) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_2__phrase = &__pyx_type_5_cdec___pyx_scope_struct_2__phrase; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_3_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_3_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_3_genexpr; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_4___get__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_4___get__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_4___get__ = &__pyx_type_5_cdec___pyx_scope_struct_4___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_5___str__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_5___str__ = &__pyx_type_5_cdec___pyx_scope_struct_5___str__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_6_genexpr) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_6_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_6_genexpr; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_7___iter__) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_7___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_7___iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_kbest) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_8_kbest) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_8_kbest = &__pyx_type_5_cdec___pyx_scope_struct_8_kbest; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_9_kbest_trees = &__pyx_type_5_cdec___pyx_scope_struct_9_kbest_trees; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_10_kbest_features) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_10_kbest_features) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_10_kbest_features = &__pyx_type_5_cdec___pyx_scope_struct_10_kbest_features; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_11_sample) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_11_sample) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_11_sample = &__pyx_type_5_cdec___pyx_scope_struct_11_sample; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_12_sample_trees = &__pyx_type_5_cdec___pyx_scope_struct_12_sample_trees; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_13___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_13___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_13___get__ = &__pyx_type_5_cdec___pyx_scope_struct_13___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_14___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_14___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_14___get__ = &__pyx_type_5_cdec___pyx_scope_struct_14___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_15___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_15___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 211; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_15___get__ = &__pyx_type_5_cdec___pyx_scope_struct_15___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_16___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_16___get__ = &__pyx_type_5_cdec___pyx_scope_struct_16___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_17___get__) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_17___get__ = &__pyx_type_5_cdec___pyx_scope_struct_17___get__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_18___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_18___iter__) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_18___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_18___iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_19_todot) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_19_todot) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_19_todot = &__pyx_type_5_cdec___pyx_scope_struct_19_todot; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_20_lines) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_20_lines = &__pyx_type_5_cdec___pyx_scope_struct_20_lines; @@ -29138,21 +29315,21 @@ PyMODINIT_FUNC PyInit__cdec(void) __pyx_ptype_5_cdec___pyx_scope_struct_21___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_21___iter__; if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_22___iter__) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_22___iter__ = &__pyx_type_5_cdec___pyx_scope_struct_22___iter__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_23__make_config) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_23__make_config) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_23__make_config = &__pyx_type_5_cdec___pyx_scope_struct_23__make_config; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_24___cinit__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_5_cdec___pyx_scope_struct_24___cinit__ = &__pyx_type_5_cdec___pyx_scope_struct_24___cinit__; - if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_25_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_24___init__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_5_cdec___pyx_scope_struct_24___init__ = &__pyx_type_5_cdec___pyx_scope_struct_24___init__; + if (PyType_Ready(&__pyx_type_5_cdec___pyx_scope_struct_25_genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_ptype_5_cdec___pyx_scope_struct_25_genexpr = &__pyx_type_5_cdec___pyx_scope_struct_25_genexpr; /*--- Type import code ---*/ - __pyx_ptype_4cdec_2sa_3_sa_FloatList = __Pyx_ImportType("cdec.sa._sa", "FloatList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FloatList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_vtabptr_4cdec_2sa_3_sa_FloatList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_FloatList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_IntList = __Pyx_ImportType("cdec.sa._sa", "IntList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_IntList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_vtabptr_4cdec_2sa_3_sa_IntList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_FeatureVector = __Pyx_ImportType("cdec.sa._sa", "FeatureVector", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FeatureVector)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} - __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_FloatList = __Pyx_ImportType("cdec.sa._sa", "FloatList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FloatList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_FloatList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_FloatList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_FloatList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_FloatList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_IntList = __Pyx_ImportType("cdec.sa._sa", "IntList", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_IntList), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_IntList = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_IntList*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_IntList->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_IntList)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_FeatureVector = __Pyx_ImportType("cdec.sa._sa", "FeatureVector", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_FeatureVector), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_FeatureVector)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_Phrase = __Pyx_ImportType("cdec.sa._sa", "Phrase", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Phrase), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_vtabptr_4cdec_2sa_3_sa_Phrase = (struct __pyx_vtabstruct_4cdec_2sa_3_sa_Phrase*)__Pyx_GetVtable(__pyx_ptype_4cdec_2sa_3_sa_Phrase->tp_dict); if (unlikely(!__pyx_vtabptr_4cdec_2sa_3_sa_Phrase)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_ptype_4cdec_2sa_3_sa_Rule = __Pyx_ImportType("cdec.sa._sa", "Rule", sizeof(struct __pyx_obj_4cdec_2sa_3_sa_Rule), 1); if (unlikely(!__pyx_ptype_4cdec_2sa_3_sa_Rule)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;} /*--- Variable import code ---*/ /*--- Function import code ---*/ __pyx_t_1 = __Pyx_ImportModule("cdec.sa._sa"); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} @@ -29163,7 +29340,7 @@ PyMODINIT_FUNC PyInit__cdec(void) Py_DECREF(__pyx_t_1); __pyx_t_1 = 0; /*--- Execution code ---*/ - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":3 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":3 * cimport grammar * cimport cdec.sa._sa as _sa * import cdec.sa._sa as _sa # <<<<<<<<<<<<<< @@ -29172,16 +29349,16 @@ PyMODINIT_FUNC PyInit__cdec(void) */ __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(((PyObject *)__pyx_n_s_56)); - PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_56)); - __Pyx_GIVEREF(((PyObject *)__pyx_n_s_56)); - __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_55), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __Pyx_INCREF(((PyObject *)__pyx_n_s_54)); + PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_n_s_54)); + __Pyx_GIVEREF(((PyObject *)__pyx_n_s_54)); + __pyx_t_3 = __Pyx_Import(((PyObject *)__pyx_n_s_53), ((PyObject *)__pyx_t_2), -1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0; if (PyObject_SetAttr(__pyx_m, __pyx_n_s___sa, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/grammar.pxi":5 + /* "/home/vchahune/tools/cdec/python/src/grammar.pxi":5 * import cdec.sa._sa as _sa * * def _phrase(phrase): # <<<<<<<<<<<<<< @@ -29193,37 +29370,37 @@ PyMODINIT_FUNC PyInit__cdec(void) if (PyObject_SetAttr(__pyx_m, __pyx_n_s___phrase, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":189 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":194 * return [] * * BLEU = Scorer('IBM_BLEU') # <<<<<<<<<<<<<< * TER = Scorer('TER') * CER = Scorer('CER') */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_58), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__BLEU, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":190 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":195 * * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') # <<<<<<<<<<<<<< * CER = Scorer('CER') */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__TER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "/Users/vchahun/Sandbox/cdec/python/src/mteval.pxi":191 + /* "/home/vchahune/tools/cdec/python/src/mteval.pxi":196 * BLEU = Scorer('IBM_BLEU') * TER = Scorer('TER') * CER = Scorer('CER') # <<<<<<<<<<<<<< */ - __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_62), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5_cdec_Scorer)), ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CER, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "_cdec.pyx":22 @@ -29290,24 +29467,24 @@ PyMODINIT_FUNC PyInit__cdec(void) * class ParseFailed(Exception): pass * * def set_silent(yn): # <<<<<<<<<<<<<< + * """set_silent(bool): Configure the verbosity of cdec.""" * SetSilent(yn) - * */ __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_3set_silent, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); if (PyObject_SetAttr(__pyx_m, __pyx_n_s__set_silent, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - /* "_cdec.pyx":31 + /* "_cdec.pyx":32 * SetSilent(yn) * * def _make_config(config): # <<<<<<<<<<<<<< * for key, value in config.items(): * if isinstance(value, dict): */ - __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_5_make_config, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_5_cdec_5_make_config, NULL, __pyx_n_s___cdec); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_GOTREF(__pyx_t_3); - if (PyObject_SetAttr(__pyx_m, __pyx_n_s___make_config, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;} + if (PyObject_SetAttr(__pyx_m, __pyx_n_s___make_config, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; /* "_cdec.pyx":1 @@ -29319,6 +29496,14 @@ PyMODINIT_FUNC PyInit__cdec(void) __Pyx_GOTREF(((PyObject *)__pyx_t_3)); if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0; + + /* "string.from_py":11 + * + * @cname("__pyx_convert_string_from_py_") + * cdef string __pyx_convert_string_from_py_(object o) except *: # <<<<<<<<<<<<<< + * return string(o, len(o)) + * + */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); @@ -29407,33 +29592,38 @@ static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyOb static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, CYTHON_UNUSED PyObject *cause) { Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - if (tb == Py_None) { - Py_DECREF(tb); - tb = 0; - } - else if (tb != NULL && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - if (value == NULL) { - value = Py_None; + if (!value || value == Py_None) + value = NULL; + else Py_INCREF(value); + if (!tb || tb == Py_None) + tb = NULL; + else { + Py_INCREF(tb); + if (!PyTraceBack_Check(tb)) { + PyErr_SetString(PyExc_TypeError, + "raise: arg 3 must be a traceback or None"); + goto raise_error; + } } #if PY_VERSION_HEX < 0x02050000 - if (!PyClass_Check(type)) + if (PyClass_Check(type)) { #else - if (!PyType_Check(type)) + if (PyType_Check(type)) { #endif - { - if (value != Py_None) { +#if CYTHON_COMPILING_IN_PYPY + if (!value) { + Py_INCREF(Py_None); + value = Py_None; + } +#endif + PyErr_NormalizeException(&type, &value, &tb); + } else { + if (value) { PyErr_SetString(PyExc_TypeError, "instance exception may not have a separate value"); goto raise_error; } - Py_DECREF(value); value = type; #if PY_VERSION_HEX < 0x02050000 if (PyInstance_Check(type)) { @@ -29466,6 +29656,7 @@ raise_error: } #else /* Python 3+ */ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) { + PyObject* owned_instance = NULL; if (tb == Py_None) { tb = 0; } else if (tb && !PyTraceBack_Check(tb)) { @@ -29483,12 +29674,36 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } value = type; type = (PyObject*) Py_TYPE(value); - } else if (!PyExceptionClass_Check(type)) { + } else if (PyExceptionClass_Check(type)) { + PyObject *args; + if (!value) + args = PyTuple_New(0); + else if (PyTuple_Check(value)) { + Py_INCREF(value); + args = value; + } + else + args = PyTuple_Pack(1, value); + if (!args) + goto bad; + owned_instance = PyEval_CallObject(type, args); + Py_DECREF(args); + if (!owned_instance) + goto bad; + value = owned_instance; + if (!PyExceptionInstance_Check(value)) { + PyErr_Format(PyExc_TypeError, + "calling %R should have returned an instance of " + "BaseException, not %R", + type, Py_TYPE(value)); + goto bad; + } + } else { PyErr_SetString(PyExc_TypeError, "raise: exception class must be a subclass of BaseException"); goto bad; } - if (cause) { + if (cause && cause != Py_None) { PyObject *fixed_cause; if (PyExceptionClass_Check(cause)) { fixed_cause = PyObject_CallObject(cause, NULL); @@ -29505,9 +29720,6 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject "BaseException"); goto bad; } - if (!value) { - value = PyObject_CallObject(type, NULL); - } PyException_SetCause(value, fixed_cause); } PyErr_SetObject(type, value); @@ -29521,6 +29733,7 @@ static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject } } bad: + Py_XDECREF(owned_instance); return; } #endif @@ -29545,7 +29758,7 @@ static void __Pyx_RaiseArgtupleInvalid( more_or_less = "exactly"; } PyErr_Format(PyExc_TypeError, - "%s() takes %s %" PY_FORMAT_SIZE_T "d positional argument%s (%" PY_FORMAT_SIZE_T "d given)", + "%s() takes %s %" CYTHON_FORMAT_SSIZE_T "d positional argument%s (%" CYTHON_FORMAT_SSIZE_T "d given)", func_name, more_or_less, num_expected, (num_expected == 1) ? "" : "s", num_found); } @@ -29565,10 +29778,9 @@ static CYTHON_INLINE int __Pyx_CheckKeywordStrings( while (PyDict_Next(kwdict, &pos, &key, 0)) { #if PY_MAJOR_VERSION < 3 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) - #else - if (unlikely(!PyUnicode_Check(key))) #endif - goto invalid_keyword_type; + if (unlikely(!PyUnicode_Check(key))) + goto invalid_keyword_type; } if ((!kw_allowed) && unlikely(key)) goto invalid_keyword; @@ -29635,7 +29847,7 @@ static void __Pyx_RaiseDoubleKeywordsError( "%s() got multiple values for keyword argument '%U'", func_name, kw_name); #else "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AS_STRING(kw_name)); + PyString_AsString(kw_name)); #endif } @@ -29656,48 +29868,72 @@ static int __Pyx_ParseOptionalKeywords( while (*name && (**name != key)) name++; if (*name) { values[name-argnames] = value; - } else { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) { - #else - if (unlikely(!PyUnicode_Check(key))) { - #endif - goto invalid_keyword_type; - } else { - for (name = first_kw_arg; *name; name++) { - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) break; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) break; - #endif - } - if (*name) { + continue; + } + name = first_kw_arg; + #if PY_MAJOR_VERSION < 3 + if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { + while (*name) { + if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) + && _PyString_Eq(**name, key)) { values[name-argnames] = value; - } else { - for (name=argnames; name != first_kw_arg; name++) { - if (**name == key) goto arg_passed_twice; - #if PY_MAJOR_VERSION >= 3 - if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) && - PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice; - #else - if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) && - _PyString_Eq(**name, key)) goto arg_passed_twice; - #endif - } - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + if ((**argname == key) || ( + (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) + && _PyString_Eq(**argname, key))) { + goto arg_passed_twice; } + argname++; + } + } + } else + #endif + if (likely(PyUnicode_Check(key))) { + while (*name) { + int cmp = (**name == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**name, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) { + values[name-argnames] = value; + break; + } + name++; + } + if (*name) continue; + else { + PyObject*** argname = argnames; + while (argname != first_kw_arg) { + int cmp = (**argname == key) ? 0 : + #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 + (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : + #endif + PyUnicode_Compare(**argname, key); + if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; + if (cmp == 0) goto arg_passed_twice; + argname++; } } + } else + goto invalid_keyword_type; + if (kwds2) { + if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; + } else { + goto invalid_keyword; } } return 0; arg_passed_twice: - __Pyx_RaiseDoubleKeywordsError(function_name, **name); + __Pyx_RaiseDoubleKeywordsError(function_name, key); goto bad; invalid_keyword_type: PyErr_Format(PyExc_TypeError, @@ -29718,12 +29954,12 @@ bad: static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" PY_FORMAT_SIZE_T "d)", expected); + "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); } static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { PyErr_Format(PyExc_ValueError, - "need more than %" PY_FORMAT_SIZE_T "d value%s to unpack", + "need more than %" CYTHON_FORMAT_SSIZE_T "d value%s to unpack", index, (index == 1) ? "" : "s"); } @@ -30091,9 +30327,8 @@ static CYTHON_INLINE WordID __Pyx_PyInt_from_py_WordID(PyObject* x) { } } -static PyObject* __Pyx_Globals() { +static PyObject* __Pyx_Globals(void) { Py_ssize_t i; - /*PyObject *d;*/ PyObject *names = NULL; PyObject *globals = PyObject_GetAttrString(__pyx_m, "__dict__"); if (!globals) { @@ -30104,25 +30339,36 @@ static PyObject* __Pyx_Globals() { names = PyObject_Dir(__pyx_m); if (!names) goto bad; - for (i = 0; i < PyList_GET_SIZE(names); i++) { + for (i = PyList_GET_SIZE(names)-1; i >= 0; i--) { +#if CYTHON_COMPILING_IN_PYPY + PyObject* name = PySequence_GetItem(names, i); + if (!name) + goto bad; +#else PyObject* name = PyList_GET_ITEM(names, i); +#endif if (!PyDict_Contains(globals, name)) { - PyObject* value = PyObject_GetAttr(__pyx_m, PyList_GET_ITEM(names, i)); - if (!value) + PyObject* value = PyObject_GetAttr(__pyx_m, name); + if (!value) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif goto bad; + } if (PyDict_SetItem(globals, name, value) < 0) { +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif Py_DECREF(value); goto bad; } } +#if CYTHON_COMPILING_IN_PYPY + Py_DECREF(name); +#endif } Py_DECREF(names); return globals; - /* - d = PyDictProxy_New(globals); - Py_DECREF(globals); - return d; - */ bad: Py_XDECREF(names); Py_XDECREF(globals); @@ -30538,86 +30784,6 @@ static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyOb Py_INCREF(tuple); } -static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else - if (s1 == s2) { - return (equals == Py_EQ); - } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) { - if (PyBytes_GET_SIZE(s1) != PyBytes_GET_SIZE(s2)) { - return (equals == Py_NE); - } else if (PyBytes_GET_SIZE(s1) == 1) { - if (equals == Py_EQ) - return (PyBytes_AS_STRING(s1)[0] == PyBytes_AS_STRING(s2)[0]); - else - return (PyBytes_AS_STRING(s1)[0] != PyBytes_AS_STRING(s2)[0]); - } else { - int result = memcmp(PyBytes_AS_STRING(s1), PyBytes_AS_STRING(s2), (size_t)PyBytes_GET_SIZE(s1)); - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -#endif -} - -static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) { -#if CYTHON_COMPILING_IN_PYPY - return PyObject_RichCompareBool(s1, s2, equals); -#else - if (s1 == s2) { - return (equals == Py_EQ); - } else if (PyUnicode_CheckExact(s1) & PyUnicode_CheckExact(s2)) { - #if CYTHON_PEP393_ENABLED - if ((PyUnicode_READY(s1) < 0) || (PyUnicode_READY(s2) < 0)) - return -1; - if (PyUnicode_GET_LENGTH(s1) != PyUnicode_GET_LENGTH(s2)) { - return (equals == Py_NE); - } else if (PyUnicode_GET_LENGTH(s1) == 1) { - Py_UCS4 ch1 = PyUnicode_READ_CHAR(s1, 0); - Py_UCS4 ch2 = PyUnicode_READ_CHAR(s2, 0); - return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2); - #else - if (PyUnicode_GET_SIZE(s1) != PyUnicode_GET_SIZE(s2)) { - return (equals == Py_NE); - } else if (PyUnicode_GET_SIZE(s1) == 1) { - Py_UNICODE ch1 = PyUnicode_AS_UNICODE(s1)[0]; - Py_UNICODE ch2 = PyUnicode_AS_UNICODE(s2)[0]; - return (equals == Py_EQ) ? (ch1 == ch2) : (ch1 != ch2); - #endif - } else { - int result = PyUnicode_Compare(s1, s2); - if ((result == -1) && unlikely(PyErr_Occurred())) - return -1; - return (equals == Py_EQ) ? (result == 0) : (result != 0); - } - } else if ((s1 == Py_None) & PyUnicode_CheckExact(s2)) { - return (equals == Py_NE); - } else if ((s2 == Py_None) & PyUnicode_CheckExact(s1)) { - return (equals == Py_NE); - } else { - int result; - PyObject* py_result = PyObject_RichCompare(s1, s2, equals); - if (!py_result) - return -1; - result = __Pyx_PyObject_IsTrue(py_result); - Py_DECREF(py_result); - return result; - } -#endif -} - static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) { const unsigned char neg_one = (unsigned char)-1, const_zero = 0; const int is_unsigned = neg_one > const_zero; @@ -31018,25 +31184,6 @@ static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* } } -static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -} - static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) { PyObject *tmp_type, *tmp_value, *tmp_tb; #if CYTHON_COMPILING_IN_CPYTHON @@ -31459,7 +31606,7 @@ static PyMemberDef __pyx_Generator_memberlist[] = { #if PY_VERSION_HEX >= 0x02060000 T_BOOL, #else - T_INT, + T_BYTE, #endif offsetof(__pyx_GeneratorObject, is_running), READONLY, @@ -31557,6 +31704,25 @@ static int __pyx_Generator_init(void) { return 0; } +static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, + CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename) { + PyObject *old_exc, *old_val, *old_tb; + PyObject *ctx; + __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); + #if PY_MAJOR_VERSION < 3 + ctx = PyString_FromString(name); + #else + ctx = PyUnicode_FromString(name); + #endif + __Pyx_ErrRestore(old_exc, old_val, old_tb); + if (!ctx) { + PyErr_WriteUnraisable(Py_None); + } else { + PyErr_WriteUnraisable(ctx); + Py_DECREF(ctx); + } +} + static int __Pyx_check_binary_version(void) { char ctversion[4], rtversion[4]; PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); @@ -31593,6 +31759,23 @@ bad: return -1; } +#ifndef __PYX_HAVE_RT_ImportModule +#define __PYX_HAVE_RT_ImportModule +static PyObject *__Pyx_ImportModule(const char *name) { + PyObject *py_name = 0; + PyObject *py_module = 0; + py_name = __Pyx_PyIdentifier_FromString(name); + if (!py_name) + goto bad; + py_module = PyImport_Import(py_name); + Py_DECREF(py_name); + return py_module; +bad: + Py_XDECREF(py_name); + return 0; +} +#endif + #ifndef __PYX_HAVE_RT_ImportType #define __PYX_HAVE_RT_ImportType static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, @@ -31645,23 +31828,6 @@ bad: } #endif -#ifndef __PYX_HAVE_RT_ImportModule -#define __PYX_HAVE_RT_ImportModule -static PyObject *__Pyx_ImportModule(const char *name) { - PyObject *py_name = 0; - PyObject *py_module = 0; - py_name = __Pyx_PyIdentifier_FromString(name); - if (!py_name) - goto bad; - py_module = PyImport_Import(py_name); - Py_DECREF(py_name); - return py_module; -bad: - Py_XDECREF(py_name); - return 0; -} -#endif - static void* __Pyx_GetVtable(PyObject *dict) { void* ptr; PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__"); @@ -31700,7 +31866,7 @@ static int __Pyx_ImportFunction(PyObject *module, const char *funcname, void (** PyModule_GetName(module), funcname); goto bad; } -#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0) +#if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==0) if (!PyCapsule_IsValid(cobj, sig)) { PyErr_Format(PyExc_TypeError, "C function %s.%s has wrong signature (expected %s, got %s)", diff --git a/python/src/_cdec.pyx b/python/src/_cdec.pyx index 6c6c8eee..71e083e4 100644 --- a/python/src/_cdec.pyx +++ b/python/src/_cdec.pyx @@ -3,7 +3,7 @@ from libcpp.vector cimport vector from utils cimport * cimport decoder -cdef char* as_str(data, char* error_msg='Cannot convert type %s to str'): +cdef bytes as_str(data, char* error_msg='Cannot convert type %s to str'): cdef bytes ret if isinstance(data, unicode): ret = data.encode('utf8') @@ -26,6 +26,7 @@ class InvalidConfig(Exception): pass class ParseFailed(Exception): pass def set_silent(yn): + """set_silent(bool): Configure the verbosity of cdec.""" SetSilent(yn) def _make_config(config): @@ -43,12 +44,10 @@ cdef class Decoder: cdef decoder.Decoder* dec cdef DenseVector weights - def __cinit__(self, config_str=None, **config): - """ Configuration can be given as a string: - Decoder('formalism = scfg') - or using keyword arguments: - Decoder(formalism='scfg') - """ + def __init__(self, config_str=None, **config): + """Decoder('formalism = scfg') -> initialize from configuration string + Decoder(formalism='scfg') -> initialize from named parameters + Create a decoder using a given configuration. Formalism is required.""" if config_str is None: formalism = config.get('formalism', None) if formalism not in ('scfg', 'fst', 'lextrans', 'pb', @@ -88,6 +87,7 @@ cdef class Decoder: return str(conf[0]['formalism'].as_str().c_str()) def read_weights(self, weights): + """decoder.read_weights(filename): Read decoder weights from a file.""" with open(weights) as fp: for line in fp: if line.strip().startswith('#'): continue @@ -95,6 +95,8 @@ cdef class Decoder: self.weights[fname.strip()] = float(value) def translate(self, sentence, grammar=None): + """decoder.translate(sentence, grammar=None) -> Hypergraph + Translate a sentence (string/Lattice) with a grammar (string/list of rules).""" cdef bytes input_str if isinstance(sentence, basestring): input_str = as_str(sentence.strip()) @@ -104,11 +106,11 @@ cdef class Decoder: raise TypeError('Cannot translate input type %s' % type(sentence)) if grammar: if isinstance(grammar, basestring): - self.dec.AddSupplementalGrammarFromString(string(as_str(grammar))) + self.dec.AddSupplementalGrammarFromString(as_str(grammar)) else: self.dec.AddSupplementalGrammar(TextGrammar(grammar).grammar[0]) cdef decoder.BasicObserver observer = decoder.BasicObserver() - self.dec.Decode(string(input_str), &observer) + self.dec.Decode(input_str, &observer) if observer.hypergraph == NULL: raise ParseFailed() cdef Hypergraph hg = Hypergraph() diff --git a/python/src/grammar.pxi b/python/src/grammar.pxi index b05d07a0..d523e4d2 100644 --- a/python/src/grammar.pxi +++ b/python/src/grammar.pxi @@ -9,6 +9,7 @@ cdef class NT: cdef public bytes cat cdef public unsigned ref def __init__(self, bytes cat, unsigned ref=0): + """NT(bytes cat, int ref=0) -> Non-terminal from category `cat`.""" self.cat = cat self.ref = ref @@ -20,6 +21,7 @@ cdef class NT: cdef class NTRef: cdef public unsigned ref def __init__(self, unsigned ref): + """NTRef(int ref) -> Non-terminal reference.""" self.ref = ref def __str__(self): @@ -48,6 +50,12 @@ cdef class TRule: cdef shared_ptr[grammar.TRule]* rule def __init__(self, lhs, f, e, scores, a=None): + """TRule(lhs, f, e, scores, a=None) -> Translation rule. + lhs: left hand side non-terminal + f: source phrase (list of words/NT) + e: target phrase (list of words/NTRef) + scores: dictionary of feature scores + a: optional list of alignment points""" self.rule = new shared_ptr[grammar.TRule](new grammar.TRule()) self.lhs = lhs self.e = e @@ -87,9 +95,10 @@ cdef class TRule: cdef int idx = 0 for i in range(len(f)): if isinstance(f[i], NT): - f_[0][i] = -TDConvert(f[i].cat) + f_[0][i] = -TDConvert(( f[i]).cat) else: - f_[0][i] = TDConvert(as_str(f[i])) + fi = as_str(f[i]) + f_[0][i] = TDConvert(fi) property e: def __get__(self): @@ -115,7 +124,8 @@ cdef class TRule: if isinstance(e[i], NTRef): e_[0][i] = 1-e[i].ref else: - e_[0][i] = TDConvert(as_str(e[i])) + ei = as_str(e[i]) + e_[0][i] = TDConvert(ei) property a: def __get__(self): @@ -145,7 +155,8 @@ cdef class TRule: cdef int fid cdef float fval for fname, fval in scores.items(): - fid = FDConvert(as_str(fname)) + fn = as_str(fname) + fid = FDConvert(fn) if fid < 0: raise KeyError(fname) scores_.set_value(fid, fval) @@ -156,7 +167,7 @@ cdef class TRule: def __set__(self, lhs): if not isinstance(lhs, NT): lhs = NT(lhs) - self.rule.get().lhs_ = -TDConvert(lhs.cat) + self.rule.get().lhs_ = -TDConvert(( lhs).cat) def __str__(self): scores = ' '.join('%s=%s' % feat for feat in self.scores) @@ -164,7 +175,11 @@ cdef class TRule: _phrase(self.f), _phrase(self.e), scores) cdef class MRule(TRule): - def __init__(self, lhs, rhs, scores, a=None): + def __init__(self, lhs, rhs, scores): + """MRule(lhs, rhs, scores, a=None) -> Monolingual rule. + lhs: left hand side non-terminal + rhs: right hand side phrase (list of words/NT) + scores: dictionary of feature scores""" cdef unsigned i = 1 e = [] for s in rhs: @@ -173,7 +188,7 @@ cdef class MRule(TRule): i += 1 else: e.append(s) - super(MRule, self).__init__(lhs, rhs, e, scores, a) + super(MRule, self).__init__(lhs, rhs, e, scores, None) cdef class Grammar: cdef shared_ptr[grammar.Grammar]* grammar @@ -196,10 +211,12 @@ cdef class Grammar: str(self.grammar.get().GetGrammarName().c_str()) def __set__(self, name): - self.grammar.get().SetGrammarName(string(name)) + name = as_str(name) + self.grammar.get().SetGrammarName(name) cdef class TextGrammar(Grammar): - def __cinit__(self, rules): + def __init__(self, rules): + """TextGrammar(rules) -> SCFG Grammar containing the rules.""" self.grammar = new shared_ptr[grammar.Grammar](new grammar.TextGrammar()) cdef grammar.TextGrammar* _g = self.grammar.get() for trule in rules: diff --git a/python/src/hypergraph.pxi b/python/src/hypergraph.pxi index bb6141df..5b675531 100644 --- a/python/src/hypergraph.pxi +++ b/python/src/hypergraph.pxi @@ -16,24 +16,33 @@ cdef class Hypergraph: return self.rng def viterbi(self): + """hg.viterbi() -> String for the best hypothesis in the hypergraph.""" cdef vector[WordID] trans hypergraph.ViterbiESentence(self.hg[0], &trans) return unicode(GetString(trans).c_str(), 'utf8') def viterbi_trees(self): + """hg.viterbi_trees() -> (f_tree, e_tree) + f_tree: Source tree for the best hypothesis in the hypergraph. + e_tree: Target tree for the best hypothesis in the hypergraph. + """ f_tree = unicode(hypergraph.ViterbiFTree(self.hg[0]).c_str(), 'utf8') e_tree = unicode(hypergraph.ViterbiETree(self.hg[0]).c_str(), 'utf8') return (f_tree, e_tree) def viterbi_features(self): + """hg.viterbi_features() -> SparseVector with the features corresponding + to the best derivation in the hypergraph.""" cdef SparseVector fmap = SparseVector.__new__(SparseVector) fmap.vector = new FastSparseVector[weight_t](hypergraph.ViterbiFeatures(self.hg[0])) return fmap def viterbi_joshua(self): + """hg.viterbi_joshua() -> Joshua representation of the best derivation.""" return unicode(hypergraph.JoshuaVisualizationString(self.hg[0]).c_str(), 'utf8') def kbest(self, size): + """hg.kbest(size) -> List of k-best hypotheses in the hypergraph.""" cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal]* derivations = new kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal](self.hg[0], size) cdef kbest.KBestDerivations[vector[WordID], kbest.ESentenceTraversal].Derivation* derivation cdef unsigned k @@ -46,6 +55,7 @@ cdef class Hypergraph: del derivations def kbest_trees(self, size): + """hg.kbest_trees(size) -> List of k-best trees in the hypergraph.""" cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal]* f_derivations = new kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal](self.hg[0], size) cdef kbest.KBestDerivations[vector[WordID], kbest.FTreeTraversal].Derivation* f_derivation cdef kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal]* e_derivations = new kbest.KBestDerivations[vector[WordID], kbest.ETreeTraversal](self.hg[0], size) @@ -64,6 +74,7 @@ cdef class Hypergraph: del e_derivations def kbest_features(self, size): + """hg.kbest_trees(size) -> List of k-best feature vectors in the hypergraph.""" cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal]* derivations = new kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal](self.hg[0], size) cdef kbest.KBestDerivations[FastSparseVector[weight_t], kbest.FeatureVectorTraversal].Derivation* derivation cdef SparseVector fmap @@ -79,6 +90,7 @@ cdef class Hypergraph: del derivations def sample(self, unsigned n): + """hg.sample(n) -> Sample of n hypotheses from the hypergraph.""" cdef vector[hypergraph.Hypothesis]* hypos = new vector[hypergraph.Hypothesis]() hypergraph.sample_hypotheses(self.hg[0], n, self._rng(), hypos) cdef unsigned k @@ -89,6 +101,7 @@ cdef class Hypergraph: del hypos def sample_trees(self, unsigned n): + """hg.sample_trees(n) -> Sample of n trees from the hypergraph.""" cdef vector[string]* trees = new vector[string]() hypergraph.sample_trees(self.hg[0], n, self._rng(), trees) cdef unsigned k @@ -99,6 +112,7 @@ cdef class Hypergraph: del trees def intersect(self, inp): + """hg.intersect(Lattice/string): Intersect the hypergraph with the provided reference.""" cdef Lattice lat if isinstance(inp, Lattice): lat = inp @@ -109,6 +123,9 @@ cdef class Hypergraph: return hypergraph.Intersect(lat.lattice[0], self.hg) def prune(self, beam_alpha=0, density=0, **kwargs): + """hg.prune(beam_alpha=0, density=0): Prune the hypergraph. + beam_alpha: use beam pruning + density: use density pruning""" cdef hypergraph.EdgeMask* preserve_mask = NULL if 'csplit_preserve_full_word' in kwargs: preserve_mask = new hypergraph.EdgeMask(self.hg.edges_.size()) @@ -118,13 +135,16 @@ cdef class Hypergraph: del preserve_mask def lattice(self): # TODO direct hg -> lattice conversion in cdec + """hg.lattice() -> Lattice corresponding to the hypergraph.""" cdef bytes plf = hypergraph.AsPLF(self.hg[0], True).c_str() return Lattice(eval(plf)) def plf(self): + """hg.plf() -> Lattice PLF representation corresponding to the hypergraph.""" return bytes(hypergraph.AsPLF(self.hg[0], True).c_str()) def reweight(self, weights): + """hg.reweight(SparseVector/DenseVector): Reweight the hypergraph with a new vector.""" if isinstance(weights, SparseVector): self.hg.Reweight(( weights).vector[0]) elif isinstance(weights, DenseVector): @@ -153,6 +173,7 @@ cdef class Hypergraph: return self.hg.NumberOfPaths() def inside_outside(self): + """hg.inside_outside() -> SparseVector with inside-outside scores for each feature.""" cdef FastSparseVector[prob_t]* result = new FastSparseVector[prob_t]() cdef prob_t z = hypergraph.InsideOutside(self.hg[0], result) result[0] /= z diff --git a/python/src/lattice.pxi b/python/src/lattice.pxi index 57e340d2..8000b61e 100644 --- a/python/src/lattice.pxi +++ b/python/src/lattice.pxi @@ -7,16 +7,16 @@ cdef class Lattice: self.lattice = new lattice.Lattice() def __init__(self, inp): + """Lattice(tuple) -> Lattice from node list. + Lattice(string) -> Lattice from PLF representation.""" if isinstance(inp, tuple): self.lattice.resize(len(inp)) for i, arcs in enumerate(inp): self[i] = arcs + elif isinstance(inp, basestring): + lattice.ConvertTextOrPLF(as_str(inp), self.lattice) else: - if isinstance(inp, unicode): - inp = inp.encode('utf8') - if not isinstance(inp, str): - raise TypeError('cannot create lattice from %s' % type(inp)) - lattice.ConvertTextOrPLF(string(inp), self.lattice) + raise TypeError('cannot create lattice from %s' % type(inp)) def __dealloc__(self): del self.lattice @@ -39,9 +39,8 @@ cdef class Lattice: raise IndexError('lattice index out of range') cdef lattice.LatticeArc* arc for (label, cost, dist2next) in arcs: - if isinstance(label, unicode): - label = label.encode('utf8') - arc = new lattice.LatticeArc(TDConvert(label), cost, dist2next) + label_str = as_str(label) + arc = new lattice.LatticeArc(TDConvert(label_str), cost, dist2next) self.lattice[0][index].push_back(arc[0]) del arc @@ -60,6 +59,7 @@ cdef class Lattice: yield self[i] def todot(self): + """lattice.todot() -> Representation of the lattice in GraphViz dot format.""" def lines(): yield 'digraph lattice {' yield 'rankdir = LR;' @@ -72,8 +72,9 @@ cdef class Lattice: return '\n'.join(lines()).encode('utf8') def as_hypergraph(self): + """lattice.as_hypergraph() -> Hypergraph representation of the lattice.""" cdef Hypergraph result = Hypergraph.__new__(Hypergraph) result.hg = new hypergraph.Hypergraph() cdef bytes plf = str(self) - hypergraph.ReadFromPLF(string(plf), result.hg) + hypergraph.ReadFromPLF(plf, result.hg) return result diff --git a/python/src/mteval.pxi b/python/src/mteval.pxi index 00355f96..f3bec393 100644 --- a/python/src/mteval.pxi +++ b/python/src/mteval.pxi @@ -93,6 +93,8 @@ cdef class CandidateSet: yield self[i] def add_kbest(self, Hypergraph hypergraph, unsigned k): + """cs.add_kbest(Hypergraph hypergraph, int k) -> Extract K-best hypotheses + from the hypergraph and add them to the candidate set.""" self.cs.AddKBestCandidates(hypergraph.hg[0], k, self.scorer.get()) cdef class SegmentEvaluator: @@ -103,15 +105,17 @@ cdef class SegmentEvaluator: del self.scorer def evaluate(self, sentence): + """se.evaluate(sentence) -> SufficientStats for the given hypothesis.""" cdef vector[WordID] hyp cdef SufficientStats sf = SufficientStats() sf.metric = self.metric sf.stats = new mteval.SufficientStats() - ConvertSentence(string(as_str(sentence.strip())), &hyp) + ConvertSentence(as_str(sentence.strip()), &hyp) self.scorer.get().Evaluate(hyp, sf.stats) return sf def candidate_set(self): + """se.candidate_set() -> Candidate set using this segment evaluator for scoring.""" return CandidateSet(self) cdef class Scorer: @@ -133,7 +137,7 @@ cdef class Scorer: cdef vector[WordID]* refv for ref in refs: refv = new vector[WordID]() - ConvertSentence(string(as_str(ref.strip())), refv) + ConvertSentence(as_str(ref.strip()), refv) refsv.push_back(refv[0]) del refv cdef unsigned i @@ -173,7 +177,8 @@ cdef class Metric: cdef Scorer scorer def __cinit__(self): self.scorer = Scorer() - self.scorer.name = new string(as_str(self.__class__.__name__)) + cdef bytes class_name = self.__class__.__name__ + self.scorer.name = new string(class_name) self.scorer.metric = mteval.PyMetricInstance(self.scorer.name[0], self, _compute_sufficient_stats, _compute_score) diff --git a/python/src/vectors.pxi b/python/src/vectors.pxi index 87780556..46f58fd4 100644 --- a/python/src/vectors.pxi +++ b/python/src/vectors.pxi @@ -5,6 +5,7 @@ cdef class DenseVector: cdef bint owned # if True, do not manage memory def __init__(self): + """DenseVector() -> Dense weight/feature vector.""" self.vector = new vector[weight_t]() self.owned = False @@ -22,7 +23,7 @@ cdef class DenseVector: raise KeyError(fname) def __setitem__(self, char* fname, float value): - cdef int fid = FDConvert(fname) + cdef int fid = FDConvert(fname) if fid < 0: raise KeyError(fname) if self.vector.size() <= fid: self.vector.resize(fid + 1) @@ -34,9 +35,11 @@ cdef class DenseVector: yield str(FDConvert(fid).c_str()), self.vector[0][fid] def dot(self, SparseVector other): + """vector.dot(SparseVector other) -> Dot product of the two vectors.""" return other.dot(self) def tosparse(self): + """vector.tosparse() -> Equivalent SparseVector.""" cdef SparseVector sparse = SparseVector.__new__(SparseVector) sparse.vector = new FastSparseVector[weight_t]() InitSparseVector(self.vector[0], sparse.vector) @@ -46,12 +49,14 @@ cdef class SparseVector: cdef FastSparseVector[weight_t]* vector def __init__(self): + """SparseVector() -> Sparse feature/weight vector.""" self.vector = new FastSparseVector[weight_t]() def __dealloc__(self): del self.vector def copy(self): + """vector.copy() -> SparseVector copy.""" return self * 1 def __getitem__(self, char* fname): @@ -60,7 +65,7 @@ cdef class SparseVector: return self.vector.value(fid) def __setitem__(self, char* fname, float value): - cdef int fid = FDConvert(fname) + cdef int fid = FDConvert(fname) if fid < 0: raise KeyError(fname) self.vector.set_value(fid, value) @@ -75,6 +80,7 @@ cdef class SparseVector: del it def dot(self, other): + """vector.dot(SparseVector/DenseVector other) -> Dot product of the two vectors.""" if isinstance(other, DenseVector): return self.vector.dot(( other).vector[0]) elif isinstance(other, SparseVector): -- cgit v1.2.3