1 /* Generated by Cython 0.12.1 on Mon May 16 07:44:10 2011 */
3 #define PY_SSIZE_T_CLEAN
5 #include "structmember.h"
7 #error Python headers needed to compile C extensions, please install development version of Python.
11 #define PY_LONG_LONG LONG_LONG
14 #define DL_EXPORT(t) t
16 #if PY_VERSION_HEX < 0x02040000
17 #define METH_COEXIST 0
18 #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
19 #define PyDict_Contains(d,o) PySequence_Contains(d,o)
22 #if PY_VERSION_HEX < 0x02050000
23 typedef int Py_ssize_t;
24 #define PY_SSIZE_T_MAX INT_MAX
25 #define PY_SSIZE_T_MIN INT_MIN
26 #define PY_FORMAT_SIZE_T ""
27 #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
28 #define PyInt_AsSsize_t(o) PyInt_AsLong(o)
29 #define PyNumber_Index(o) PyNumber_Int(o)
30 #define PyIndex_Check(o) PyNumber_Check(o)
31 #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
34 #if PY_VERSION_HEX < 0x02060000
35 #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
36 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
37 #define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
38 #define PyVarObject_HEAD_INIT(type, size) \
39 PyObject_HEAD_INIT(type) size,
40 #define PyType_Modified(t)
52 Py_ssize_t *suboffsets;
56 #define PyBUF_SIMPLE 0
57 #define PyBUF_WRITABLE 0x0001
58 #define PyBUF_FORMAT 0x0004
59 #define PyBUF_ND 0x0008
60 #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
61 #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
62 #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
63 #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
64 #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
68 #if PY_MAJOR_VERSION < 3
69 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
71 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
74 #if PY_MAJOR_VERSION >= 3
75 #define Py_TPFLAGS_CHECKTYPES 0
76 #define Py_TPFLAGS_HAVE_INDEX 0
79 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
80 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
83 #if PY_MAJOR_VERSION >= 3
84 #define PyBaseString_Type PyUnicode_Type
85 #define PyString_Type PyUnicode_Type
86 #define PyString_CheckExact PyUnicode_CheckExact
88 #define PyBytes_Type PyString_Type
89 #define PyBytes_CheckExact PyString_CheckExact
92 #if PY_MAJOR_VERSION >= 3
93 #define PyInt_Type PyLong_Type
94 #define PyInt_Check(op) PyLong_Check(op)
95 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
96 #define PyInt_FromString PyLong_FromString
97 #define PyInt_FromUnicode PyLong_FromUnicode
98 #define PyInt_FromLong PyLong_FromLong
99 #define PyInt_FromSize_t PyLong_FromSize_t
100 #define PyInt_FromSsize_t PyLong_FromSsize_t
101 #define PyInt_AsLong PyLong_AsLong
102 #define PyInt_AS_LONG PyLong_AS_LONG
103 #define PyInt_AsSsize_t PyLong_AsSsize_t
104 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
105 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
106 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
107 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
109 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
110 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
114 #if PY_MAJOR_VERSION >= 3
115 #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
118 #if !defined(WIN32) && !defined(MS_WINDOWS)
129 #define _USE_MATH_DEFINES
132 #if PY_VERSION_HEX < 0x02050000
133 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),((char *)(n)))
134 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
135 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),((char *)(n)))
137 #define __Pyx_GetAttrString(o,n) PyObject_GetAttrString((o),(n))
138 #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
139 #define __Pyx_DelAttrString(o,n) PyObject_DelAttrString((o),(n))
142 #if PY_VERSION_HEX < 0x02050000
143 #define __Pyx_NAMESTR(n) ((char *)(n))
144 #define __Pyx_DOCSTR(n) ((char *)(n))
146 #define __Pyx_NAMESTR(n) (n)
147 #define __Pyx_DOCSTR(n) (n)
150 #define __PYX_EXTERN_C extern "C"
152 #define __PYX_EXTERN_C extern
155 #define __PYX_HAVE_API__sphinxbase
156 #include "sphinxbase/logmath.h"
157 #include "sphinxbase/cmd_ln.h"
158 #include "sphinxbase/ckd_alloc.h"
159 #include "sphinxbase/fsg_model.h"
160 #include "sphinxbase/ngram_model.h"
161 #include "sphinxbase/huff_code.h"
163 #ifndef CYTHON_INLINE
164 #if defined(__GNUC__)
165 #define CYTHON_INLINE __inline__
166 #elif defined(_MSC_VER)
167 #define CYTHON_INLINE __inline
169 #define CYTHON_INLINE
173 typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
176 /* Type Conversion Predeclarations */
178 #if PY_MAJOR_VERSION < 3
179 #define __Pyx_PyBytes_FromString PyString_FromString
180 #define __Pyx_PyBytes_FromStringAndSize PyString_FromStringAndSize
181 #define __Pyx_PyBytes_AsString PyString_AsString
183 #define __Pyx_PyBytes_FromString PyBytes_FromString
184 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
185 #define __Pyx_PyBytes_AsString PyBytes_AsString
188 #define __Pyx_PyBytes_FromUString(s) __Pyx_PyBytes_FromString((char*)s)
189 #define __Pyx_PyBytes_AsUString(s) ((unsigned char*) __Pyx_PyBytes_AsString(s))
191 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
192 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
193 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
195 #if !defined(T_PYSSIZET)
196 #if PY_VERSION_HEX < 0x02050000
197 #define T_PYSSIZET T_INT
198 #elif !defined(T_LONGLONG)
200 ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \
201 ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
204 ((sizeof(Py_ssize_t) == sizeof(int)) ? T_INT : \
205 ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : \
206 ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
211 #if !defined(T_ULONGLONG)
212 #define __Pyx_T_UNSIGNED_INT(x) \
213 ((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE : \
214 ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
215 ((sizeof(x) == sizeof(unsigned int)) ? T_UINT : \
216 ((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : -1))))
218 #define __Pyx_T_UNSIGNED_INT(x) \
219 ((sizeof(x) == sizeof(unsigned char)) ? T_UBYTE : \
220 ((sizeof(x) == sizeof(unsigned short)) ? T_USHORT : \
221 ((sizeof(x) == sizeof(unsigned int)) ? T_UINT : \
222 ((sizeof(x) == sizeof(unsigned long)) ? T_ULONG : \
223 ((sizeof(x) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))))
225 #if !defined(T_LONGLONG)
226 #define __Pyx_T_SIGNED_INT(x) \
227 ((sizeof(x) == sizeof(char)) ? T_BYTE : \
228 ((sizeof(x) == sizeof(short)) ? T_SHORT : \
229 ((sizeof(x) == sizeof(int)) ? T_INT : \
230 ((sizeof(x) == sizeof(long)) ? T_LONG : -1))))
232 #define __Pyx_T_SIGNED_INT(x) \
233 ((sizeof(x) == sizeof(char)) ? T_BYTE : \
234 ((sizeof(x) == sizeof(short)) ? T_SHORT : \
235 ((sizeof(x) == sizeof(int)) ? T_INT : \
236 ((sizeof(x) == sizeof(long)) ? T_LONG : \
237 ((sizeof(x) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))))
240 #define __Pyx_T_FLOATING(x) \
241 ((sizeof(x) == sizeof(float)) ? T_FLOAT : \
242 ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))
244 #if !defined(T_SIZET)
245 #if !defined(T_ULONGLONG)
247 ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \
248 ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
251 ((sizeof(size_t) == sizeof(unsigned int)) ? T_UINT : \
252 ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : \
253 ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
257 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
258 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
259 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
261 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
265 /* Test for GCC > 2.95 */
266 #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
267 #define likely(x) __builtin_expect(!!(x), 1)
268 #define unlikely(x) __builtin_expect(!!(x), 0)
269 #else /* __GNUC__ > 2 ... */
270 #define likely(x) (x)
271 #define unlikely(x) (x)
272 #endif /* __GNUC__ > 2 ... */
274 #define likely(x) (x)
275 #define unlikely(x) (x)
276 #endif /* __GNUC__ */
278 static PyObject *__pyx_m;
279 static PyObject *__pyx_b;
280 static PyObject *__pyx_empty_tuple;
281 static PyObject *__pyx_empty_bytes;
282 static int __pyx_lineno;
283 static int __pyx_clineno = 0;
284 static const char * __pyx_cfilenm= __FILE__;
285 static const char *__pyx_filename;
286 static const char **__pyx_f;
289 typedef float __pyx_t_10sphinxbase_float32;
291 typedef int __pyx_t_10sphinxbase_int32;
293 typedef double __pyx_t_10sphinxbase_float64;
295 /* Type declarations */
297 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":149
298 * cdef logmath_t *lmath
300 * cdef class NGramIter: # <<<<<<<<<<<<<<
302 * cdef ngram_iter_t *itor
305 struct __pyx_obj_10sphinxbase_NGramIter {
307 struct __pyx_vtabstruct_10sphinxbase_NGramIter *__pyx_vtab;
308 struct __pyx_obj_10sphinxbase_NGramModel *lm;
317 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":159
318 * cdef set_iter(NGramIter self, ngram_iter_t *itor)
320 * cdef class HuffCode: # <<<<<<<<<<<<<<
321 * cdef huff_code_t *hc
325 struct __pyx_obj_10sphinxbase_HuffCode {
331 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":138
333 * # Extension classes
334 * cdef class NGramModel: # <<<<<<<<<<<<<<
335 * cdef ngram_model_t *lm
336 * cdef logmath_t *lmath
339 struct __pyx_obj_10sphinxbase_NGramModel {
341 struct __pyx_vtabstruct_10sphinxbase_NGramModel *__pyx_vtab;
349 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":146
350 * cdef set_lmath(NGramModel self, logmath_t *lmath)
352 * cdef class LogMath: # <<<<<<<<<<<<<<
353 * cdef logmath_t *lmath
357 struct __pyx_obj_10sphinxbase_LogMath {
363 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":390
364 * raise ValueError, "Write %s to file failed" % file_name
366 * cdef class NGramIter: # <<<<<<<<<<<<<<
368 * N-Gram language model iterator class.
371 struct __pyx_vtabstruct_10sphinxbase_NGramIter {
372 PyObject *(*set_iter)(struct __pyx_obj_10sphinxbase_NGramIter *, ngram_iter_t *);
374 static struct __pyx_vtabstruct_10sphinxbase_NGramIter *__pyx_vtabptr_10sphinxbase_NGramIter;
377 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":128
378 * LOWER = NGRAM_LOWER
380 * cdef class NGramModel: # <<<<<<<<<<<<<<
382 * N-Gram language model class.
385 struct __pyx_vtabstruct_10sphinxbase_NGramModel {
386 PyObject *(*set_lm)(struct __pyx_obj_10sphinxbase_NGramModel *, ngram_model_t *);
387 PyObject *(*set_lmath)(struct __pyx_obj_10sphinxbase_NGramModel *, logmath_t *);
389 static struct __pyx_vtabstruct_10sphinxbase_NGramModel *__pyx_vtabptr_10sphinxbase_NGramModel;
391 #ifndef CYTHON_REFNANNY
392 #define CYTHON_REFNANNY 0
397 void (*INCREF)(void*, PyObject*, int);
398 void (*DECREF)(void*, PyObject*, int);
399 void (*GOTREF)(void*, PyObject*, int);
400 void (*GIVEREF)(void*, PyObject*, int);
401 void* (*SetupContext)(const char*, int, const char*);
402 void (*FinishContext)(void**);
403 } __Pyx_RefNannyAPIStruct;
404 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
405 static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
406 PyObject *m = NULL, *p = NULL;
408 m = PyImport_ImportModule((char *)modname);
410 p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
412 r = PyLong_AsVoidPtr(p);
416 return (__Pyx_RefNannyAPIStruct *)r;
418 #define __Pyx_RefNannySetupContext(name) void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
419 #define __Pyx_RefNannyFinishContext() __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
420 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
421 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
422 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
423 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
424 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
426 #define __Pyx_RefNannySetupContext(name)
427 #define __Pyx_RefNannyFinishContext()
428 #define __Pyx_INCREF(r) Py_INCREF(r)
429 #define __Pyx_DECREF(r) Py_DECREF(r)
430 #define __Pyx_GOTREF(r)
431 #define __Pyx_GIVEREF(r)
432 #define __Pyx_XDECREF(r) Py_XDECREF(r)
433 #endif /* CYTHON_REFNANNY */
434 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
435 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
437 static void __Pyx_RaiseDoubleKeywordsError(
438 const char* func_name, PyObject* kw_name); /*proto*/
440 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
441 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
443 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, const char* function_name); /*proto*/
445 static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
446 if (likely(PyList_CheckExact(L))) {
447 if (PyList_Append(L, x) < 0) return NULL;
449 return Py_None; /* this is just to have an accurate signature */
453 m = __Pyx_GetAttrString(L, "append");
455 r = PyObject_CallFunctionObjArgs(m, x, NULL);
461 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
463 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void);
465 static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
466 static int __Pyx_EndUnpack(PyObject *); /*proto*/
469 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
472 r = PyObject_GetItem(o, j);
478 #define __Pyx_GetItemInt_List(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
479 __Pyx_GetItemInt_List_Fast(o, i, size <= sizeof(long)) : \
480 __Pyx_GetItemInt_Generic(o, to_py_func(i)))
482 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
483 if (likely(o != Py_None)) {
484 if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
485 PyObject *r = PyList_GET_ITEM(o, i);
489 else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
490 PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
495 return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
498 #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
499 __Pyx_GetItemInt_Tuple_Fast(o, i, size <= sizeof(long)) : \
500 __Pyx_GetItemInt_Generic(o, to_py_func(i)))
502 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
503 if (likely(o != Py_None)) {
504 if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
505 PyObject *r = PyTuple_GET_ITEM(o, i);
509 else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
510 PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
515 return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
519 #define __Pyx_GetItemInt(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
520 __Pyx_GetItemInt_Fast(o, i, size <= sizeof(long)) : \
521 __Pyx_GetItemInt_Generic(o, to_py_func(i)))
523 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
525 if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
526 r = PyList_GET_ITEM(o, i);
529 else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
530 r = PyTuple_GET_ITEM(o, i);
533 else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
534 r = PySequence_GetItem(o, i);
537 r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
542 static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */
544 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
545 const char *name, int exact); /*proto*/
547 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
549 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
550 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
552 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
554 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
556 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
558 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
560 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
562 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
564 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
566 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
568 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
570 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
572 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
574 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
576 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
578 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
580 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
582 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
584 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
586 static void __Pyx_AddTraceback(const char *funcname); /*proto*/
588 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
589 /* Module declarations from sphinxbase */
591 static PyTypeObject *__pyx_ptype_10sphinxbase_NGramModel = 0;
592 static PyTypeObject *__pyx_ptype_10sphinxbase_LogMath = 0;
593 static PyTypeObject *__pyx_ptype_10sphinxbase_NGramIter = 0;
594 static PyTypeObject *__pyx_ptype_10sphinxbase_HuffCode = 0;
595 #define __Pyx_MODULE_NAME "sphinxbase"
596 int __pyx_module_is_main_sphinxbase = 0;
598 /* Implementation of sphinxbase */
599 static PyObject *__pyx_builtin_range;
600 static PyObject *__pyx_builtin_ValueError;
601 static PyObject *__pyx_builtin_StopIteration;
602 static PyObject *__pyx_builtin_ord;
603 static PyObject *__pyx_builtin_min;
604 static PyObject *__pyx_builtin_enumerate;
605 static PyObject *__pyx_builtin_RuntimeError;
606 static char __pyx_k_9[] = "Recode from %s to %s failed";
607 static char __pyx_k_10[] = "Casefolding failed";
608 static char __pyx_k_12[] = "Write %s to file failed";
609 static char __pyx_k_13[] = "";
610 static char __pyx_k_14[] = "%d";
611 static char __pyx_k_15[] = "%s";
612 static char __pyx_k_16[] = "One of alphabet or infile must be passed to constructor";
613 static char __pyx_k_17[] = "Only one of alphabet or infile must be passed to constructor";
614 static char __pyx_k_18[] = "Invalid data at position %d";
615 static char __pyx_k_19[] = "No file is attached";
616 static char __pyx_k__a[] = "a";
617 static char __pyx_k__b[] = "b";
618 static char __pyx_k__m[] = "m";
619 static char __pyx_k__w[] = "w";
620 static char __pyx_k__cw[] = "cw";
621 static char __pyx_k__fh[] = "fh";
622 static char __pyx_k__hc[] = "hc";
623 static char __pyx_k__lm[] = "lm";
624 static char __pyx_k__lw[] = "lw";
625 static char __pyx_k__rb[] = "rb";
626 static char __pyx_k__uw[] = "uw";
627 static char __pyx_k__wb[] = "wb";
628 static char __pyx_k__DMP[] = "DMP";
629 static char __pyx_k__min[] = "min";
630 static char __pyx_k__ord[] = "ord";
631 static char __pyx_k__too[] = "too";
632 static char __pyx_k__val[] = "val";
633 static char __pyx_k__wip[] = "wip";
634 static char __pyx_k__ARPA[] = "ARPA";
635 static char __pyx_k__AUTO[] = "AUTO";
636 static char __pyx_k__base[] = "base";
637 static char __pyx_k__file[] = "file";
638 static char __pyx_k__frum[] = "frum";
639 static char __pyx_k__itor[] = "itor";
640 static char __pyx_k__mode[] = "mode";
641 static char __pyx_k__read[] = "read";
642 static char __pyx_k__word[] = "word";
643 static char __pyx_k__LOWER[] = "LOWER";
644 static char __pyx_k__UPPER[] = "UPPER";
645 static char __pyx_k__lmath[] = "lmath";
646 static char __pyx_k__lmctl[] = "lmctl";
647 static char __pyx_k__nbits[] = "nbits";
648 static char __pyx_k__range[] = "range";
649 static char __pyx_k__shift[] = "shift";
650 static char __pyx_k__words[] = "words";
651 static char __pyx_k__detach[] = "detach";
652 static char __pyx_k__format[] = "format";
653 static char __pyx_k__infile[] = "infile";
654 static char __pyx_k__weight[] = "weight";
655 static char __pyx_k____main__[] = "__main__";
656 static char __pyx_k__alphabet[] = "alphabet";
657 static char __pyx_k__log_bowt[] = "log_bowt";
658 static char __pyx_k__log_prob[] = "log_prob";
659 static char __pyx_k__set_iter[] = "set_iter";
660 static char __pyx_k__enumerate[] = "enumerate";
661 static char __pyx_k__file_name[] = "file_name";
662 static char __pyx_k__use_table[] = "use_table";
663 static char __pyx_k__ValueError[] = "ValueError";
664 static char __pyx_k__first_item[] = "first_item";
665 static char __pyx_k__RuntimeError[] = "RuntimeError";
666 static char __pyx_k__StopIteration[] = "StopIteration";
667 static PyObject *__pyx_kp_s_10;
668 static PyObject *__pyx_kp_s_12;
669 static PyObject *__pyx_kp_s_13;
670 static PyObject *__pyx_kp_s_14;
671 static PyObject *__pyx_kp_s_15;
672 static PyObject *__pyx_kp_s_16;
673 static PyObject *__pyx_kp_s_17;
674 static PyObject *__pyx_kp_s_18;
675 static PyObject *__pyx_kp_s_19;
676 static PyObject *__pyx_kp_s_9;
677 static PyObject *__pyx_n_s__ARPA;
678 static PyObject *__pyx_n_s__AUTO;
679 static PyObject *__pyx_n_s__DMP;
680 static PyObject *__pyx_n_s__LOWER;
681 static PyObject *__pyx_n_s__RuntimeError;
682 static PyObject *__pyx_n_s__StopIteration;
683 static PyObject *__pyx_n_s__UPPER;
684 static PyObject *__pyx_n_s__ValueError;
685 static PyObject *__pyx_n_s____main__;
686 static PyObject *__pyx_n_s__a;
687 static PyObject *__pyx_n_s__alphabet;
688 static PyObject *__pyx_n_s__b;
689 static PyObject *__pyx_n_s__base;
690 static PyObject *__pyx_n_s__cw;
691 static PyObject *__pyx_n_s__detach;
692 static PyObject *__pyx_n_s__enumerate;
693 static PyObject *__pyx_n_s__fh;
694 static PyObject *__pyx_n_s__file;
695 static PyObject *__pyx_n_s__file_name;
696 static PyObject *__pyx_n_s__first_item;
697 static PyObject *__pyx_n_s__format;
698 static PyObject *__pyx_n_s__frum;
699 static PyObject *__pyx_n_s__hc;
700 static PyObject *__pyx_n_s__infile;
701 static PyObject *__pyx_n_s__itor;
702 static PyObject *__pyx_n_s__lm;
703 static PyObject *__pyx_n_s__lmath;
704 static PyObject *__pyx_n_s__lmctl;
705 static PyObject *__pyx_n_s__log_bowt;
706 static PyObject *__pyx_n_s__log_prob;
707 static PyObject *__pyx_n_s__lw;
708 static PyObject *__pyx_n_s__m;
709 static PyObject *__pyx_n_s__min;
710 static PyObject *__pyx_n_s__mode;
711 static PyObject *__pyx_n_s__nbits;
712 static PyObject *__pyx_n_s__ord;
713 static PyObject *__pyx_n_s__range;
714 static PyObject *__pyx_n_s__rb;
715 static PyObject *__pyx_n_s__read;
716 static PyObject *__pyx_n_s__set_iter;
717 static PyObject *__pyx_n_s__shift;
718 static PyObject *__pyx_n_s__too;
719 static PyObject *__pyx_n_s__use_table;
720 static PyObject *__pyx_n_s__uw;
721 static PyObject *__pyx_n_s__val;
722 static PyObject *__pyx_n_s__w;
723 static PyObject *__pyx_n_s__wb;
724 static PyObject *__pyx_n_s__weight;
725 static PyObject *__pyx_n_s__wip;
726 static PyObject *__pyx_n_s__word;
727 static PyObject *__pyx_n_s__words;
728 static PyObject *__pyx_int_0;
729 static PyObject *__pyx_int_1;
730 static PyObject *__pyx_int_8;
731 static PyObject *__pyx_k_1;
732 static PyObject *__pyx_k_2;
733 static PyObject *__pyx_k_3;
734 static PyObject *__pyx_k_4;
735 static PyObject *__pyx_k_5;
736 static PyObject *__pyx_k_6;
737 static PyObject *__pyx_k_7;
738 static PyObject *__pyx_k_8;
739 static PyObject *__pyx_k_11;
741 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":24
742 * @type use_table: bool
744 * def __init__(self, base=1.0001, shift=0, use_table=1): # <<<<<<<<<<<<<<
745 * self.lmath = logmath_init(base, shift, use_table)
749 static int __pyx_pf_10sphinxbase_7LogMath___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
750 static int __pyx_pf_10sphinxbase_7LogMath___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
751 PyObject *__pyx_v_base = 0;
752 PyObject *__pyx_v_shift = 0;
753 PyObject *__pyx_v_use_table = 0;
755 __pyx_t_10sphinxbase_float64 __pyx_t_1;
758 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__base,&__pyx_n_s__shift,&__pyx_n_s__use_table,0};
759 __Pyx_RefNannySetupContext("__init__");
760 if (unlikely(__pyx_kwds)) {
761 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
762 PyObject* values[3] = {0,0,0};
763 values[0] = __pyx_k_1;
764 values[1] = ((PyObject *)__pyx_int_0);
765 values[2] = ((PyObject *)__pyx_int_1);
766 switch (PyTuple_GET_SIZE(__pyx_args)) {
767 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
768 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
769 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
771 default: goto __pyx_L5_argtuple_error;
773 switch (PyTuple_GET_SIZE(__pyx_args)) {
776 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__base);
777 if (unlikely(value)) { values[0] = value; kw_args--; }
781 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__shift);
782 if (unlikely(value)) { values[1] = value; kw_args--; }
786 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_table);
787 if (unlikely(value)) { values[2] = value; kw_args--; }
790 if (unlikely(kw_args > 0)) {
791 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
793 __pyx_v_base = values[0];
794 __pyx_v_shift = values[1];
795 __pyx_v_use_table = values[2];
797 __pyx_v_base = __pyx_k_1;
798 __pyx_v_shift = ((PyObject *)__pyx_int_0);
799 __pyx_v_use_table = ((PyObject *)__pyx_int_1);
800 switch (PyTuple_GET_SIZE(__pyx_args)) {
801 case 3: __pyx_v_use_table = PyTuple_GET_ITEM(__pyx_args, 2);
802 case 2: __pyx_v_shift = PyTuple_GET_ITEM(__pyx_args, 1);
803 case 1: __pyx_v_base = PyTuple_GET_ITEM(__pyx_args, 0);
805 default: goto __pyx_L5_argtuple_error;
808 goto __pyx_L4_argument_unpacking_done;
809 __pyx_L5_argtuple_error:;
810 __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
812 __Pyx_AddTraceback("sphinxbase.LogMath.__init__");
814 __pyx_L4_argument_unpacking_done:;
816 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":25
818 * def __init__(self, base=1.0001, shift=0, use_table=1):
819 * self.lmath = logmath_init(base, shift, use_table) # <<<<<<<<<<<<<<
821 * def __dealloc__(self):
823 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_base); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
824 __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_shift); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
825 __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_use_table); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
826 ((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath = logmath_init(__pyx_t_1, __pyx_t_2, __pyx_t_3);
831 __Pyx_AddTraceback("sphinxbase.LogMath.__init__");
834 __Pyx_RefNannyFinishContext();
838 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":27
839 * self.lmath = logmath_init(base, shift, use_table)
841 * def __dealloc__(self): # <<<<<<<<<<<<<<
843 * Destructor for LogMath class.
846 static void __pyx_pf_10sphinxbase_7LogMath___dealloc__(PyObject *__pyx_v_self); /*proto*/
847 static char __pyx_doc_10sphinxbase_7LogMath___dealloc__[] = "\n Destructor for LogMath class.\n ";
848 static void __pyx_pf_10sphinxbase_7LogMath___dealloc__(PyObject *__pyx_v_self) {
849 __Pyx_RefNannySetupContext("__dealloc__");
851 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":31
852 * Destructor for LogMath class.
854 * logmath_free(self.lmath) # <<<<<<<<<<<<<<
856 * def get_zero(self):
858 logmath_free(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath);
860 __Pyx_RefNannyFinishContext();
863 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":33
864 * logmath_free(self.lmath)
866 * def get_zero(self): # <<<<<<<<<<<<<<
868 * Get the log-zero value.
871 static PyObject *__pyx_pf_10sphinxbase_7LogMath_get_zero(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
872 static char __pyx_doc_10sphinxbase_7LogMath_get_zero[] = "\n Get the log-zero value.\n\n @return: Smallest number representable by this object.\n @rtype: int\n ";
873 static PyObject *__pyx_pf_10sphinxbase_7LogMath_get_zero(PyObject *__pyx_v_self, PyObject *unused) {
874 PyObject *__pyx_r = NULL;
875 PyObject *__pyx_t_1 = NULL;
876 __Pyx_RefNannySetupContext("get_zero");
878 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":40
881 * return logmath_get_zero(self.lmath) # <<<<<<<<<<<<<<
883 * def add(self, a, b):
885 __Pyx_XDECREF(__pyx_r);
886 __pyx_t_1 = PyInt_FromLong(logmath_get_zero(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
887 __Pyx_GOTREF(__pyx_t_1);
892 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
895 __Pyx_XDECREF(__pyx_t_1);
896 __Pyx_AddTraceback("sphinxbase.LogMath.get_zero");
899 __Pyx_XGIVEREF(__pyx_r);
900 __Pyx_RefNannyFinishContext();
904 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":42
905 * return logmath_get_zero(self.lmath)
907 * def add(self, a, b): # <<<<<<<<<<<<<<
909 * Add two numbers in log-space.
912 static PyObject *__pyx_pf_10sphinxbase_7LogMath_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
913 static char __pyx_doc_10sphinxbase_7LogMath_add[] = "\n Add two numbers in log-space.\n\n @param a: Logarithm A.\n @type a: int\n @param b: Logarithm B.\n @type b: int\n @return: log(exp(a)+exp(b))\n @rtype: int\n ";
914 static PyObject *__pyx_pf_10sphinxbase_7LogMath_add(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
915 PyObject *__pyx_v_a = 0;
916 PyObject *__pyx_v_b = 0;
917 PyObject *__pyx_r = NULL;
920 PyObject *__pyx_t_3 = NULL;
921 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__a,&__pyx_n_s__b,0};
922 __Pyx_RefNannySetupContext("add");
923 if (unlikely(__pyx_kwds)) {
924 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
925 PyObject* values[2] = {0,0};
926 switch (PyTuple_GET_SIZE(__pyx_args)) {
927 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
928 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
930 default: goto __pyx_L5_argtuple_error;
932 switch (PyTuple_GET_SIZE(__pyx_args)) {
934 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__a);
935 if (likely(values[0])) kw_args--;
936 else goto __pyx_L5_argtuple_error;
938 values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b);
939 if (likely(values[1])) kw_args--;
941 __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
944 if (unlikely(kw_args > 0)) {
945 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
947 __pyx_v_a = values[0];
948 __pyx_v_b = values[1];
949 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
950 goto __pyx_L5_argtuple_error;
952 __pyx_v_a = PyTuple_GET_ITEM(__pyx_args, 0);
953 __pyx_v_b = PyTuple_GET_ITEM(__pyx_args, 1);
955 goto __pyx_L4_argument_unpacking_done;
956 __pyx_L5_argtuple_error:;
957 __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
959 __Pyx_AddTraceback("sphinxbase.LogMath.add");
961 __pyx_L4_argument_unpacking_done:;
963 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":53
966 * return logmath_add(self.lmath, a, b) # <<<<<<<<<<<<<<
970 __Pyx_XDECREF(__pyx_r);
971 __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_a); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
972 __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_v_b); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
973 __pyx_t_3 = PyInt_FromLong(logmath_add(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1, __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
974 __Pyx_GOTREF(__pyx_t_3);
979 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
982 __Pyx_XDECREF(__pyx_t_3);
983 __Pyx_AddTraceback("sphinxbase.LogMath.add");
986 __Pyx_XGIVEREF(__pyx_r);
987 __Pyx_RefNannyFinishContext();
991 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":55
992 * return logmath_add(self.lmath, a, b)
994 * def log(self, x): # <<<<<<<<<<<<<<
996 * Return log-value of a number.
999 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
1000 static char __pyx_doc_10sphinxbase_7LogMath_log[] = "\n Return log-value of a number.\n\n @param x: Number (in linear space)\n @type x: float\n @return: Log-value of x.\n @rtype: int\n ";
1001 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
1002 PyObject *__pyx_r = NULL;
1003 __pyx_t_10sphinxbase_float64 __pyx_t_1;
1004 PyObject *__pyx_t_2 = NULL;
1005 __Pyx_RefNannySetupContext("log");
1007 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":64
1010 * return logmath_log(self.lmath, x) # <<<<<<<<<<<<<<
1014 __Pyx_XDECREF(__pyx_r);
1015 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1016 __pyx_t_2 = PyInt_FromLong(logmath_log(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1017 __Pyx_GOTREF(__pyx_t_2);
1018 __pyx_r = __pyx_t_2;
1022 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1025 __Pyx_XDECREF(__pyx_t_2);
1026 __Pyx_AddTraceback("sphinxbase.LogMath.log");
1029 __Pyx_XGIVEREF(__pyx_r);
1030 __Pyx_RefNannyFinishContext();
1034 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":66
1035 * return logmath_log(self.lmath, x)
1037 * def exp(self, x): # <<<<<<<<<<<<<<
1039 * Return linear of a log-value
1042 static PyObject *__pyx_pf_10sphinxbase_7LogMath_exp(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
1043 static char __pyx_doc_10sphinxbase_7LogMath_exp[] = "\n Return linear of a log-value\n\n @param x: Logarithm X (in this object's base)\n @type x: int\n @return: Exponent (linear value) of X.\n @rtype: float\n ";
1044 static PyObject *__pyx_pf_10sphinxbase_7LogMath_exp(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
1045 PyObject *__pyx_r = NULL;
1047 PyObject *__pyx_t_2 = NULL;
1048 __Pyx_RefNannySetupContext("exp");
1050 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":75
1053 * return logmath_exp(self.lmath, x) # <<<<<<<<<<<<<<
1055 * def log_to_ln(self, x):
1057 __Pyx_XDECREF(__pyx_r);
1058 __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_x); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1059 __pyx_t_2 = PyFloat_FromDouble(logmath_exp(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1060 __Pyx_GOTREF(__pyx_t_2);
1061 __pyx_r = __pyx_t_2;
1065 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1068 __Pyx_XDECREF(__pyx_t_2);
1069 __Pyx_AddTraceback("sphinxbase.LogMath.exp");
1072 __Pyx_XGIVEREF(__pyx_r);
1073 __Pyx_RefNannyFinishContext();
1077 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":77
1078 * return logmath_exp(self.lmath, x)
1080 * def log_to_ln(self, x): # <<<<<<<<<<<<<<
1082 * Return natural logarithm of a log-value.
1085 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log_to_ln(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
1086 static char __pyx_doc_10sphinxbase_7LogMath_log_to_ln[] = "\n Return natural logarithm of a log-value.\n\n @param x: Logarithm X (in this object's base)\n @type x: int\n @return: Natural log equivalent of x.\n @rtype: float\n ";
1087 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log_to_ln(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
1088 PyObject *__pyx_r = NULL;
1090 PyObject *__pyx_t_2 = NULL;
1091 __Pyx_RefNannySetupContext("log_to_ln");
1093 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":86
1096 * return logmath_log_to_ln(self.lmath, x) # <<<<<<<<<<<<<<
1098 * def log_to_log10(self, x):
1100 __Pyx_XDECREF(__pyx_r);
1101 __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_x); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1102 __pyx_t_2 = PyFloat_FromDouble(logmath_log_to_ln(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1103 __Pyx_GOTREF(__pyx_t_2);
1104 __pyx_r = __pyx_t_2;
1108 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1111 __Pyx_XDECREF(__pyx_t_2);
1112 __Pyx_AddTraceback("sphinxbase.LogMath.log_to_ln");
1115 __Pyx_XGIVEREF(__pyx_r);
1116 __Pyx_RefNannyFinishContext();
1120 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":88
1121 * return logmath_log_to_ln(self.lmath, x)
1123 * def log_to_log10(self, x): # <<<<<<<<<<<<<<
1125 * Return logarithm in base 10 of a log-value.
1128 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log_to_log10(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
1129 static char __pyx_doc_10sphinxbase_7LogMath_log_to_log10[] = "\n Return logarithm in base 10 of a log-value.\n\n @param x: Logarithm X (in this object's base)\n @type x: int\n @return: log10 equivalent of x.\n @rtype: float\n ";
1130 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log_to_log10(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
1131 PyObject *__pyx_r = NULL;
1133 PyObject *__pyx_t_2 = NULL;
1134 __Pyx_RefNannySetupContext("log_to_log10");
1136 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":97
1139 * return logmath_log_to_log10(self.lmath, x) # <<<<<<<<<<<<<<
1141 * def ln_to_log(self, x):
1143 __Pyx_XDECREF(__pyx_r);
1144 __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_x); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1145 __pyx_t_2 = PyFloat_FromDouble(logmath_log_to_log10(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1146 __Pyx_GOTREF(__pyx_t_2);
1147 __pyx_r = __pyx_t_2;
1151 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1154 __Pyx_XDECREF(__pyx_t_2);
1155 __Pyx_AddTraceback("sphinxbase.LogMath.log_to_log10");
1158 __Pyx_XGIVEREF(__pyx_r);
1159 __Pyx_RefNannyFinishContext();
1163 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":99
1164 * return logmath_log_to_log10(self.lmath, x)
1166 * def ln_to_log(self, x): # <<<<<<<<<<<<<<
1168 * Return log-value of a natural logarithm.
1171 static PyObject *__pyx_pf_10sphinxbase_7LogMath_ln_to_log(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
1172 static char __pyx_doc_10sphinxbase_7LogMath_ln_to_log[] = "\n Return log-value of a natural logarithm.\n\n @param x: Logarithm X (in base e)\n @type x: float\n @return: Log-value equivalent of x.\n @rtype: int\n ";
1173 static PyObject *__pyx_pf_10sphinxbase_7LogMath_ln_to_log(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
1174 PyObject *__pyx_r = NULL;
1175 __pyx_t_10sphinxbase_float64 __pyx_t_1;
1176 PyObject *__pyx_t_2 = NULL;
1177 __Pyx_RefNannySetupContext("ln_to_log");
1179 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":108
1182 * return logmath_ln_to_log(self.lmath, x) # <<<<<<<<<<<<<<
1184 * def log10_to_log(self, x):
1186 __Pyx_XDECREF(__pyx_r);
1187 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1188 __pyx_t_2 = PyInt_FromLong(logmath_ln_to_log(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1189 __Pyx_GOTREF(__pyx_t_2);
1190 __pyx_r = __pyx_t_2;
1194 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1197 __Pyx_XDECREF(__pyx_t_2);
1198 __Pyx_AddTraceback("sphinxbase.LogMath.ln_to_log");
1201 __Pyx_XGIVEREF(__pyx_r);
1202 __Pyx_RefNannyFinishContext();
1206 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":110
1207 * return logmath_ln_to_log(self.lmath, x)
1209 * def log10_to_log(self, x): # <<<<<<<<<<<<<<
1211 * Return log-value of a base 10 logarithm.
1214 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log10_to_log(PyObject *__pyx_v_self, PyObject *__pyx_v_x); /*proto*/
1215 static char __pyx_doc_10sphinxbase_7LogMath_log10_to_log[] = "\n Return log-value of a base 10 logarithm.\n\n @param x: Logarithm X (in base 10)\n @type x: float\n @return: Log-value equivalent of x.\n @rtype: int\n ";
1216 static PyObject *__pyx_pf_10sphinxbase_7LogMath_log10_to_log(PyObject *__pyx_v_self, PyObject *__pyx_v_x) {
1217 PyObject *__pyx_r = NULL;
1218 __pyx_t_10sphinxbase_float64 __pyx_t_1;
1219 PyObject *__pyx_t_2 = NULL;
1220 __Pyx_RefNannySetupContext("log10_to_log");
1222 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":119
1225 * return logmath_log10_to_log(self.lmath, x) # <<<<<<<<<<<<<<
1227 * # Unfortunately, Cython doesn't actually export enums to Python...
1229 __Pyx_XDECREF(__pyx_r);
1230 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_x); if (unlikely((__pyx_t_1 == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1231 __pyx_t_2 = PyInt_FromLong(logmath_log10_to_log(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1232 __Pyx_GOTREF(__pyx_t_2);
1233 __pyx_r = __pyx_t_2;
1237 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1240 __Pyx_XDECREF(__pyx_t_2);
1241 __Pyx_AddTraceback("sphinxbase.LogMath.log10_to_log");
1244 __Pyx_XGIVEREF(__pyx_r);
1245 __Pyx_RefNannyFinishContext();
1249 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":146
1252 * def __init__(self, file=None, lw=1.0, wip=1.0, uw=1.0, lmctl=None): # <<<<<<<<<<<<<<
1253 * self.lmath = logmath_init(1.0001, 0, 0)
1257 static int __pyx_pf_10sphinxbase_10NGramModel___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1258 static int __pyx_pf_10sphinxbase_10NGramModel___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1259 PyObject *__pyx_v_file = 0;
1260 PyObject *__pyx_v_lw = 0;
1261 PyObject *__pyx_v_wip = 0;
1262 PyObject *__pyx_v_uw = 0;
1263 PyObject *__pyx_v_lmctl = 0;
1267 __pyx_t_10sphinxbase_float32 __pyx_t_3;
1268 __pyx_t_10sphinxbase_float32 __pyx_t_4;
1269 __pyx_t_10sphinxbase_float32 __pyx_t_5;
1271 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__file,&__pyx_n_s__lw,&__pyx_n_s__wip,&__pyx_n_s__uw,&__pyx_n_s__lmctl,0};
1272 __Pyx_RefNannySetupContext("__init__");
1273 if (unlikely(__pyx_kwds)) {
1274 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
1275 PyObject* values[5] = {0,0,0,0,0};
1276 values[0] = ((PyObject *)Py_None);
1277 values[1] = __pyx_k_2;
1278 values[2] = __pyx_k_3;
1279 values[3] = __pyx_k_4;
1280 values[4] = ((PyObject *)Py_None);
1281 switch (PyTuple_GET_SIZE(__pyx_args)) {
1282 case 5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
1283 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
1284 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1285 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1286 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1288 default: goto __pyx_L5_argtuple_error;
1290 switch (PyTuple_GET_SIZE(__pyx_args)) {
1293 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__file);
1294 if (unlikely(value)) { values[0] = value; kw_args--; }
1298 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lw);
1299 if (unlikely(value)) { values[1] = value; kw_args--; }
1303 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wip);
1304 if (unlikely(value)) { values[2] = value; kw_args--; }
1308 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__uw);
1309 if (unlikely(value)) { values[3] = value; kw_args--; }
1313 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lmctl);
1314 if (unlikely(value)) { values[4] = value; kw_args--; }
1317 if (unlikely(kw_args > 0)) {
1318 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1320 __pyx_v_file = values[0];
1321 __pyx_v_lw = values[1];
1322 __pyx_v_wip = values[2];
1323 __pyx_v_uw = values[3];
1324 __pyx_v_lmctl = values[4];
1326 __pyx_v_file = ((PyObject *)Py_None);
1327 __pyx_v_lw = __pyx_k_2;
1328 __pyx_v_wip = __pyx_k_3;
1329 __pyx_v_uw = __pyx_k_4;
1330 __pyx_v_lmctl = ((PyObject *)Py_None);
1331 switch (PyTuple_GET_SIZE(__pyx_args)) {
1332 case 5: __pyx_v_lmctl = PyTuple_GET_ITEM(__pyx_args, 4);
1333 case 4: __pyx_v_uw = PyTuple_GET_ITEM(__pyx_args, 3);
1334 case 3: __pyx_v_wip = PyTuple_GET_ITEM(__pyx_args, 2);
1335 case 2: __pyx_v_lw = PyTuple_GET_ITEM(__pyx_args, 1);
1336 case 1: __pyx_v_file = PyTuple_GET_ITEM(__pyx_args, 0);
1338 default: goto __pyx_L5_argtuple_error;
1341 goto __pyx_L4_argument_unpacking_done;
1342 __pyx_L5_argtuple_error:;
1343 __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1345 __Pyx_AddTraceback("sphinxbase.NGramModel.__init__");
1347 __pyx_L4_argument_unpacking_done:;
1348 __Pyx_INCREF((PyObject *)__pyx_v_self);
1349 __Pyx_INCREF(__pyx_v_file);
1350 __Pyx_INCREF(__pyx_v_lw);
1351 __Pyx_INCREF(__pyx_v_wip);
1352 __Pyx_INCREF(__pyx_v_uw);
1353 __Pyx_INCREF(__pyx_v_lmctl);
1355 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":147
1357 * def __init__(self, file=None, lw=1.0, wip=1.0, uw=1.0, lmctl=None):
1358 * self.lmath = logmath_init(1.0001, 0, 0) # <<<<<<<<<<<<<<
1360 * self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)
1362 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath = logmath_init(1.0001, 0, 0);
1364 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":148
1365 * def __init__(self, file=None, lw=1.0, wip=1.0, uw=1.0, lmctl=None):
1366 * self.lmath = logmath_init(1.0001, 0, 0)
1367 * if file: # <<<<<<<<<<<<<<
1368 * self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)
1369 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1371 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_file); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1374 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":149
1375 * self.lmath = logmath_init(1.0001, 0, 0)
1377 * self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath) # <<<<<<<<<<<<<<
1378 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1381 __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_file); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1382 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm = ngram_model_read(NULL, __pyx_t_2, NGRAM_AUTO, ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath);
1384 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":150
1386 * self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)
1387 * ngram_model_apply_weights(self.lm, lw, wip, uw) # <<<<<<<<<<<<<<
1389 * self.lm = ngram_model_set_read(NULL, lmctl, self.lmath)
1391 __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_lw); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1392 __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_wip); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1393 __pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_uw); if (unlikely((__pyx_t_5 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1394 ngram_model_apply_weights(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_3, __pyx_t_4, __pyx_t_5);
1398 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":151
1399 * self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)
1400 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1401 * elif lmctl: # <<<<<<<<<<<<<<
1402 * self.lm = ngram_model_set_read(NULL, lmctl, self.lmath)
1405 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_lmctl); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1408 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":152
1409 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1411 * self.lm = ngram_model_set_read(NULL, lmctl, self.lmath) # <<<<<<<<<<<<<<
1415 __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_lmctl); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1416 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm = ngram_model_set_read(NULL, __pyx_t_2, ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath);
1421 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":154
1422 * self.lm = ngram_model_set_read(NULL, lmctl, self.lmath)
1424 * self.lm = NULL # <<<<<<<<<<<<<<
1428 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm = NULL;
1432 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":155
1435 * self.lw = lw # <<<<<<<<<<<<<<
1439 __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_v_lw); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1440 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lw = __pyx_t_6;
1442 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":156
1445 * self.wip = wip # <<<<<<<<<<<<<<
1449 __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_v_wip); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1450 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->wip = __pyx_t_6;
1452 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":157
1455 * self.uw = uw # <<<<<<<<<<<<<<
1457 * cdef set_lm(NGramModel self, ngram_model_t *lm):
1459 __pyx_t_6 = __pyx_PyFloat_AsDouble(__pyx_v_uw); if (unlikely((__pyx_t_6 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1460 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->uw = __pyx_t_6;
1465 __Pyx_AddTraceback("sphinxbase.NGramModel.__init__");
1468 __Pyx_DECREF((PyObject *)__pyx_v_self);
1469 __Pyx_DECREF(__pyx_v_file);
1470 __Pyx_DECREF(__pyx_v_lw);
1471 __Pyx_DECREF(__pyx_v_wip);
1472 __Pyx_DECREF(__pyx_v_uw);
1473 __Pyx_DECREF(__pyx_v_lmctl);
1474 __Pyx_RefNannyFinishContext();
1478 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":159
1481 * cdef set_lm(NGramModel self, ngram_model_t *lm): # <<<<<<<<<<<<<<
1482 * ngram_model_retain(lm)
1483 * ngram_model_free(self.lm)
1486 static PyObject *__pyx_f_10sphinxbase_10NGramModel_set_lm(struct __pyx_obj_10sphinxbase_NGramModel *__pyx_v_self, ngram_model_t *__pyx_v_lm) {
1487 PyObject *__pyx_r = NULL;
1488 __Pyx_RefNannySetupContext("set_lm");
1490 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":160
1492 * cdef set_lm(NGramModel self, ngram_model_t *lm):
1493 * ngram_model_retain(lm) # <<<<<<<<<<<<<<
1494 * ngram_model_free(self.lm)
1497 ngram_model_retain(__pyx_v_lm);
1499 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":161
1500 * cdef set_lm(NGramModel self, ngram_model_t *lm):
1501 * ngram_model_retain(lm)
1502 * ngram_model_free(self.lm) # <<<<<<<<<<<<<<
1506 ngram_model_free(__pyx_v_self->lm);
1508 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":162
1509 * ngram_model_retain(lm)
1510 * ngram_model_free(self.lm)
1511 * self.lm = lm # <<<<<<<<<<<<<<
1513 * cdef set_lmath(NGramModel self, logmath_t *lmath):
1515 __pyx_v_self->lm = __pyx_v_lm;
1517 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1518 __Pyx_XGIVEREF(__pyx_r);
1519 __Pyx_RefNannyFinishContext();
1523 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":164
1526 * cdef set_lmath(NGramModel self, logmath_t *lmath): # <<<<<<<<<<<<<<
1527 * logmath_retain(lmath)
1528 * logmath_free(self.lmath)
1531 static PyObject *__pyx_f_10sphinxbase_10NGramModel_set_lmath(struct __pyx_obj_10sphinxbase_NGramModel *__pyx_v_self, logmath_t *__pyx_v_lmath) {
1532 PyObject *__pyx_r = NULL;
1533 __Pyx_RefNannySetupContext("set_lmath");
1535 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":165
1537 * cdef set_lmath(NGramModel self, logmath_t *lmath):
1538 * logmath_retain(lmath) # <<<<<<<<<<<<<<
1539 * logmath_free(self.lmath)
1540 * self.lmath = lmath
1542 logmath_retain(__pyx_v_lmath);
1544 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":166
1545 * cdef set_lmath(NGramModel self, logmath_t *lmath):
1546 * logmath_retain(lmath)
1547 * logmath_free(self.lmath) # <<<<<<<<<<<<<<
1548 * self.lmath = lmath
1551 logmath_free(__pyx_v_self->lmath);
1553 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":167
1554 * logmath_retain(lmath)
1555 * logmath_free(self.lmath)
1556 * self.lmath = lmath # <<<<<<<<<<<<<<
1558 * def __dealloc__(self):
1560 __pyx_v_self->lmath = __pyx_v_lmath;
1562 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1563 __Pyx_XGIVEREF(__pyx_r);
1564 __Pyx_RefNannyFinishContext();
1568 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":169
1569 * self.lmath = lmath
1571 * def __dealloc__(self): # <<<<<<<<<<<<<<
1573 * Destructor for N-Gram model class.
1576 static void __pyx_pf_10sphinxbase_10NGramModel___dealloc__(PyObject *__pyx_v_self); /*proto*/
1577 static char __pyx_doc_10sphinxbase_10NGramModel___dealloc__[] = "\n Destructor for N-Gram model class.\n ";
1578 static void __pyx_pf_10sphinxbase_10NGramModel___dealloc__(PyObject *__pyx_v_self) {
1579 __Pyx_RefNannySetupContext("__dealloc__");
1581 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":173
1582 * Destructor for N-Gram model class.
1584 * logmath_free(self.lmath) # <<<<<<<<<<<<<<
1585 * ngram_model_free(self.lm)
1588 logmath_free(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath);
1590 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":174
1592 * logmath_free(self.lmath)
1593 * ngram_model_free(self.lm) # <<<<<<<<<<<<<<
1595 * def apply_weights(self, lw=1.0, wip=1.0, uw=1.0):
1597 ngram_model_free(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm);
1599 __Pyx_RefNannyFinishContext();
1602 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":176
1603 * ngram_model_free(self.lm)
1605 * def apply_weights(self, lw=1.0, wip=1.0, uw=1.0): # <<<<<<<<<<<<<<
1607 * Change the language model weights applied in L{score}.
1610 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_apply_weights(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1611 static char __pyx_doc_10sphinxbase_10NGramModel_apply_weights[] = "\n Change the language model weights applied in L{score}.\n \n @param lw: Language weight to apply to model probabilities.\n @type lw: float\n @param wip: Word insertion penalty to add to model probabilities\n @type wip: float\n @param uw: Weight to give unigrams when interpolating with uniform distribution.\n @type uw: float\n ";
1612 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_apply_weights(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1613 PyObject *__pyx_v_lw = 0;
1614 PyObject *__pyx_v_wip = 0;
1615 PyObject *__pyx_v_uw = 0;
1616 PyObject *__pyx_r = NULL;
1618 __pyx_t_10sphinxbase_float32 __pyx_t_2;
1619 __pyx_t_10sphinxbase_float32 __pyx_t_3;
1620 __pyx_t_10sphinxbase_float32 __pyx_t_4;
1621 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lw,&__pyx_n_s__wip,&__pyx_n_s__uw,0};
1622 __Pyx_RefNannySetupContext("apply_weights");
1623 if (unlikely(__pyx_kwds)) {
1624 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
1625 PyObject* values[3] = {0,0,0};
1626 values[0] = __pyx_k_5;
1627 values[1] = __pyx_k_6;
1628 values[2] = __pyx_k_7;
1629 switch (PyTuple_GET_SIZE(__pyx_args)) {
1630 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1631 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1632 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1634 default: goto __pyx_L5_argtuple_error;
1636 switch (PyTuple_GET_SIZE(__pyx_args)) {
1639 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lw);
1640 if (unlikely(value)) { values[0] = value; kw_args--; }
1644 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wip);
1645 if (unlikely(value)) { values[1] = value; kw_args--; }
1649 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__uw);
1650 if (unlikely(value)) { values[2] = value; kw_args--; }
1653 if (unlikely(kw_args > 0)) {
1654 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "apply_weights") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1656 __pyx_v_lw = values[0];
1657 __pyx_v_wip = values[1];
1658 __pyx_v_uw = values[2];
1660 __pyx_v_lw = __pyx_k_5;
1661 __pyx_v_wip = __pyx_k_6;
1662 __pyx_v_uw = __pyx_k_7;
1663 switch (PyTuple_GET_SIZE(__pyx_args)) {
1664 case 3: __pyx_v_uw = PyTuple_GET_ITEM(__pyx_args, 2);
1665 case 2: __pyx_v_wip = PyTuple_GET_ITEM(__pyx_args, 1);
1666 case 1: __pyx_v_lw = PyTuple_GET_ITEM(__pyx_args, 0);
1668 default: goto __pyx_L5_argtuple_error;
1671 goto __pyx_L4_argument_unpacking_done;
1672 __pyx_L5_argtuple_error:;
1673 __Pyx_RaiseArgtupleInvalid("apply_weights", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1675 __Pyx_AddTraceback("sphinxbase.NGramModel.apply_weights");
1677 __pyx_L4_argument_unpacking_done:;
1679 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":187
1682 * self.lw = lw # <<<<<<<<<<<<<<
1686 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_lw); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1687 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lw = __pyx_t_1;
1689 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":188
1692 * self.wip = wip # <<<<<<<<<<<<<<
1694 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1696 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_wip); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1697 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->wip = __pyx_t_1;
1699 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":189
1702 * self.uw = uw # <<<<<<<<<<<<<<
1703 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1706 __pyx_t_1 = __pyx_PyFloat_AsDouble(__pyx_v_uw); if (unlikely((__pyx_t_1 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1707 ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->uw = __pyx_t_1;
1709 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":190
1712 * ngram_model_apply_weights(self.lm, lw, wip, uw) # <<<<<<<<<<<<<<
1714 * def get_size(self):
1716 __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_lw); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1717 __pyx_t_3 = __pyx_PyFloat_AsDouble(__pyx_v_wip); if (unlikely((__pyx_t_3 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1718 __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_v_uw); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1719 ngram_model_apply_weights(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_2, __pyx_t_3, __pyx_t_4);
1721 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1724 __Pyx_AddTraceback("sphinxbase.NGramModel.apply_weights");
1727 __Pyx_XGIVEREF(__pyx_r);
1728 __Pyx_RefNannyFinishContext();
1732 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":192
1733 * ngram_model_apply_weights(self.lm, lw, wip, uw)
1735 * def get_size(self): # <<<<<<<<<<<<<<
1737 * Get the order of this model (i.e. the 'N' in 'N-gram')
1740 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_get_size(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
1741 static char __pyx_doc_10sphinxbase_10NGramModel_get_size[] = "\n Get the order of this model (i.e. the 'N' in 'N-gram')\n\n @return: Order of this model\n @rtype: int\n ";
1742 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_get_size(PyObject *__pyx_v_self, PyObject *unused) {
1743 PyObject *__pyx_r = NULL;
1744 PyObject *__pyx_t_1 = NULL;
1745 __Pyx_RefNannySetupContext("get_size");
1747 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":199
1750 * return ngram_model_get_size(self.lm) # <<<<<<<<<<<<<<
1752 * def get_counts(self):
1754 __Pyx_XDECREF(__pyx_r);
1755 __pyx_t_1 = PyInt_FromLong(ngram_model_get_size(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1756 __Pyx_GOTREF(__pyx_t_1);
1757 __pyx_r = __pyx_t_1;
1761 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1764 __Pyx_XDECREF(__pyx_t_1);
1765 __Pyx_AddTraceback("sphinxbase.NGramModel.get_size");
1768 __Pyx_XGIVEREF(__pyx_r);
1769 __Pyx_RefNannyFinishContext();
1773 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":201
1774 * return ngram_model_get_size(self.lm)
1776 * def get_counts(self): # <<<<<<<<<<<<<<
1778 * Get the counts of each size of N-gram.
1781 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_get_counts(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
1782 static char __pyx_doc_10sphinxbase_10NGramModel_get_counts[] = "\n Get the counts of each size of N-gram.\n\n @return: Counts of 1, 2, ..., N grams\n @rtype: tuple(int)\n ";
1783 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_get_counts(PyObject *__pyx_v_self, PyObject *unused) {
1784 int *__pyx_v_counts;
1785 PyObject *__pyx_v_i;
1786 PyObject *__pyx_r = NULL;
1787 PyObject *__pyx_t_1 = NULL;
1788 Py_ssize_t __pyx_t_2;
1789 PyObject *__pyx_t_3 = NULL;
1790 PyObject *__pyx_t_4 = NULL;
1791 Py_ssize_t __pyx_t_5;
1793 __Pyx_RefNannySetupContext("get_counts");
1794 __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
1796 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":209
1799 * counts = ngram_model_get_counts(self.lm) # <<<<<<<<<<<<<<
1800 * return tuple([counts[i] for i in range(ngram_model_get_size(self.lm))])
1803 __pyx_v_counts = ngram_model_get_counts(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm);
1805 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":210
1807 * counts = ngram_model_get_counts(self.lm)
1808 * return tuple([counts[i] for i in range(ngram_model_get_size(self.lm))]) # <<<<<<<<<<<<<<
1810 * def unknown_wid(self):
1812 __Pyx_XDECREF(__pyx_r);
1813 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1814 __Pyx_GOTREF(((PyObject *)__pyx_t_1));
1815 __pyx_t_3 = PyInt_FromLong(ngram_model_get_size(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1816 __Pyx_GOTREF(__pyx_t_3);
1817 __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1818 __Pyx_GOTREF(__pyx_t_4);
1819 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
1820 __Pyx_GIVEREF(__pyx_t_3);
1822 __pyx_t_3 = PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1823 __Pyx_GOTREF(__pyx_t_3);
1824 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1825 if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
1826 __pyx_t_2 = 0; __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4);
1828 __pyx_t_2 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1829 __Pyx_GOTREF(__pyx_t_4);
1831 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1833 if (likely(PyList_CheckExact(__pyx_t_4))) {
1834 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_4)) break;
1835 __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
1836 } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
1837 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
1838 __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
1840 __pyx_t_3 = PyIter_Next(__pyx_t_4);
1842 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1845 __Pyx_GOTREF(__pyx_t_3);
1847 __Pyx_DECREF(__pyx_v_i);
1848 __pyx_v_i = __pyx_t_3;
1850 __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1851 __pyx_t_3 = PyInt_FromLong((__pyx_v_counts[__pyx_t_5])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1852 __Pyx_GOTREF(__pyx_t_3);
1853 __pyx_t_6 = PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_3); if (unlikely(__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1854 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1856 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1857 __pyx_t_4 = ((PyObject *)PyList_AsTuple(__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1858 __Pyx_GOTREF(((PyObject *)__pyx_t_4));
1859 __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
1860 __pyx_r = ((PyObject *)__pyx_t_4);
1864 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1867 __Pyx_XDECREF(__pyx_t_1);
1868 __Pyx_XDECREF(__pyx_t_3);
1869 __Pyx_XDECREF(__pyx_t_4);
1870 __Pyx_AddTraceback("sphinxbase.NGramModel.get_counts");
1873 __Pyx_DECREF(__pyx_v_i);
1874 __Pyx_XGIVEREF(__pyx_r);
1875 __Pyx_RefNannyFinishContext();
1879 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":212
1880 * return tuple([counts[i] for i in range(ngram_model_get_size(self.lm))])
1882 * def unknown_wid(self): # <<<<<<<<<<<<<<
1884 * Get the ID for an unknown word.
1887 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_unknown_wid(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
1888 static char __pyx_doc_10sphinxbase_10NGramModel_unknown_wid[] = "\n Get the ID for an unknown word.\n\n In the case of a closed-vocabulary language model this will be -1.\n\n @return: Word ID for the unknown word.\n @rtype: int\n ";
1889 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_unknown_wid(PyObject *__pyx_v_self, PyObject *unused) {
1890 PyObject *__pyx_r = NULL;
1891 PyObject *__pyx_t_1 = NULL;
1892 __Pyx_RefNannySetupContext("unknown_wid");
1894 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":221
1897 * return ngram_unknown_wid(self.lm) # <<<<<<<<<<<<<<
1901 __Pyx_XDECREF(__pyx_r);
1902 __pyx_t_1 = PyInt_FromLong(ngram_unknown_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1903 __Pyx_GOTREF(__pyx_t_1);
1904 __pyx_r = __pyx_t_1;
1908 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1911 __Pyx_XDECREF(__pyx_t_1);
1912 __Pyx_AddTraceback("sphinxbase.NGramModel.unknown_wid");
1915 __Pyx_XGIVEREF(__pyx_r);
1916 __Pyx_RefNannyFinishContext();
1920 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":223
1921 * return ngram_unknown_wid(self.lm)
1923 * def zero(self): # <<<<<<<<<<<<<<
1925 * Get the log-zero value for this language model.
1928 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_zero(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
1929 static char __pyx_doc_10sphinxbase_10NGramModel_zero[] = "\n Get the log-zero value for this language model.\n\n @return: Log value used to represent zero.\n @rtype: float\n ";
1930 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_zero(PyObject *__pyx_v_self, PyObject *unused) {
1931 PyObject *__pyx_r = NULL;
1932 PyObject *__pyx_t_1 = NULL;
1933 __Pyx_RefNannySetupContext("zero");
1935 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":230
1938 * return logmath_log_to_ln(self.lmath, ngram_zero(self.lm)) # <<<<<<<<<<<<<<
1940 * def wid(self, word):
1942 __Pyx_XDECREF(__pyx_r);
1943 __pyx_t_1 = PyFloat_FromDouble(logmath_log_to_ln(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath, ngram_zero(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1944 __Pyx_GOTREF(__pyx_t_1);
1945 __pyx_r = __pyx_t_1;
1949 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1952 __Pyx_XDECREF(__pyx_t_1);
1953 __Pyx_AddTraceback("sphinxbase.NGramModel.zero");
1956 __Pyx_XGIVEREF(__pyx_r);
1957 __Pyx_RefNannyFinishContext();
1961 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":232
1962 * return logmath_log_to_ln(self.lmath, ngram_zero(self.lm))
1964 * def wid(self, word): # <<<<<<<<<<<<<<
1966 * Get the internal ID for a word.
1969 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_wid(PyObject *__pyx_v_self, PyObject *__pyx_v_word); /*proto*/
1970 static char __pyx_doc_10sphinxbase_10NGramModel_wid[] = "\n Get the internal ID for a word.\n \n @param word: Word in question\n @type word: string\n @return: Internal ID for word, or -1 if not present\n @rtype: int\n ";
1971 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_wid(PyObject *__pyx_v_self, PyObject *__pyx_v_word) {
1972 PyObject *__pyx_r = NULL;
1974 PyObject *__pyx_t_2 = NULL;
1975 __Pyx_RefNannySetupContext("wid");
1977 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":241
1980 * return ngram_wid(self.lm, word) # <<<<<<<<<<<<<<
1982 * def word(self, wid):
1984 __Pyx_XDECREF(__pyx_r);
1985 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_word); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1986 __pyx_t_2 = PyInt_FromLong(ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1987 __Pyx_GOTREF(__pyx_t_2);
1988 __pyx_r = __pyx_t_2;
1992 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1995 __Pyx_XDECREF(__pyx_t_2);
1996 __Pyx_AddTraceback("sphinxbase.NGramModel.wid");
1999 __Pyx_XGIVEREF(__pyx_r);
2000 __Pyx_RefNannyFinishContext();
2004 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":243
2005 * return ngram_wid(self.lm, word)
2007 * def word(self, wid): # <<<<<<<<<<<<<<
2009 * Get the string corresponding to an internal word ID.
2012 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_word(PyObject *__pyx_v_self, PyObject *__pyx_v_wid); /*proto*/
2013 static char __pyx_doc_10sphinxbase_10NGramModel_word[] = "\n Get the string corresponding to an internal word ID.\n \n @param word: Word ID in question\n @type word: int\n @return: String for word, or None if not present\n @rtype: string\n ";
2014 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_word(PyObject *__pyx_v_self, PyObject *__pyx_v_wid) {
2015 PyObject *__pyx_r = NULL;
2016 __pyx_t_10sphinxbase_int32 __pyx_t_1;
2017 PyObject *__pyx_t_2 = NULL;
2018 __Pyx_RefNannySetupContext("word");
2020 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":252
2023 * return ngram_word(self.lm, wid) # <<<<<<<<<<<<<<
2025 * # Note that this and prob() are almost exactly the same...
2027 __Pyx_XDECREF(__pyx_r);
2028 __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_wid); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2029 __pyx_t_2 = __Pyx_PyBytes_FromString(ngram_word(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2030 __Pyx_GOTREF(((PyObject *)__pyx_t_2));
2031 __pyx_r = ((PyObject *)__pyx_t_2);
2035 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2038 __Pyx_XDECREF(__pyx_t_2);
2039 __Pyx_AddTraceback("sphinxbase.NGramModel.word");
2042 __Pyx_XGIVEREF(__pyx_r);
2043 __Pyx_RefNannyFinishContext();
2047 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":255
2049 * # Note that this and prob() are almost exactly the same...
2050 * def score(self, word, *args): # <<<<<<<<<<<<<<
2052 * Get the score for an N-Gram.
2055 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_score(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2056 static char __pyx_doc_10sphinxbase_10NGramModel_score[] = "\n Get the score for an N-Gram.\n\n The argument list consists of the history words (as\n null-terminated strings) of the N-Gram, in reverse order.\n Therefore, if you wanted to get the N-Gram score for 'a whole\n joy', you would call::\n\n score, n_used = model.score('joy', 'whole', 'a')\n\n This function returns a tuple, consisting of the score and the\n number of words used in computing it (i.e. the effective size\n of the N-Gram). The score is returned in logarithmic form,\n using base e.\n\n If one of the words is not in the LM's vocabulary, the result\n will depend on whether this is an open or closed vocabulary\n language model. For an open-vocabulary model, unknown words\n are all mapped to the unigram <UNK> which has a non-zero\n probability and also participates in higher-order N-Grams.\n Therefore, you will get a score of some sort in this case.\n\n For a closed-vocabulary model, unknown words are impossible\n and thus have zero probability. Therefore, if C{word} is\n unknown, this function will return a 'zero' log-probability,\n i.e. a large negative number.\n ";
2057 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_score(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2058 PyObject *__pyx_v_word = 0;
2059 PyObject *__pyx_v_args = 0;
2060 __pyx_t_10sphinxbase_int32 __pyx_v_wid;
2061 __pyx_t_10sphinxbase_int32 *__pyx_v_hist;
2062 __pyx_t_10sphinxbase_int32 __pyx_v_n_hist;
2063 __pyx_t_10sphinxbase_int32 __pyx_v_n_used;
2064 __pyx_t_10sphinxbase_int32 __pyx_v_score;
2065 PyObject *__pyx_v_i;
2066 PyObject *__pyx_v_spam;
2067 PyObject *__pyx_r = NULL;
2069 Py_ssize_t __pyx_t_2;
2070 __pyx_t_10sphinxbase_int32 __pyx_t_3;
2072 PyObject *__pyx_t_5 = NULL;
2073 PyObject *__pyx_t_6 = NULL;
2074 PyObject *__pyx_t_7 = NULL;
2075 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__word,0};
2076 __Pyx_RefNannySetupContext("score");
2077 if (PyTuple_GET_SIZE(__pyx_args) > 1) {
2078 __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
2079 if (unlikely(!__pyx_v_args)) return NULL;
2081 __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2083 if (unlikely(__pyx_kwds)) {
2084 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2085 PyObject* values[1] = {0};
2086 switch (PyTuple_GET_SIZE(__pyx_args)) {
2088 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2091 switch (PyTuple_GET_SIZE(__pyx_args)) {
2093 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__word);
2094 if (likely(values[0])) kw_args--;
2095 else goto __pyx_L5_argtuple_error;
2097 if (unlikely(kw_args > 0)) {
2098 const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
2099 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "score") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2101 __pyx_v_word = values[0];
2102 } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
2103 goto __pyx_L5_argtuple_error;
2105 __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2107 goto __pyx_L4_argument_unpacking_done;
2108 __pyx_L5_argtuple_error:;
2109 __Pyx_RaiseArgtupleInvalid("score", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2111 __Pyx_DECREF(__pyx_v_args);
2112 __Pyx_AddTraceback("sphinxbase.NGramModel.score");
2114 __pyx_L4_argument_unpacking_done:;
2115 __Pyx_INCREF((PyObject *)__pyx_v_self);
2116 __Pyx_INCREF(__pyx_v_word);
2117 __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
2118 __pyx_v_spam = Py_None; __Pyx_INCREF(Py_None);
2120 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":288
2123 * wid = ngram_wid(self.lm, word) # <<<<<<<<<<<<<<
2124 * n_hist = len(args)
2125 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2127 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_word); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2128 __pyx_v_wid = ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
2130 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":289
2132 * wid = ngram_wid(self.lm, word)
2133 * n_hist = len(args) # <<<<<<<<<<<<<<
2134 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2135 * for i from 0 <= i < n_hist:
2137 __pyx_t_2 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2138 __pyx_v_n_hist = __pyx_t_2;
2140 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":290
2141 * wid = ngram_wid(self.lm, word)
2142 * n_hist = len(args)
2143 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32)) # <<<<<<<<<<<<<<
2144 * for i from 0 <= i < n_hist:
2147 __pyx_v_hist = ((__pyx_t_10sphinxbase_int32 *)ckd_calloc(__pyx_v_n_hist, (sizeof(__pyx_t_10sphinxbase_int32))));
2149 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":291
2150 * n_hist = len(args)
2151 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2152 * for i from 0 <= i < n_hist: # <<<<<<<<<<<<<<
2154 * hist[i] = ngram_wid(self.lm, spam)
2156 __pyx_t_3 = __pyx_v_n_hist;
2157 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
2158 __pyx_t_5 = PyInt_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2159 __Pyx_GOTREF(__pyx_t_5);
2160 __Pyx_DECREF(__pyx_v_i);
2161 __pyx_v_i = __pyx_t_5;
2164 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":292
2165 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2166 * for i from 0 <= i < n_hist:
2167 * spam = args[i] # <<<<<<<<<<<<<<
2168 * hist[i] = ngram_wid(self.lm, spam)
2169 * score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used)
2171 __pyx_t_5 = PyObject_GetItem(__pyx_v_args, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2172 __Pyx_GOTREF(__pyx_t_5);
2173 __Pyx_DECREF(__pyx_v_spam);
2174 __pyx_v_spam = __pyx_t_5;
2177 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":293
2178 * for i from 0 <= i < n_hist:
2180 * hist[i] = ngram_wid(self.lm, spam) # <<<<<<<<<<<<<<
2181 * score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used)
2184 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_spam); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2185 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2186 (__pyx_v_hist[__pyx_t_2]) = ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
2187 __pyx_t_4 = __Pyx_PyInt_AsLong(__pyx_v_i); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2190 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":291
2191 * n_hist = len(args)
2192 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2193 * for i from 0 <= i < n_hist: # <<<<<<<<<<<<<<
2195 * hist[i] = ngram_wid(self.lm, spam)
2197 __pyx_t_5 = PyInt_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2198 __Pyx_GOTREF(__pyx_t_5);
2199 __Pyx_DECREF(__pyx_v_i);
2200 __pyx_v_i = __pyx_t_5;
2203 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":294
2205 * hist[i] = ngram_wid(self.lm, spam)
2206 * score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used) # <<<<<<<<<<<<<<
2208 * return logmath_log_to_ln(self.lmath, score), n_used
2210 __pyx_v_score = ngram_ng_score(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_v_wid, __pyx_v_hist, __pyx_v_n_hist, (&__pyx_v_n_used));
2212 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":295
2213 * hist[i] = ngram_wid(self.lm, spam)
2214 * score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used)
2215 * ckd_free(hist) # <<<<<<<<<<<<<<
2216 * return logmath_log_to_ln(self.lmath, score), n_used
2219 ckd_free(__pyx_v_hist);
2221 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":296
2222 * score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used)
2224 * return logmath_log_to_ln(self.lmath, score), n_used # <<<<<<<<<<<<<<
2226 * def prob(self, word, *args):
2228 __Pyx_XDECREF(__pyx_r);
2229 __pyx_t_5 = PyFloat_FromDouble(logmath_log_to_ln(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath, __pyx_v_score)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2230 __Pyx_GOTREF(__pyx_t_5);
2231 __pyx_t_6 = PyInt_FromLong(__pyx_v_n_used); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2232 __Pyx_GOTREF(__pyx_t_6);
2233 __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2234 __Pyx_GOTREF(__pyx_t_7);
2235 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
2236 __Pyx_GIVEREF(__pyx_t_5);
2237 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
2238 __Pyx_GIVEREF(__pyx_t_6);
2241 __pyx_r = __pyx_t_7;
2245 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2248 __Pyx_XDECREF(__pyx_t_5);
2249 __Pyx_XDECREF(__pyx_t_6);
2250 __Pyx_XDECREF(__pyx_t_7);
2251 __Pyx_AddTraceback("sphinxbase.NGramModel.score");
2254 __Pyx_DECREF(__pyx_v_args);
2255 __Pyx_DECREF(__pyx_v_i);
2256 __Pyx_DECREF(__pyx_v_spam);
2257 __Pyx_DECREF((PyObject *)__pyx_v_self);
2258 __Pyx_DECREF(__pyx_v_word);
2259 __Pyx_XGIVEREF(__pyx_r);
2260 __Pyx_RefNannyFinishContext();
2264 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":298
2265 * return logmath_log_to_ln(self.lmath, score), n_used
2267 * def prob(self, word, *args): # <<<<<<<<<<<<<<
2269 * Get the log-probability for an N-Gram.
2272 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_prob(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2273 static char __pyx_doc_10sphinxbase_10NGramModel_prob[] = "\n Get the log-probability for an N-Gram.\n\n This works effectively the same way as L{score}, except that\n any weights (language weight, insertion penalty) applied to\n the language model are ignored and the 'raw' probability value\n is returned.\n ";
2274 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_prob(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2275 PyObject *__pyx_v_word = 0;
2276 PyObject *__pyx_v_args = 0;
2277 __pyx_t_10sphinxbase_int32 __pyx_v_wid;
2278 __pyx_t_10sphinxbase_int32 *__pyx_v_hist;
2279 __pyx_t_10sphinxbase_int32 __pyx_v_n_hist;
2280 __pyx_t_10sphinxbase_int32 __pyx_v_n_used;
2281 __pyx_t_10sphinxbase_int32 __pyx_v_score;
2282 PyObject *__pyx_v_i;
2283 PyObject *__pyx_v_spam;
2284 PyObject *__pyx_r = NULL;
2286 Py_ssize_t __pyx_t_2;
2287 __pyx_t_10sphinxbase_int32 __pyx_t_3;
2289 PyObject *__pyx_t_5 = NULL;
2290 PyObject *__pyx_t_6 = NULL;
2291 PyObject *__pyx_t_7 = NULL;
2292 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__word,0};
2293 __Pyx_RefNannySetupContext("prob");
2294 if (PyTuple_GET_SIZE(__pyx_args) > 1) {
2295 __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
2296 if (unlikely(!__pyx_v_args)) return NULL;
2298 __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2300 if (unlikely(__pyx_kwds)) {
2301 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2302 PyObject* values[1] = {0};
2303 switch (PyTuple_GET_SIZE(__pyx_args)) {
2305 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2308 switch (PyTuple_GET_SIZE(__pyx_args)) {
2310 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__word);
2311 if (likely(values[0])) kw_args--;
2312 else goto __pyx_L5_argtuple_error;
2314 if (unlikely(kw_args > 0)) {
2315 const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
2316 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "prob") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2318 __pyx_v_word = values[0];
2319 } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
2320 goto __pyx_L5_argtuple_error;
2322 __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2324 goto __pyx_L4_argument_unpacking_done;
2325 __pyx_L5_argtuple_error:;
2326 __Pyx_RaiseArgtupleInvalid("prob", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2328 __Pyx_DECREF(__pyx_v_args);
2329 __Pyx_AddTraceback("sphinxbase.NGramModel.prob");
2331 __pyx_L4_argument_unpacking_done:;
2332 __Pyx_INCREF((PyObject *)__pyx_v_self);
2333 __Pyx_INCREF(__pyx_v_word);
2334 __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
2335 __pyx_v_spam = Py_None; __Pyx_INCREF(Py_None);
2337 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":312
2340 * wid = ngram_wid(self.lm, word) # <<<<<<<<<<<<<<
2341 * n_hist = len(args)
2342 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2344 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_word); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2345 __pyx_v_wid = ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
2347 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":313
2349 * wid = ngram_wid(self.lm, word)
2350 * n_hist = len(args) # <<<<<<<<<<<<<<
2351 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2352 * for i from 0 <= i < n_hist:
2354 __pyx_t_2 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2355 __pyx_v_n_hist = __pyx_t_2;
2357 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":314
2358 * wid = ngram_wid(self.lm, word)
2359 * n_hist = len(args)
2360 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32)) # <<<<<<<<<<<<<<
2361 * for i from 0 <= i < n_hist:
2364 __pyx_v_hist = ((__pyx_t_10sphinxbase_int32 *)ckd_calloc(__pyx_v_n_hist, (sizeof(__pyx_t_10sphinxbase_int32))));
2366 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":315
2367 * n_hist = len(args)
2368 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2369 * for i from 0 <= i < n_hist: # <<<<<<<<<<<<<<
2371 * hist[i] = ngram_wid(self.lm, spam)
2373 __pyx_t_3 = __pyx_v_n_hist;
2374 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
2375 __pyx_t_5 = PyInt_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2376 __Pyx_GOTREF(__pyx_t_5);
2377 __Pyx_DECREF(__pyx_v_i);
2378 __pyx_v_i = __pyx_t_5;
2381 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":316
2382 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2383 * for i from 0 <= i < n_hist:
2384 * spam = args[i] # <<<<<<<<<<<<<<
2385 * hist[i] = ngram_wid(self.lm, spam)
2386 * score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used)
2388 __pyx_t_5 = PyObject_GetItem(__pyx_v_args, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2389 __Pyx_GOTREF(__pyx_t_5);
2390 __Pyx_DECREF(__pyx_v_spam);
2391 __pyx_v_spam = __pyx_t_5;
2394 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":317
2395 * for i from 0 <= i < n_hist:
2397 * hist[i] = ngram_wid(self.lm, spam) # <<<<<<<<<<<<<<
2398 * score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used)
2401 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_spam); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2402 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2403 (__pyx_v_hist[__pyx_t_2]) = ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
2404 __pyx_t_4 = __Pyx_PyInt_AsLong(__pyx_v_i); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2407 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":315
2408 * n_hist = len(args)
2409 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2410 * for i from 0 <= i < n_hist: # <<<<<<<<<<<<<<
2412 * hist[i] = ngram_wid(self.lm, spam)
2414 __pyx_t_5 = PyInt_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2415 __Pyx_GOTREF(__pyx_t_5);
2416 __Pyx_DECREF(__pyx_v_i);
2417 __pyx_v_i = __pyx_t_5;
2420 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":318
2422 * hist[i] = ngram_wid(self.lm, spam)
2423 * score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used) # <<<<<<<<<<<<<<
2425 * return logmath_log_to_ln(self.lmath, score), n_used
2427 __pyx_v_score = ngram_ng_prob(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_v_wid, __pyx_v_hist, __pyx_v_n_hist, (&__pyx_v_n_used));
2429 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":319
2430 * hist[i] = ngram_wid(self.lm, spam)
2431 * score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used)
2432 * ckd_free(hist) # <<<<<<<<<<<<<<
2433 * return logmath_log_to_ln(self.lmath, score), n_used
2436 ckd_free(__pyx_v_hist);
2438 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":320
2439 * score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used)
2441 * return logmath_log_to_ln(self.lmath, score), n_used # <<<<<<<<<<<<<<
2443 * def mgrams(self, m):
2445 __Pyx_XDECREF(__pyx_r);
2446 __pyx_t_5 = PyFloat_FromDouble(logmath_log_to_ln(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath, __pyx_v_score)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2447 __Pyx_GOTREF(__pyx_t_5);
2448 __pyx_t_6 = PyInt_FromLong(__pyx_v_n_used); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2449 __Pyx_GOTREF(__pyx_t_6);
2450 __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2451 __Pyx_GOTREF(__pyx_t_7);
2452 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
2453 __Pyx_GIVEREF(__pyx_t_5);
2454 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
2455 __Pyx_GIVEREF(__pyx_t_6);
2458 __pyx_r = __pyx_t_7;
2462 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2465 __Pyx_XDECREF(__pyx_t_5);
2466 __Pyx_XDECREF(__pyx_t_6);
2467 __Pyx_XDECREF(__pyx_t_7);
2468 __Pyx_AddTraceback("sphinxbase.NGramModel.prob");
2471 __Pyx_DECREF(__pyx_v_args);
2472 __Pyx_DECREF(__pyx_v_i);
2473 __Pyx_DECREF(__pyx_v_spam);
2474 __Pyx_DECREF((PyObject *)__pyx_v_self);
2475 __Pyx_DECREF(__pyx_v_word);
2476 __Pyx_XGIVEREF(__pyx_r);
2477 __Pyx_RefNannyFinishContext();
2481 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":322
2482 * return logmath_log_to_ln(self.lmath, score), n_used
2484 * def mgrams(self, m): # <<<<<<<<<<<<<<
2486 * Return an iterator over each N-gram of order m+1.
2489 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_mgrams(PyObject *__pyx_v_self, PyObject *__pyx_v_m); /*proto*/
2490 static char __pyx_doc_10sphinxbase_10NGramModel_mgrams[] = "\n Return an iterator over each N-gram of order m+1.\n\n This allows Pythonic iteration over the parameters of an\n N-Gram model.\n\n @param m: Order of requested N-grams minus one\n @type m: int\n @return: Iterator over M+1-grams\n @rtype: NGramIter\n ";
2491 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_mgrams(PyObject *__pyx_v_self, PyObject *__pyx_v_m) {
2492 struct __pyx_obj_10sphinxbase_NGramIter *__pyx_v_itor;
2493 PyObject *__pyx_r = NULL;
2494 PyObject *__pyx_t_1 = NULL;
2495 PyObject *__pyx_t_2 = NULL;
2497 __Pyx_RefNannySetupContext("mgrams");
2498 __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)Py_None); __Pyx_INCREF(Py_None);
2500 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":335
2502 * cdef NGramIter itor
2503 * itor = NGramIter(self, m) # <<<<<<<<<<<<<<
2504 * itor.itor = ngram_model_mgrams(self.lm, m)
2507 __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2508 __Pyx_GOTREF(__pyx_t_1);
2509 __Pyx_INCREF(__pyx_v_self);
2510 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
2511 __Pyx_GIVEREF(__pyx_v_self);
2512 __Pyx_INCREF(__pyx_v_m);
2513 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_m);
2514 __Pyx_GIVEREF(__pyx_v_m);
2515 __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10sphinxbase_NGramIter)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2516 __Pyx_GOTREF(__pyx_t_2);
2517 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2518 __Pyx_DECREF(((PyObject *)__pyx_v_itor));
2519 __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_t_2);
2522 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":336
2523 * cdef NGramIter itor
2524 * itor = NGramIter(self, m)
2525 * itor.itor = ngram_model_mgrams(self.lm, m) # <<<<<<<<<<<<<<
2529 __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_v_m); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2530 __pyx_v_itor->itor = ngram_model_mgrams(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_3);
2532 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":337
2533 * itor = NGramIter(self, m)
2534 * itor.itor = ngram_model_mgrams(self.lm, m)
2535 * return itor # <<<<<<<<<<<<<<
2537 * def ngram(self, word, *args):
2539 __Pyx_XDECREF(__pyx_r);
2540 __Pyx_INCREF(((PyObject *)__pyx_v_itor));
2541 __pyx_r = ((PyObject *)__pyx_v_itor);
2544 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2547 __Pyx_XDECREF(__pyx_t_1);
2548 __Pyx_XDECREF(__pyx_t_2);
2549 __Pyx_AddTraceback("sphinxbase.NGramModel.mgrams");
2552 __Pyx_DECREF((PyObject *)__pyx_v_itor);
2553 __Pyx_XGIVEREF(__pyx_r);
2554 __Pyx_RefNannyFinishContext();
2558 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":339
2561 * def ngram(self, word, *args): # <<<<<<<<<<<<<<
2563 * Return an N-Gram iterator pointing to a given N-gram.
2566 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_ngram(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2567 static char __pyx_doc_10sphinxbase_10NGramModel_ngram[] = "\n Return an N-Gram iterator pointing to a given N-gram.\n\n This allows you to iterate over its successors among other\n things.\n\n @param word: Head word of requested N-gram.\n @type word: str\n @param args: History words of requested N-gram\n @type args: str\n @return: Iterator pointing to N-gram.\n ";
2568 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_ngram(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2569 PyObject *__pyx_v_word = 0;
2570 PyObject *__pyx_v_args = 0;
2571 struct __pyx_obj_10sphinxbase_NGramIter *__pyx_v_itor;
2572 __pyx_t_10sphinxbase_int32 __pyx_v_wid;
2573 __pyx_t_10sphinxbase_int32 *__pyx_v_hist;
2574 __pyx_t_10sphinxbase_int32 __pyx_v_n_hist;
2575 PyObject *__pyx_v_i;
2576 PyObject *__pyx_v_spam;
2577 PyObject *__pyx_r = NULL;
2579 Py_ssize_t __pyx_t_2;
2580 __pyx_t_10sphinxbase_int32 __pyx_t_3;
2582 PyObject *__pyx_t_5 = NULL;
2583 PyObject *__pyx_t_6 = NULL;
2584 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__word,0};
2585 __Pyx_RefNannySetupContext("ngram");
2586 if (PyTuple_GET_SIZE(__pyx_args) > 1) {
2587 __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args)); __Pyx_GOTREF(__pyx_v_args);
2588 if (unlikely(!__pyx_v_args)) return NULL;
2590 __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2592 if (unlikely(__pyx_kwds)) {
2593 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2594 PyObject* values[1] = {0};
2595 switch (PyTuple_GET_SIZE(__pyx_args)) {
2597 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2600 switch (PyTuple_GET_SIZE(__pyx_args)) {
2602 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__word);
2603 if (likely(values[0])) kw_args--;
2604 else goto __pyx_L5_argtuple_error;
2606 if (unlikely(kw_args > 0)) {
2607 const Py_ssize_t used_pos_args = (PyTuple_GET_SIZE(__pyx_args) < 1) ? PyTuple_GET_SIZE(__pyx_args) : 1;
2608 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "ngram") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2610 __pyx_v_word = values[0];
2611 } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
2612 goto __pyx_L5_argtuple_error;
2614 __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2616 goto __pyx_L4_argument_unpacking_done;
2617 __pyx_L5_argtuple_error:;
2618 __Pyx_RaiseArgtupleInvalid("ngram", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2620 __Pyx_DECREF(__pyx_v_args);
2621 __Pyx_AddTraceback("sphinxbase.NGramModel.ngram");
2623 __pyx_L4_argument_unpacking_done:;
2624 __Pyx_INCREF((PyObject *)__pyx_v_self);
2625 __Pyx_INCREF(__pyx_v_word);
2626 __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)Py_None); __Pyx_INCREF(Py_None);
2627 __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
2628 __pyx_v_spam = Py_None; __Pyx_INCREF(Py_None);
2630 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":356
2633 * wid = ngram_wid(self.lm, word) # <<<<<<<<<<<<<<
2634 * n_hist = len(args)
2635 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2637 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_word); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2638 __pyx_v_wid = ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
2640 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":357
2642 * wid = ngram_wid(self.lm, word)
2643 * n_hist = len(args) # <<<<<<<<<<<<<<
2644 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2645 * for i from 0 <= i < n_hist:
2647 __pyx_t_2 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2648 __pyx_v_n_hist = __pyx_t_2;
2650 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":358
2651 * wid = ngram_wid(self.lm, word)
2652 * n_hist = len(args)
2653 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32)) # <<<<<<<<<<<<<<
2654 * for i from 0 <= i < n_hist:
2657 __pyx_v_hist = ((__pyx_t_10sphinxbase_int32 *)ckd_calloc(__pyx_v_n_hist, (sizeof(__pyx_t_10sphinxbase_int32))));
2659 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":359
2660 * n_hist = len(args)
2661 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2662 * for i from 0 <= i < n_hist: # <<<<<<<<<<<<<<
2664 * hist[i] = ngram_wid(self.lm, spam)
2666 __pyx_t_3 = __pyx_v_n_hist;
2667 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4++) {
2668 __pyx_t_5 = PyInt_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2669 __Pyx_GOTREF(__pyx_t_5);
2670 __Pyx_DECREF(__pyx_v_i);
2671 __pyx_v_i = __pyx_t_5;
2674 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":360
2675 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2676 * for i from 0 <= i < n_hist:
2677 * spam = args[i] # <<<<<<<<<<<<<<
2678 * hist[i] = ngram_wid(self.lm, spam)
2679 * itor = NGramIter(self, n_hist)
2681 __pyx_t_5 = PyObject_GetItem(__pyx_v_args, __pyx_v_i); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2682 __Pyx_GOTREF(__pyx_t_5);
2683 __Pyx_DECREF(__pyx_v_spam);
2684 __pyx_v_spam = __pyx_t_5;
2687 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":361
2688 * for i from 0 <= i < n_hist:
2690 * hist[i] = ngram_wid(self.lm, spam) # <<<<<<<<<<<<<<
2691 * itor = NGramIter(self, n_hist)
2692 * # We do set_iter here, because we're returning something the
2694 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_spam); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2695 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2696 (__pyx_v_hist[__pyx_t_2]) = ngram_wid(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
2697 __pyx_t_4 = __Pyx_PyInt_AsLong(__pyx_v_i); if (unlikely((__pyx_t_4 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2700 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":359
2701 * n_hist = len(args)
2702 * hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2703 * for i from 0 <= i < n_hist: # <<<<<<<<<<<<<<
2705 * hist[i] = ngram_wid(self.lm, spam)
2707 __pyx_t_5 = PyInt_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2708 __Pyx_GOTREF(__pyx_t_5);
2709 __Pyx_DECREF(__pyx_v_i);
2710 __pyx_v_i = __pyx_t_5;
2713 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":362
2715 * hist[i] = ngram_wid(self.lm, spam)
2716 * itor = NGramIter(self, n_hist) # <<<<<<<<<<<<<<
2717 * # We do set_iter here, because we're returning something the
2718 * # user is immediately going to do stuff with.
2720 __pyx_t_5 = PyInt_FromLong(__pyx_v_n_hist); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2721 __Pyx_GOTREF(__pyx_t_5);
2722 __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2723 __Pyx_GOTREF(__pyx_t_6);
2724 __Pyx_INCREF(__pyx_v_self);
2725 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
2726 __Pyx_GIVEREF(__pyx_v_self);
2727 PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
2728 __Pyx_GIVEREF(__pyx_t_5);
2730 __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10sphinxbase_NGramIter)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2731 __Pyx_GOTREF(__pyx_t_5);
2732 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2733 __Pyx_DECREF(((PyObject *)__pyx_v_itor));
2734 __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_t_5);
2737 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":365
2738 * # We do set_iter here, because we're returning something the
2739 * # user is immediately going to do stuff with.
2740 * itor.set_iter(ngram_ng_iter(self.lm, wid, hist, n_hist)) # <<<<<<<<<<<<<<
2744 __pyx_t_5 = ((struct __pyx_vtabstruct_10sphinxbase_NGramIter *)__pyx_v_itor->__pyx_vtab)->set_iter(__pyx_v_itor, ngram_ng_iter(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_v_wid, __pyx_v_hist, __pyx_v_n_hist)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2745 __Pyx_GOTREF(__pyx_t_5);
2746 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2748 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":366
2749 * # user is immediately going to do stuff with.
2750 * itor.set_iter(ngram_ng_iter(self.lm, wid, hist, n_hist))
2751 * ckd_free(hist) # <<<<<<<<<<<<<<
2755 ckd_free(__pyx_v_hist);
2757 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":367
2758 * itor.set_iter(ngram_ng_iter(self.lm, wid, hist, n_hist))
2760 * return itor # <<<<<<<<<<<<<<
2762 * def add_word(self, word, weight=1.0):
2764 __Pyx_XDECREF(__pyx_r);
2765 __Pyx_INCREF(((PyObject *)__pyx_v_itor));
2766 __pyx_r = ((PyObject *)__pyx_v_itor);
2769 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2772 __Pyx_XDECREF(__pyx_t_5);
2773 __Pyx_XDECREF(__pyx_t_6);
2774 __Pyx_AddTraceback("sphinxbase.NGramModel.ngram");
2777 __Pyx_DECREF(__pyx_v_args);
2778 __Pyx_DECREF((PyObject *)__pyx_v_itor);
2779 __Pyx_DECREF(__pyx_v_i);
2780 __Pyx_DECREF(__pyx_v_spam);
2781 __Pyx_DECREF((PyObject *)__pyx_v_self);
2782 __Pyx_DECREF(__pyx_v_word);
2783 __Pyx_XGIVEREF(__pyx_r);
2784 __Pyx_RefNannyFinishContext();
2788 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":369
2791 * def add_word(self, word, weight=1.0): # <<<<<<<<<<<<<<
2792 * return ngram_model_add_word(self.lm, word, weight)
2796 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_add_word(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2797 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_add_word(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2798 PyObject *__pyx_v_word = 0;
2799 PyObject *__pyx_v_weight = 0;
2800 PyObject *__pyx_r = NULL;
2802 __pyx_t_10sphinxbase_float32 __pyx_t_2;
2803 PyObject *__pyx_t_3 = NULL;
2804 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__word,&__pyx_n_s__weight,0};
2805 __Pyx_RefNannySetupContext("add_word");
2806 if (unlikely(__pyx_kwds)) {
2807 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2808 PyObject* values[2] = {0,0};
2809 values[1] = __pyx_k_8;
2810 switch (PyTuple_GET_SIZE(__pyx_args)) {
2811 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2812 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2814 default: goto __pyx_L5_argtuple_error;
2816 switch (PyTuple_GET_SIZE(__pyx_args)) {
2818 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__word);
2819 if (likely(values[0])) kw_args--;
2820 else goto __pyx_L5_argtuple_error;
2823 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weight);
2824 if (unlikely(value)) { values[1] = value; kw_args--; }
2827 if (unlikely(kw_args > 0)) {
2828 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "add_word") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2830 __pyx_v_word = values[0];
2831 __pyx_v_weight = values[1];
2833 __pyx_v_weight = __pyx_k_8;
2834 switch (PyTuple_GET_SIZE(__pyx_args)) {
2835 case 2: __pyx_v_weight = PyTuple_GET_ITEM(__pyx_args, 1);
2836 case 1: __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2838 default: goto __pyx_L5_argtuple_error;
2841 goto __pyx_L4_argument_unpacking_done;
2842 __pyx_L5_argtuple_error:;
2843 __Pyx_RaiseArgtupleInvalid("add_word", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2845 __Pyx_AddTraceback("sphinxbase.NGramModel.add_word");
2847 __pyx_L4_argument_unpacking_done:;
2849 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":370
2851 * def add_word(self, word, weight=1.0):
2852 * return ngram_model_add_word(self.lm, word, weight) # <<<<<<<<<<<<<<
2854 * def recode(self, frum, too):
2856 __Pyx_XDECREF(__pyx_r);
2857 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_word); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2858 __pyx_t_2 = __pyx_PyFloat_AsDouble(__pyx_v_weight); if (unlikely((__pyx_t_2 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2859 __pyx_t_3 = PyInt_FromLong(ngram_model_add_word(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1, __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2860 __Pyx_GOTREF(__pyx_t_3);
2861 __pyx_r = __pyx_t_3;
2865 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2868 __Pyx_XDECREF(__pyx_t_3);
2869 __Pyx_AddTraceback("sphinxbase.NGramModel.add_word");
2872 __Pyx_XGIVEREF(__pyx_r);
2873 __Pyx_RefNannyFinishContext();
2877 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":372
2878 * return ngram_model_add_word(self.lm, word, weight)
2880 * def recode(self, frum, too): # <<<<<<<<<<<<<<
2882 * rv = ngram_model_recode(self.lm, frum, too)
2885 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_recode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2886 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_recode(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2887 PyObject *__pyx_v_frum = 0;
2888 PyObject *__pyx_v_too = 0;
2890 PyObject *__pyx_r = NULL;
2894 PyObject *__pyx_t_4 = NULL;
2895 PyObject *__pyx_t_5 = NULL;
2896 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__frum,&__pyx_n_s__too,0};
2897 __Pyx_RefNannySetupContext("recode");
2898 if (unlikely(__pyx_kwds)) {
2899 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2900 PyObject* values[2] = {0,0};
2901 switch (PyTuple_GET_SIZE(__pyx_args)) {
2902 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2903 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2905 default: goto __pyx_L5_argtuple_error;
2907 switch (PyTuple_GET_SIZE(__pyx_args)) {
2909 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__frum);
2910 if (likely(values[0])) kw_args--;
2911 else goto __pyx_L5_argtuple_error;
2913 values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__too);
2914 if (likely(values[1])) kw_args--;
2916 __Pyx_RaiseArgtupleInvalid("recode", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2919 if (unlikely(kw_args > 0)) {
2920 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "recode") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2922 __pyx_v_frum = values[0];
2923 __pyx_v_too = values[1];
2924 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2925 goto __pyx_L5_argtuple_error;
2927 __pyx_v_frum = PyTuple_GET_ITEM(__pyx_args, 0);
2928 __pyx_v_too = PyTuple_GET_ITEM(__pyx_args, 1);
2930 goto __pyx_L4_argument_unpacking_done;
2931 __pyx_L5_argtuple_error:;
2932 __Pyx_RaiseArgtupleInvalid("recode", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2934 __Pyx_AddTraceback("sphinxbase.NGramModel.recode");
2936 __pyx_L4_argument_unpacking_done:;
2937 __Pyx_INCREF((PyObject *)__pyx_v_self);
2938 __Pyx_INCREF(__pyx_v_frum);
2939 __Pyx_INCREF(__pyx_v_too);
2941 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":374
2942 * def recode(self, frum, too):
2944 * rv = ngram_model_recode(self.lm, frum, too) # <<<<<<<<<<<<<<
2946 * raise ValueError, "Recode from %s to %s failed" % (frum, too)
2948 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_frum); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2949 __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_too); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2950 __pyx_v_rv = ngram_model_recode(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1, __pyx_t_2);
2952 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":375
2954 * rv = ngram_model_recode(self.lm, frum, too)
2955 * if rv == -1: # <<<<<<<<<<<<<<
2956 * raise ValueError, "Recode from %s to %s failed" % (frum, too)
2959 __pyx_t_3 = (__pyx_v_rv == -1);
2962 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":376
2963 * rv = ngram_model_recode(self.lm, frum, too)
2965 * raise ValueError, "Recode from %s to %s failed" % (frum, too) # <<<<<<<<<<<<<<
2967 * def casefold(self, kase):
2969 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2970 __Pyx_GOTREF(__pyx_t_4);
2971 __Pyx_INCREF(__pyx_v_frum);
2972 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_frum);
2973 __Pyx_GIVEREF(__pyx_v_frum);
2974 __Pyx_INCREF(__pyx_v_too);
2975 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_too);
2976 __Pyx_GIVEREF(__pyx_v_too);
2977 __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2978 __Pyx_GOTREF(__pyx_t_5);
2979 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2980 __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_5, 0);
2981 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2982 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2987 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2990 __Pyx_XDECREF(__pyx_t_4);
2991 __Pyx_XDECREF(__pyx_t_5);
2992 __Pyx_AddTraceback("sphinxbase.NGramModel.recode");
2995 __Pyx_DECREF((PyObject *)__pyx_v_self);
2996 __Pyx_DECREF(__pyx_v_frum);
2997 __Pyx_DECREF(__pyx_v_too);
2998 __Pyx_XGIVEREF(__pyx_r);
2999 __Pyx_RefNannyFinishContext();
3003 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":378
3004 * raise ValueError, "Recode from %s to %s failed" % (frum, too)
3006 * def casefold(self, kase): # <<<<<<<<<<<<<<
3008 * rv = ngram_model_casefold(self.lm, kase)
3011 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_casefold(PyObject *__pyx_v_self, PyObject *__pyx_v_kase); /*proto*/
3012 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_casefold(PyObject *__pyx_v_self, PyObject *__pyx_v_kase) {
3014 PyObject *__pyx_r = NULL;
3015 ngram_case_t __pyx_t_1;
3017 __Pyx_RefNannySetupContext("casefold");
3018 __Pyx_INCREF((PyObject *)__pyx_v_self);
3019 __Pyx_INCREF(__pyx_v_kase);
3021 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":380
3022 * def casefold(self, kase):
3024 * rv = ngram_model_casefold(self.lm, kase) # <<<<<<<<<<<<<<
3026 * raise ValueError, "Casefolding failed"
3028 __pyx_t_1 = ((ngram_case_t)PyInt_AsLong(__pyx_v_kase)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3029 __pyx_v_rv = ngram_model_casefold(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1);
3031 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":381
3033 * rv = ngram_model_casefold(self.lm, kase)
3034 * if rv == -1: # <<<<<<<<<<<<<<
3035 * raise ValueError, "Casefolding failed"
3038 __pyx_t_2 = (__pyx_v_rv == -1);
3041 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":382
3042 * rv = ngram_model_casefold(self.lm, kase)
3044 * raise ValueError, "Casefolding failed" # <<<<<<<<<<<<<<
3046 * def write(self, file_name, format=NGRAM_AUTO):
3048 __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_10), 0);
3049 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3054 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3057 __Pyx_AddTraceback("sphinxbase.NGramModel.casefold");
3060 __Pyx_DECREF((PyObject *)__pyx_v_self);
3061 __Pyx_DECREF(__pyx_v_kase);
3062 __Pyx_XGIVEREF(__pyx_r);
3063 __Pyx_RefNannyFinishContext();
3067 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":384
3068 * raise ValueError, "Casefolding failed"
3070 * def write(self, file_name, format=NGRAM_AUTO): # <<<<<<<<<<<<<<
3072 * rv = ngram_model_write(self.lm, file_name, format)
3075 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3076 static PyObject *__pyx_pf_10sphinxbase_10NGramModel_write(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3077 PyObject *__pyx_v_file_name = 0;
3078 PyObject *__pyx_v_format = 0;
3080 PyObject *__pyx_r = NULL;
3082 ngram_file_type_t __pyx_t_2;
3084 PyObject *__pyx_t_4 = NULL;
3085 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__file_name,&__pyx_n_s__format,0};
3086 __Pyx_RefNannySetupContext("write");
3087 if (unlikely(__pyx_kwds)) {
3088 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3089 PyObject* values[2] = {0,0};
3090 values[1] = __pyx_k_11;
3091 switch (PyTuple_GET_SIZE(__pyx_args)) {
3092 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3093 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3095 default: goto __pyx_L5_argtuple_error;
3097 switch (PyTuple_GET_SIZE(__pyx_args)) {
3099 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__file_name);
3100 if (likely(values[0])) kw_args--;
3101 else goto __pyx_L5_argtuple_error;
3104 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
3105 if (unlikely(value)) { values[1] = value; kw_args--; }
3108 if (unlikely(kw_args > 0)) {
3109 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "write") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3111 __pyx_v_file_name = values[0];
3112 __pyx_v_format = values[1];
3114 __pyx_v_format = __pyx_k_11;
3115 switch (PyTuple_GET_SIZE(__pyx_args)) {
3116 case 2: __pyx_v_format = PyTuple_GET_ITEM(__pyx_args, 1);
3117 case 1: __pyx_v_file_name = PyTuple_GET_ITEM(__pyx_args, 0);
3119 default: goto __pyx_L5_argtuple_error;
3122 goto __pyx_L4_argument_unpacking_done;
3123 __pyx_L5_argtuple_error:;
3124 __Pyx_RaiseArgtupleInvalid("write", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3126 __Pyx_AddTraceback("sphinxbase.NGramModel.write");
3128 __pyx_L4_argument_unpacking_done:;
3129 __Pyx_INCREF((PyObject *)__pyx_v_self);
3130 __Pyx_INCREF(__pyx_v_file_name);
3131 __Pyx_INCREF(__pyx_v_format);
3133 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":386
3134 * def write(self, file_name, format=NGRAM_AUTO):
3136 * rv = ngram_model_write(self.lm, file_name, format) # <<<<<<<<<<<<<<
3138 * raise ValueError, "Write %s to file failed" % file_name
3140 __pyx_t_1 = __Pyx_PyBytes_AsString(__pyx_v_file_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3141 __pyx_t_2 = ((ngram_file_type_t)PyInt_AsLong(__pyx_v_format)); if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3142 __pyx_v_rv = ngram_model_write(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm, __pyx_t_1, __pyx_t_2);
3144 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":387
3146 * rv = ngram_model_write(self.lm, file_name, format)
3147 * if rv == -1: # <<<<<<<<<<<<<<
3148 * raise ValueError, "Write %s to file failed" % file_name
3151 __pyx_t_3 = (__pyx_v_rv == -1);
3154 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":388
3155 * rv = ngram_model_write(self.lm, file_name, format)
3157 * raise ValueError, "Write %s to file failed" % file_name # <<<<<<<<<<<<<<
3159 * cdef class NGramIter:
3161 __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_v_file_name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3162 __Pyx_GOTREF(__pyx_t_4);
3163 __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_4, 0);
3164 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3165 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3170 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3173 __Pyx_XDECREF(__pyx_t_4);
3174 __Pyx_AddTraceback("sphinxbase.NGramModel.write");
3177 __Pyx_DECREF((PyObject *)__pyx_v_self);
3178 __Pyx_DECREF(__pyx_v_file_name);
3179 __Pyx_DECREF(__pyx_v_format);
3180 __Pyx_XGIVEREF(__pyx_r);
3181 __Pyx_RefNannyFinishContext();
3185 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":397
3188 * def __cinit__(self, NGramModel lm, int m): # <<<<<<<<<<<<<<
3193 static int __pyx_pf_10sphinxbase_9NGramIter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3194 static int __pyx_pf_10sphinxbase_9NGramIter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3195 struct __pyx_obj_10sphinxbase_NGramModel *__pyx_v_lm = 0;
3198 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__lm,&__pyx_n_s__m,0};
3199 __Pyx_RefNannySetupContext("__cinit__");
3200 if (unlikely(__pyx_kwds)) {
3201 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3202 PyObject* values[2] = {0,0};
3203 switch (PyTuple_GET_SIZE(__pyx_args)) {
3204 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3205 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3207 default: goto __pyx_L5_argtuple_error;
3209 switch (PyTuple_GET_SIZE(__pyx_args)) {
3211 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lm);
3212 if (likely(values[0])) kw_args--;
3213 else goto __pyx_L5_argtuple_error;
3215 values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__m);
3216 if (likely(values[1])) kw_args--;
3218 __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3221 if (unlikely(kw_args > 0)) {
3222 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3224 __pyx_v_lm = ((struct __pyx_obj_10sphinxbase_NGramModel *)values[0]);
3225 __pyx_v_m = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_m == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3226 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3227 goto __pyx_L5_argtuple_error;
3229 __pyx_v_lm = ((struct __pyx_obj_10sphinxbase_NGramModel *)PyTuple_GET_ITEM(__pyx_args, 0));
3230 __pyx_v_m = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_m == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3232 goto __pyx_L4_argument_unpacking_done;
3233 __pyx_L5_argtuple_error:;
3234 __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3236 __Pyx_AddTraceback("sphinxbase.NGramIter.__cinit__");
3238 __pyx_L4_argument_unpacking_done:;
3239 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_lm), __pyx_ptype_10sphinxbase_NGramModel, 1, "lm", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3241 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":398
3243 * def __cinit__(self, NGramModel lm, int m):
3244 * self.itor = NULL # <<<<<<<<<<<<<<
3248 ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->itor = NULL;
3250 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":399
3251 * def __cinit__(self, NGramModel lm, int m):
3253 * self.lm = lm # <<<<<<<<<<<<<<
3255 * self.first_item = True
3257 __Pyx_INCREF(((PyObject *)__pyx_v_lm));
3258 __Pyx_GIVEREF(((PyObject *)__pyx_v_lm));
3259 __Pyx_GOTREF(((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->lm);
3260 __Pyx_DECREF(((PyObject *)((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->lm));
3261 ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->lm = __pyx_v_lm;
3263 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":400
3266 * self.m = m # <<<<<<<<<<<<<<
3267 * self.first_item = True
3270 ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->m = __pyx_v_m;
3272 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":401
3275 * self.first_item = True # <<<<<<<<<<<<<<
3277 * def __iter__(self):
3279 ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->first_item = 1;
3284 __Pyx_AddTraceback("sphinxbase.NGramIter.__cinit__");
3287 __Pyx_RefNannyFinishContext();
3291 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":403
3292 * self.first_item = True
3294 * def __iter__(self): # <<<<<<<<<<<<<<
3295 * self.first_item = True
3299 static PyObject *__pyx_pf_10sphinxbase_9NGramIter___iter__(PyObject *__pyx_v_self); /*proto*/
3300 static PyObject *__pyx_pf_10sphinxbase_9NGramIter___iter__(PyObject *__pyx_v_self) {
3301 PyObject *__pyx_r = NULL;
3302 __Pyx_RefNannySetupContext("__iter__");
3304 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":404
3306 * def __iter__(self):
3307 * self.first_item = True # <<<<<<<<<<<<<<
3311 ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->first_item = 1;
3313 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":405
3314 * def __iter__(self):
3315 * self.first_item = True
3316 * return self # <<<<<<<<<<<<<<
3318 * cdef set_iter(NGramIter self, ngram_iter_t *itor):
3320 __Pyx_XDECREF(__pyx_r);
3321 __Pyx_INCREF(__pyx_v_self);
3322 __pyx_r = __pyx_v_self;
3325 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3327 __Pyx_XGIVEREF(__pyx_r);
3328 __Pyx_RefNannyFinishContext();
3332 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":407
3335 * cdef set_iter(NGramIter self, ngram_iter_t *itor): # <<<<<<<<<<<<<<
3336 * cdef int32 prob, bowt
3340 static PyObject *__pyx_f_10sphinxbase_9NGramIter_set_iter(struct __pyx_obj_10sphinxbase_NGramIter *__pyx_v_self, ngram_iter_t *__pyx_v_itor) {
3341 __pyx_t_10sphinxbase_int32 __pyx_v_prob;
3342 __pyx_t_10sphinxbase_int32 __pyx_v_bowt;
3343 __pyx_t_10sphinxbase_int32 *__pyx_v_wids;
3344 PyObject *__pyx_v_i;
3345 PyObject *__pyx_r = NULL;
3348 PyObject *__pyx_t_3 = NULL;
3349 Py_ssize_t __pyx_t_4;
3350 PyObject *__pyx_t_5 = NULL;
3351 Py_ssize_t __pyx_t_6;
3352 PyObject *__pyx_t_7 = NULL;
3353 __Pyx_RefNannySetupContext("set_iter");
3354 __Pyx_INCREF((PyObject *)__pyx_v_self);
3355 __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
3357 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":411
3360 * if itor == NULL: # <<<<<<<<<<<<<<
3361 * raise StopIteration
3364 __pyx_t_1 = (__pyx_v_itor == NULL);
3367 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":412
3370 * raise StopIteration # <<<<<<<<<<<<<<
3372 * if self.first_item:
3374 __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
3375 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3380 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":413
3382 * raise StopIteration
3383 * self.itor = itor # <<<<<<<<<<<<<<
3384 * if self.first_item:
3385 * self.first_item = False
3387 __pyx_v_self->itor = __pyx_v_itor;
3389 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":414
3390 * raise StopIteration
3392 * if self.first_item: # <<<<<<<<<<<<<<
3393 * self.first_item = False
3394 * wids = ngram_iter_get(itor, &prob, &bowt)
3396 __pyx_t_2 = __pyx_v_self->first_item;
3399 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":415
3401 * if self.first_item:
3402 * self.first_item = False # <<<<<<<<<<<<<<
3403 * wids = ngram_iter_get(itor, &prob, &bowt)
3404 * self.log_prob = logmath_log_to_ln(self.lm.lmath, prob)
3406 __pyx_v_self->first_item = 0;
3411 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":416
3412 * if self.first_item:
3413 * self.first_item = False
3414 * wids = ngram_iter_get(itor, &prob, &bowt) # <<<<<<<<<<<<<<
3415 * self.log_prob = logmath_log_to_ln(self.lm.lmath, prob)
3416 * self.log_bowt = logmath_log_to_ln(self.lm.lmath, bowt)
3418 __pyx_v_wids = ngram_iter_get(__pyx_v_itor, (&__pyx_v_prob), (&__pyx_v_bowt));
3420 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":417
3421 * self.first_item = False
3422 * wids = ngram_iter_get(itor, &prob, &bowt)
3423 * self.log_prob = logmath_log_to_ln(self.lm.lmath, prob) # <<<<<<<<<<<<<<
3424 * self.log_bowt = logmath_log_to_ln(self.lm.lmath, bowt)
3427 __pyx_v_self->log_prob = logmath_log_to_ln(__pyx_v_self->lm->lmath, __pyx_v_prob);
3429 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":418
3430 * wids = ngram_iter_get(itor, &prob, &bowt)
3431 * self.log_prob = logmath_log_to_ln(self.lm.lmath, prob)
3432 * self.log_bowt = logmath_log_to_ln(self.lm.lmath, bowt) # <<<<<<<<<<<<<<
3434 * for i in range(0, self.m+1):
3436 __pyx_v_self->log_bowt = logmath_log_to_ln(__pyx_v_self->lm->lmath, __pyx_v_bowt);
3438 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":419
3439 * self.log_prob = logmath_log_to_ln(self.lm.lmath, prob)
3440 * self.log_bowt = logmath_log_to_ln(self.lm.lmath, bowt)
3441 * self.words = [] # <<<<<<<<<<<<<<
3442 * for i in range(0, self.m+1):
3443 * self.words.append(ngram_word(self.lm.lm, wids[i]))
3445 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3446 __Pyx_GOTREF(((PyObject *)__pyx_t_3));
3447 __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
3448 __Pyx_GOTREF(__pyx_v_self->words);
3449 __Pyx_DECREF(__pyx_v_self->words);
3450 __pyx_v_self->words = ((PyObject *)__pyx_t_3);
3453 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":420
3454 * self.log_bowt = logmath_log_to_ln(self.lm.lmath, bowt)
3456 * for i in range(0, self.m+1): # <<<<<<<<<<<<<<
3457 * self.words.append(ngram_word(self.lm.lm, wids[i]))
3460 __pyx_t_3 = PyInt_FromLong((__pyx_v_self->m + 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3461 __Pyx_GOTREF(__pyx_t_3);
3462 __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3463 __Pyx_GOTREF(__pyx_t_5);
3464 __Pyx_INCREF(__pyx_int_0);
3465 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_int_0);
3466 __Pyx_GIVEREF(__pyx_int_0);
3467 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
3468 __Pyx_GIVEREF(__pyx_t_3);
3470 __pyx_t_3 = PyObject_Call(__pyx_builtin_range, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3471 __Pyx_GOTREF(__pyx_t_3);
3472 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3473 if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
3474 __pyx_t_4 = 0; __pyx_t_5 = __pyx_t_3; __Pyx_INCREF(__pyx_t_5);
3476 __pyx_t_4 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3477 __Pyx_GOTREF(__pyx_t_5);
3479 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3481 if (likely(PyList_CheckExact(__pyx_t_5))) {
3482 if (__pyx_t_4 >= PyList_GET_SIZE(__pyx_t_5)) break;
3483 __pyx_t_3 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
3484 } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
3485 if (__pyx_t_4 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
3486 __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_4); __Pyx_INCREF(__pyx_t_3); __pyx_t_4++;
3488 __pyx_t_3 = PyIter_Next(__pyx_t_5);
3490 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3493 __Pyx_GOTREF(__pyx_t_3);
3495 __Pyx_DECREF(__pyx_v_i);
3496 __pyx_v_i = __pyx_t_3;
3499 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":421
3501 * for i in range(0, self.m+1):
3502 * self.words.append(ngram_word(self.lm.lm, wids[i])) # <<<<<<<<<<<<<<
3504 * def __next__(self):
3506 __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3507 __pyx_t_3 = __Pyx_PyBytes_FromString(ngram_word(__pyx_v_self->lm->lm, (__pyx_v_wids[__pyx_t_6]))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3508 __Pyx_GOTREF(((PyObject *)__pyx_t_3));
3509 __pyx_t_7 = __Pyx_PyObject_Append(__pyx_v_self->words, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3510 __Pyx_GOTREF(__pyx_t_7);
3511 __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
3512 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3514 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3516 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3519 __Pyx_XDECREF(__pyx_t_3);
3520 __Pyx_XDECREF(__pyx_t_5);
3521 __Pyx_XDECREF(__pyx_t_7);
3522 __Pyx_AddTraceback("sphinxbase.NGramIter.set_iter");
3525 __Pyx_DECREF(__pyx_v_i);
3526 __Pyx_DECREF((PyObject *)__pyx_v_self);
3527 __Pyx_XGIVEREF(__pyx_r);
3528 __Pyx_RefNannyFinishContext();
3532 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":423
3533 * self.words.append(ngram_word(self.lm.lm, wids[i]))
3535 * def __next__(self): # <<<<<<<<<<<<<<
3536 * if self.first_item:
3537 * self.set_iter(self.itor)
3540 static PyObject *__pyx_pf_10sphinxbase_9NGramIter___next__(PyObject *__pyx_v_self); /*proto*/
3541 static PyObject *__pyx_pf_10sphinxbase_9NGramIter___next__(PyObject *__pyx_v_self) {
3542 PyObject *__pyx_r = NULL;
3544 PyObject *__pyx_t_2 = NULL;
3545 __Pyx_RefNannySetupContext("__next__");
3546 __Pyx_INCREF((PyObject *)__pyx_v_self);
3548 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":424
3550 * def __next__(self):
3551 * if self.first_item: # <<<<<<<<<<<<<<
3552 * self.set_iter(self.itor)
3555 __pyx_t_1 = ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->first_item;
3558 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":425
3559 * def __next__(self):
3560 * if self.first_item:
3561 * self.set_iter(self.itor) # <<<<<<<<<<<<<<
3563 * self.set_iter(ngram_iter_next(self.itor))
3565 __pyx_t_2 = ((struct __pyx_vtabstruct_10sphinxbase_NGramIter *)((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->__pyx_vtab)->set_iter(((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self), ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->itor); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3566 __Pyx_GOTREF(__pyx_t_2);
3567 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3572 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":427
3573 * self.set_iter(self.itor)
3575 * self.set_iter(ngram_iter_next(self.itor)) # <<<<<<<<<<<<<<
3579 __pyx_t_2 = ((struct __pyx_vtabstruct_10sphinxbase_NGramIter *)((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->__pyx_vtab)->set_iter(((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self), ngram_iter_next(((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->itor)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 427; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3580 __Pyx_GOTREF(__pyx_t_2);
3581 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3585 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":428
3587 * self.set_iter(ngram_iter_next(self.itor))
3588 * return self # <<<<<<<<<<<<<<
3590 * def successors(self):
3592 __Pyx_XDECREF(__pyx_r);
3593 __Pyx_INCREF(__pyx_v_self);
3594 __pyx_r = __pyx_v_self;
3597 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3600 __Pyx_XDECREF(__pyx_t_2);
3601 __Pyx_AddTraceback("sphinxbase.NGramIter.__next__");
3604 __Pyx_DECREF((PyObject *)__pyx_v_self);
3605 __Pyx_XGIVEREF(__pyx_r);
3606 __Pyx_RefNannyFinishContext();
3610 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":430
3613 * def successors(self): # <<<<<<<<<<<<<<
3615 * Get an iterator over N+1-gram successors of an N-gram.
3618 static PyObject *__pyx_pf_10sphinxbase_9NGramIter_successors(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
3619 static char __pyx_doc_10sphinxbase_9NGramIter_successors[] = "\n Get an iterator over N+1-gram successors of an N-gram.\n ";
3620 static PyObject *__pyx_pf_10sphinxbase_9NGramIter_successors(PyObject *__pyx_v_self, PyObject *unused) {
3621 struct __pyx_obj_10sphinxbase_NGramIter *__pyx_v_itor;
3622 PyObject *__pyx_r = NULL;
3623 PyObject *__pyx_t_1 = NULL;
3624 PyObject *__pyx_t_2 = NULL;
3625 __Pyx_RefNannySetupContext("successors");
3626 __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)Py_None); __Pyx_INCREF(Py_None);
3628 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":435
3630 * cdef NGramIter itor
3631 * itor = NGramIter(self.lm, self.m + 1) # <<<<<<<<<<<<<<
3632 * itor.itor = ngram_iter_successors(self.itor)
3635 __pyx_t_1 = PyInt_FromLong((((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->m + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3636 __Pyx_GOTREF(__pyx_t_1);
3637 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3638 __Pyx_GOTREF(__pyx_t_2);
3639 __Pyx_INCREF(((PyObject *)((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->lm));
3640 PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->lm));
3641 __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->lm));
3642 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
3643 __Pyx_GIVEREF(__pyx_t_1);
3645 __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10sphinxbase_NGramIter)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3646 __Pyx_GOTREF(__pyx_t_1);
3647 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3648 __Pyx_DECREF(((PyObject *)__pyx_v_itor));
3649 __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_t_1);
3652 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":436
3653 * cdef NGramIter itor
3654 * itor = NGramIter(self.lm, self.m + 1)
3655 * itor.itor = ngram_iter_successors(self.itor) # <<<<<<<<<<<<<<
3659 __pyx_v_itor->itor = ngram_iter_successors(((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->itor);
3661 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":437
3662 * itor = NGramIter(self.lm, self.m + 1)
3663 * itor.itor = ngram_iter_successors(self.itor)
3664 * return itor # <<<<<<<<<<<<<<
3666 * def binstr(str val, int nbits):
3668 __Pyx_XDECREF(__pyx_r);
3669 __Pyx_INCREF(((PyObject *)__pyx_v_itor));
3670 __pyx_r = ((PyObject *)__pyx_v_itor);
3673 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3676 __Pyx_XDECREF(__pyx_t_1);
3677 __Pyx_XDECREF(__pyx_t_2);
3678 __Pyx_AddTraceback("sphinxbase.NGramIter.successors");
3681 __Pyx_DECREF((PyObject *)__pyx_v_itor);
3682 __Pyx_XGIVEREF(__pyx_r);
3683 __Pyx_RefNannyFinishContext();
3687 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":439
3690 * def binstr(str val, int nbits): # <<<<<<<<<<<<<<
3692 * Silly function to format a string as a binary string
3695 static PyObject *__pyx_pf_10sphinxbase_binstr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3696 static char __pyx_doc_10sphinxbase_binstr[] = "\n Silly function to format a string as a binary string\n ";
3697 static PyObject *__pyx_pf_10sphinxbase_binstr(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3698 PyObject *__pyx_v_val = 0;
3701 PyObject *__pyx_v_outstr;
3702 PyObject *__pyx_v_c;
3703 PyObject *__pyx_v_cval;
3704 PyObject *__pyx_v_cnb;
3705 PyObject *__pyx_r = NULL;
3706 Py_ssize_t __pyx_t_1;
3707 PyObject *__pyx_t_2 = NULL;
3708 PyObject *__pyx_t_3 = NULL;
3709 PyObject *__pyx_t_4 = NULL;
3712 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__val,&__pyx_n_s__nbits,0};
3713 __Pyx_RefNannySetupContext("binstr");
3714 __pyx_self = __pyx_self;
3715 if (unlikely(__pyx_kwds)) {
3716 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3717 PyObject* values[2] = {0,0};
3718 switch (PyTuple_GET_SIZE(__pyx_args)) {
3719 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3720 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3722 default: goto __pyx_L5_argtuple_error;
3724 switch (PyTuple_GET_SIZE(__pyx_args)) {
3726 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__val);
3727 if (likely(values[0])) kw_args--;
3728 else goto __pyx_L5_argtuple_error;
3730 values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbits);
3731 if (likely(values[1])) kw_args--;
3733 __Pyx_RaiseArgtupleInvalid("binstr", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3736 if (unlikely(kw_args > 0)) {
3737 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "binstr") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3739 __pyx_v_val = ((PyObject *)values[0]);
3740 __pyx_v_nbits = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_nbits == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3741 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3742 goto __pyx_L5_argtuple_error;
3744 __pyx_v_val = ((PyObject *)PyTuple_GET_ITEM(__pyx_args, 0));
3745 __pyx_v_nbits = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_nbits == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3747 goto __pyx_L4_argument_unpacking_done;
3748 __pyx_L5_argtuple_error:;
3749 __Pyx_RaiseArgtupleInvalid("binstr", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3751 __Pyx_AddTraceback("sphinxbase.binstr");
3753 __pyx_L4_argument_unpacking_done:;
3754 __Pyx_INCREF(__pyx_v_val);
3755 __pyx_v_outstr = Py_None; __Pyx_INCREF(Py_None);
3756 __pyx_v_c = Py_None; __Pyx_INCREF(Py_None);
3757 __pyx_v_cval = Py_None; __Pyx_INCREF(Py_None);
3758 __pyx_v_cnb = Py_None; __Pyx_INCREF(Py_None);
3759 if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_val), &PyString_Type, 1, "val", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3761 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":444
3764 * outstr = "" # <<<<<<<<<<<<<<
3768 __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
3769 __Pyx_DECREF(__pyx_v_outstr);
3770 __pyx_v_outstr = ((PyObject *)__pyx_kp_s_13);
3772 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":445
3775 * for c in val: # <<<<<<<<<<<<<<
3777 * cnb = min(8, nbits)
3779 __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(((PyObject *)__pyx_v_val)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3780 __Pyx_GOTREF(__pyx_t_2);
3783 __pyx_t_3 = PyIter_Next(__pyx_t_2);
3785 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3788 __Pyx_GOTREF(__pyx_t_3);
3790 __Pyx_DECREF(__pyx_v_c);
3791 __pyx_v_c = __pyx_t_3;
3794 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":446
3797 * cval = ord(c) # <<<<<<<<<<<<<<
3798 * cnb = min(8, nbits)
3799 * for i in range(0,cnb):
3801 __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3802 __Pyx_GOTREF(__pyx_t_3);
3803 __Pyx_INCREF(__pyx_v_c);
3804 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_c);
3805 __Pyx_GIVEREF(__pyx_v_c);
3806 __pyx_t_4 = PyObject_Call(__pyx_builtin_ord, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3807 __Pyx_GOTREF(__pyx_t_4);
3808 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3809 __Pyx_DECREF(__pyx_v_cval);
3810 __pyx_v_cval = __pyx_t_4;
3813 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":447
3816 * cnb = min(8, nbits) # <<<<<<<<<<<<<<
3817 * for i in range(0,cnb):
3818 * outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3820 __pyx_t_4 = PyInt_FromLong(__pyx_v_nbits); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3821 __Pyx_GOTREF(__pyx_t_4);
3822 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3823 __Pyx_GOTREF(__pyx_t_3);
3824 __Pyx_INCREF(__pyx_int_8);
3825 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_int_8);
3826 __Pyx_GIVEREF(__pyx_int_8);
3827 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_4);
3828 __Pyx_GIVEREF(__pyx_t_4);
3830 __pyx_t_4 = PyObject_Call(__pyx_builtin_min, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3831 __Pyx_GOTREF(__pyx_t_4);
3832 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3833 __Pyx_DECREF(__pyx_v_cnb);
3834 __pyx_v_cnb = __pyx_t_4;
3837 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":448
3839 * cnb = min(8, nbits)
3840 * for i in range(0,cnb): # <<<<<<<<<<<<<<
3841 * outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3844 __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_v_cnb); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3845 for (__pyx_t_6 = 0; __pyx_t_6 < __pyx_t_5; __pyx_t_6+=1) {
3846 __pyx_v_i = __pyx_t_6;
3848 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":449
3849 * cnb = min(8, nbits)
3850 * for i in range(0,cnb):
3851 * outstr += "%d" % ((cval & (1 << 7-i)) != 0) # <<<<<<<<<<<<<<
3855 __pyx_t_4 = PyInt_FromLong((1 << (7 - __pyx_v_i))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3856 __Pyx_GOTREF(__pyx_t_4);
3857 __pyx_t_3 = PyNumber_And(__pyx_v_cval, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3858 __Pyx_GOTREF(__pyx_t_3);
3859 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3860 __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3861 __Pyx_GOTREF(__pyx_t_4);
3862 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3863 __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3864 __Pyx_GOTREF(__pyx_t_3);
3865 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3866 __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_outstr, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3867 __Pyx_GOTREF(__pyx_t_4);
3868 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3869 __Pyx_DECREF(__pyx_v_outstr);
3870 __pyx_v_outstr = __pyx_t_4;
3874 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":450
3875 * for i in range(0,cnb):
3876 * outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3877 * nbits -= 8 # <<<<<<<<<<<<<<
3883 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3885 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":451
3886 * outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3888 * return outstr # <<<<<<<<<<<<<<
3890 * def bincw(int cw, int nbits):
3892 __Pyx_XDECREF(__pyx_r);
3893 __Pyx_INCREF(__pyx_v_outstr);
3894 __pyx_r = __pyx_v_outstr;
3897 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3900 __Pyx_XDECREF(__pyx_t_2);
3901 __Pyx_XDECREF(__pyx_t_3);
3902 __Pyx_XDECREF(__pyx_t_4);
3903 __Pyx_AddTraceback("sphinxbase.binstr");
3906 __Pyx_DECREF(__pyx_v_outstr);
3907 __Pyx_DECREF(__pyx_v_c);
3908 __Pyx_DECREF(__pyx_v_cval);
3909 __Pyx_DECREF(__pyx_v_cnb);
3910 __Pyx_DECREF(__pyx_v_val);
3911 __Pyx_XGIVEREF(__pyx_r);
3912 __Pyx_RefNannyFinishContext();
3916 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":453
3919 * def bincw(int cw, int nbits): # <<<<<<<<<<<<<<
3921 * Silly function to format an int as a binary string
3924 static PyObject *__pyx_pf_10sphinxbase_bincw(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3925 static char __pyx_doc_10sphinxbase_bincw[] = "\n Silly function to format an int as a binary string\n ";
3926 static PyObject *__pyx_pf_10sphinxbase_bincw(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3930 PyObject *__pyx_v_outstr;
3931 PyObject *__pyx_r = NULL;
3934 PyObject *__pyx_t_3 = NULL;
3935 PyObject *__pyx_t_4 = NULL;
3936 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__cw,&__pyx_n_s__nbits,0};
3937 __Pyx_RefNannySetupContext("bincw");
3938 __pyx_self = __pyx_self;
3939 if (unlikely(__pyx_kwds)) {
3940 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3941 PyObject* values[2] = {0,0};
3942 switch (PyTuple_GET_SIZE(__pyx_args)) {
3943 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3944 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3946 default: goto __pyx_L5_argtuple_error;
3948 switch (PyTuple_GET_SIZE(__pyx_args)) {
3950 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__cw);
3951 if (likely(values[0])) kw_args--;
3952 else goto __pyx_L5_argtuple_error;
3954 values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbits);
3955 if (likely(values[1])) kw_args--;
3957 __Pyx_RaiseArgtupleInvalid("bincw", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3960 if (unlikely(kw_args > 0)) {
3961 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "bincw") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3963 __pyx_v_cw = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_cw == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3964 __pyx_v_nbits = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_nbits == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3965 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3966 goto __pyx_L5_argtuple_error;
3968 __pyx_v_cw = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_cw == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3969 __pyx_v_nbits = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_nbits == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3971 goto __pyx_L4_argument_unpacking_done;
3972 __pyx_L5_argtuple_error:;
3973 __Pyx_RaiseArgtupleInvalid("bincw", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3975 __Pyx_AddTraceback("sphinxbase.bincw");
3977 __pyx_L4_argument_unpacking_done:;
3978 __pyx_v_outstr = Py_None; __Pyx_INCREF(Py_None);
3980 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":458
3983 * outstr = "" # <<<<<<<<<<<<<<
3984 * for i in range(0,nbits):
3985 * outstr = "%s" % (cw & 1) + outstr
3987 __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
3988 __Pyx_DECREF(__pyx_v_outstr);
3989 __pyx_v_outstr = ((PyObject *)__pyx_kp_s_13);
3991 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":459
3994 * for i in range(0,nbits): # <<<<<<<<<<<<<<
3995 * outstr = "%s" % (cw & 1) + outstr
3998 __pyx_t_1 = __pyx_v_nbits;
3999 for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
4000 __pyx_v_i = __pyx_t_2;
4002 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":460
4004 * for i in range(0,nbits):
4005 * outstr = "%s" % (cw & 1) + outstr # <<<<<<<<<<<<<<
4009 __pyx_t_3 = PyInt_FromLong((__pyx_v_cw & 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4010 __Pyx_GOTREF(__pyx_t_3);
4011 __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4012 __Pyx_GOTREF(__pyx_t_4);
4013 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4014 __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_v_outstr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4015 __Pyx_GOTREF(__pyx_t_3);
4016 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4017 __Pyx_DECREF(__pyx_v_outstr);
4018 __pyx_v_outstr = __pyx_t_3;
4021 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":461
4022 * for i in range(0,nbits):
4023 * outstr = "%s" % (cw & 1) + outstr
4024 * cw >>= 1 # <<<<<<<<<<<<<<
4031 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":462
4032 * outstr = "%s" % (cw & 1) + outstr
4034 * return outstr # <<<<<<<<<<<<<<
4036 * # FIXME: Due to the style of IO in huff_code API this part of the code
4038 __Pyx_XDECREF(__pyx_r);
4039 __Pyx_INCREF(__pyx_v_outstr);
4040 __pyx_r = __pyx_v_outstr;
4043 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4046 __Pyx_XDECREF(__pyx_t_3);
4047 __Pyx_XDECREF(__pyx_t_4);
4048 __Pyx_AddTraceback("sphinxbase.bincw");
4051 __Pyx_DECREF(__pyx_v_outstr);
4052 __Pyx_XGIVEREF(__pyx_r);
4053 __Pyx_RefNannyFinishContext();
4057 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":482
4058 * @type infile: file | str
4060 * def __init__(self, alphabet=None, infile=None): # <<<<<<<<<<<<<<
4061 * cdef char **symbols
4062 * cdef int *frequencies
4065 static int __pyx_pf_10sphinxbase_8HuffCode___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4066 static int __pyx_pf_10sphinxbase_8HuffCode___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4067 PyObject *__pyx_v_alphabet = 0;
4068 PyObject *__pyx_v_infile = 0;
4069 char **__pyx_v_symbols;
4070 int *__pyx_v_frequencies;
4072 PyObject *__pyx_v_bogus;
4073 PyObject *__pyx_v_i;
4074 PyObject *__pyx_v_spam;
4075 PyObject *__pyx_v_sym;
4076 PyObject *__pyx_v_freq;
4078 PyObject *__pyx_t_1 = NULL;
4082 PyObject *__pyx_t_5 = NULL;
4083 PyObject *__pyx_t_6 = NULL;
4084 Py_ssize_t __pyx_t_7;
4085 PyObject *__pyx_t_8 = NULL;
4086 PyObject *__pyx_t_9 = NULL;
4088 Py_ssize_t __pyx_t_11;
4090 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__alphabet,&__pyx_n_s__infile,0};
4091 __Pyx_RefNannySetupContext("__init__");
4092 if (unlikely(__pyx_kwds)) {
4093 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
4094 PyObject* values[2] = {0,0};
4095 values[0] = ((PyObject *)Py_None);
4096 values[1] = ((PyObject *)Py_None);
4097 switch (PyTuple_GET_SIZE(__pyx_args)) {
4098 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4099 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4101 default: goto __pyx_L5_argtuple_error;
4103 switch (PyTuple_GET_SIZE(__pyx_args)) {
4106 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alphabet);
4107 if (unlikely(value)) { values[0] = value; kw_args--; }
4111 PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile);
4112 if (unlikely(value)) { values[1] = value; kw_args--; }
4115 if (unlikely(kw_args > 0)) {
4116 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4118 __pyx_v_alphabet = values[0];
4119 __pyx_v_infile = values[1];
4121 __pyx_v_alphabet = ((PyObject *)Py_None);
4122 __pyx_v_infile = ((PyObject *)Py_None);
4123 switch (PyTuple_GET_SIZE(__pyx_args)) {
4124 case 2: __pyx_v_infile = PyTuple_GET_ITEM(__pyx_args, 1);
4125 case 1: __pyx_v_alphabet = PyTuple_GET_ITEM(__pyx_args, 0);
4127 default: goto __pyx_L5_argtuple_error;
4130 goto __pyx_L4_argument_unpacking_done;
4131 __pyx_L5_argtuple_error:;
4132 __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 482; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4134 __Pyx_AddTraceback("sphinxbase.HuffCode.__init__");
4136 __pyx_L4_argument_unpacking_done:;
4137 __Pyx_INCREF((PyObject *)__pyx_v_self);
4138 __Pyx_INCREF(__pyx_v_alphabet);
4139 __Pyx_INCREF(__pyx_v_infile);
4140 __pyx_v_bogus = Py_None; __Pyx_INCREF(Py_None);
4141 __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
4142 __pyx_v_spam = Py_None; __Pyx_INCREF(Py_None);
4143 __pyx_v_sym = Py_None; __Pyx_INCREF(Py_None);
4144 __pyx_v_freq = Py_None; __Pyx_INCREF(Py_None);
4146 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":487
4149 * if alphabet == None and infile == None: # <<<<<<<<<<<<<<
4150 * raise ValueError, "One of alphabet or infile must be passed to constructor"
4151 * if alphabet != None and infile != None:
4153 __pyx_t_1 = PyObject_RichCompare(__pyx_v_alphabet, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4154 __Pyx_GOTREF(__pyx_t_1);
4155 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4156 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4158 __pyx_t_1 = PyObject_RichCompare(__pyx_v_infile, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4159 __Pyx_GOTREF(__pyx_t_1);
4160 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4161 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4162 __pyx_t_4 = __pyx_t_3;
4164 __pyx_t_4 = __pyx_t_2;
4168 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":488
4170 * if alphabet == None and infile == None:
4171 * raise ValueError, "One of alphabet or infile must be passed to constructor" # <<<<<<<<<<<<<<
4172 * if alphabet != None and infile != None:
4173 * raise ValueError, "Only one of alphabet or infile must be passed to constructor"
4175 __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_16), 0);
4176 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4181 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":489
4182 * if alphabet == None and infile == None:
4183 * raise ValueError, "One of alphabet or infile must be passed to constructor"
4184 * if alphabet != None and infile != None: # <<<<<<<<<<<<<<
4185 * raise ValueError, "Only one of alphabet or infile must be passed to constructor"
4188 __pyx_t_1 = PyObject_RichCompare(__pyx_v_alphabet, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4189 __Pyx_GOTREF(__pyx_t_1);
4190 __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4191 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4193 __pyx_t_1 = PyObject_RichCompare(__pyx_v_infile, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4194 __Pyx_GOTREF(__pyx_t_1);
4195 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4196 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4197 __pyx_t_3 = __pyx_t_2;
4199 __pyx_t_3 = __pyx_t_4;
4203 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":490
4204 * raise ValueError, "One of alphabet or infile must be passed to constructor"
4205 * if alphabet != None and infile != None:
4206 * raise ValueError, "Only one of alphabet or infile must be passed to constructor" # <<<<<<<<<<<<<<
4210 __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_kp_s_17), 0);
4211 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4216 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":492
4217 * raise ValueError, "Only one of alphabet or infile must be passed to constructor"
4219 * self.fh = None # <<<<<<<<<<<<<<
4223 __Pyx_INCREF(Py_None);
4224 __Pyx_GIVEREF(Py_None);
4225 __Pyx_GOTREF(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh);
4226 __Pyx_DECREF(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh);
4227 ((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh = Py_None;
4229 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":493
4232 * if infile: # <<<<<<<<<<<<<<
4236 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_infile); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4239 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":494
4242 * self.read(infile) # <<<<<<<<<<<<<<
4246 __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__read); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4247 __Pyx_GOTREF(__pyx_t_1);
4248 __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4249 __Pyx_GOTREF(__pyx_t_5);
4250 __Pyx_INCREF(__pyx_v_infile);
4251 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_infile);
4252 __Pyx_GIVEREF(__pyx_v_infile);
4253 __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4254 __Pyx_GOTREF(__pyx_t_6);
4255 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4256 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4257 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4259 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":495
4262 * return # <<<<<<<<<<<<<<
4264 * nsym = len(alphabet)
4272 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":497
4275 * nsym = len(alphabet) # <<<<<<<<<<<<<<
4276 * frequencies = <int *>ckd_calloc(nsym, sizeof(int))
4277 * symbols = <char **>ckd_calloc(nsym, sizeof(char *))
4279 __pyx_t_7 = PyObject_Length(__pyx_v_alphabet); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4280 __pyx_v_nsym = __pyx_t_7;
4282 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":498
4284 * nsym = len(alphabet)
4285 * frequencies = <int *>ckd_calloc(nsym, sizeof(int)) # <<<<<<<<<<<<<<
4286 * symbols = <char **>ckd_calloc(nsym, sizeof(char *))
4287 * # Need to create separate Python objects for each string,
4289 __pyx_v_frequencies = ((int *)ckd_calloc(__pyx_v_nsym, (sizeof(int))));
4291 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":499
4292 * nsym = len(alphabet)
4293 * frequencies = <int *>ckd_calloc(nsym, sizeof(int))
4294 * symbols = <char **>ckd_calloc(nsym, sizeof(char *)) # <<<<<<<<<<<<<<
4295 * # Need to create separate Python objects for each string,
4296 * # otherwise we get random duplicates of the codewords...
4298 __pyx_v_symbols = ((char **)ckd_calloc(__pyx_v_nsym, (sizeof(char *))));
4300 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":502
4301 * # Need to create separate Python objects for each string,
4302 * # otherwise we get random duplicates of the codewords...
4303 * bogus = [] # <<<<<<<<<<<<<<
4304 * for i, spam in enumerate(alphabet):
4307 __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4308 __Pyx_GOTREF(((PyObject *)__pyx_t_6));
4309 __Pyx_DECREF(__pyx_v_bogus);
4310 __pyx_v_bogus = ((PyObject *)__pyx_t_6);
4313 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":503
4314 * # otherwise we get random duplicates of the codewords...
4316 * for i, spam in enumerate(alphabet): # <<<<<<<<<<<<<<
4318 * bogus.append(repr(sym))
4320 __Pyx_INCREF(__pyx_int_0);
4321 __pyx_t_6 = __pyx_int_0;
4322 if (PyList_CheckExact(__pyx_v_alphabet) || PyTuple_CheckExact(__pyx_v_alphabet)) {
4323 __pyx_t_7 = 0; __pyx_t_5 = __pyx_v_alphabet; __Pyx_INCREF(__pyx_t_5);
4325 __pyx_t_7 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_alphabet); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4326 __Pyx_GOTREF(__pyx_t_5);
4329 if (likely(PyList_CheckExact(__pyx_t_5))) {
4330 if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
4331 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++;
4332 } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
4333 if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
4334 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_1); __pyx_t_7++;
4336 __pyx_t_1 = PyIter_Next(__pyx_t_5);
4338 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4341 __Pyx_GOTREF(__pyx_t_1);
4343 __Pyx_DECREF(__pyx_v_spam);
4344 __pyx_v_spam = __pyx_t_1;
4346 __Pyx_INCREF(__pyx_t_6);
4347 __Pyx_DECREF(__pyx_v_i);
4348 __pyx_v_i = __pyx_t_6;
4349 __pyx_t_1 = PyNumber_Add(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4350 __Pyx_GOTREF(__pyx_t_1);
4351 __Pyx_DECREF(__pyx_t_6);
4352 __pyx_t_6 = __pyx_t_1;
4355 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":504
4357 * for i, spam in enumerate(alphabet):
4358 * sym, freq = spam # <<<<<<<<<<<<<<
4359 * bogus.append(repr(sym))
4360 * frequencies[i] = freq
4362 if (PyTuple_CheckExact(__pyx_v_spam) && likely(PyTuple_GET_SIZE(__pyx_v_spam) == 2)) {
4363 PyObject* tuple = __pyx_v_spam;
4364 __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
4365 __pyx_t_8 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_8);
4366 __Pyx_DECREF(__pyx_v_sym);
4367 __pyx_v_sym = __pyx_t_1;
4369 __Pyx_DECREF(__pyx_v_freq);
4370 __pyx_v_freq = __pyx_t_8;
4373 __pyx_t_9 = PyObject_GetIter(__pyx_v_spam); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4374 __Pyx_GOTREF(__pyx_t_9);
4375 __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4376 __Pyx_GOTREF(__pyx_t_1);
4377 __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4378 __Pyx_GOTREF(__pyx_t_8);
4379 if (__Pyx_EndUnpack(__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4380 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
4381 __Pyx_DECREF(__pyx_v_sym);
4382 __pyx_v_sym = __pyx_t_1;
4384 __Pyx_DECREF(__pyx_v_freq);
4385 __pyx_v_freq = __pyx_t_8;
4389 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":505
4390 * for i, spam in enumerate(alphabet):
4392 * bogus.append(repr(sym)) # <<<<<<<<<<<<<<
4393 * frequencies[i] = freq
4394 * symbols[i] = bogus[-1]
4396 __pyx_t_8 = PyObject_Repr(__pyx_v_sym); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4397 __Pyx_GOTREF(__pyx_t_8);
4398 __pyx_t_1 = __Pyx_PyObject_Append(__pyx_v_bogus, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4399 __Pyx_GOTREF(__pyx_t_1);
4400 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
4401 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4403 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":506
4405 * bogus.append(repr(sym))
4406 * frequencies[i] = freq # <<<<<<<<<<<<<<
4407 * symbols[i] = bogus[-1]
4408 * self.hc = huff_code_build_str(symbols, frequencies, nsym)
4410 __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_v_freq); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4411 __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4412 (__pyx_v_frequencies[__pyx_t_11]) = __pyx_t_10;
4414 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":507
4415 * bogus.append(repr(sym))
4416 * frequencies[i] = freq
4417 * symbols[i] = bogus[-1] # <<<<<<<<<<<<<<
4418 * self.hc = huff_code_build_str(symbols, frequencies, nsym)
4419 * ckd_free(frequencies)
4421 __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_bogus, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4422 __Pyx_GOTREF(__pyx_t_1);
4423 __pyx_t_12 = __Pyx_PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4424 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4425 __pyx_t_11 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_11 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4426 (__pyx_v_symbols[__pyx_t_11]) = __pyx_t_12;
4428 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4429 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4431 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":508
4432 * frequencies[i] = freq
4433 * symbols[i] = bogus[-1]
4434 * self.hc = huff_code_build_str(symbols, frequencies, nsym) # <<<<<<<<<<<<<<
4435 * ckd_free(frequencies)
4438 ((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc = huff_code_build_str(__pyx_v_symbols, __pyx_v_frequencies, __pyx_v_nsym);
4440 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":509
4441 * symbols[i] = bogus[-1]
4442 * self.hc = huff_code_build_str(symbols, frequencies, nsym)
4443 * ckd_free(frequencies) # <<<<<<<<<<<<<<
4447 ckd_free(__pyx_v_frequencies);
4449 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":510
4450 * self.hc = huff_code_build_str(symbols, frequencies, nsym)
4451 * ckd_free(frequencies)
4452 * ckd_free(symbols) # <<<<<<<<<<<<<<
4454 * def read(self, infile):
4456 ckd_free(__pyx_v_symbols);
4461 __Pyx_XDECREF(__pyx_t_1);
4462 __Pyx_XDECREF(__pyx_t_5);
4463 __Pyx_XDECREF(__pyx_t_6);
4464 __Pyx_XDECREF(__pyx_t_8);
4465 __Pyx_XDECREF(__pyx_t_9);
4466 __Pyx_AddTraceback("sphinxbase.HuffCode.__init__");
4469 __Pyx_DECREF(__pyx_v_bogus);
4470 __Pyx_DECREF(__pyx_v_i);
4471 __Pyx_DECREF(__pyx_v_spam);
4472 __Pyx_DECREF(__pyx_v_sym);
4473 __Pyx_DECREF(__pyx_v_freq);
4474 __Pyx_DECREF((PyObject *)__pyx_v_self);
4475 __Pyx_DECREF(__pyx_v_alphabet);
4476 __Pyx_DECREF(__pyx_v_infile);
4477 __Pyx_RefNannyFinishContext();
4481 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":512
4484 * def read(self, infile): # <<<<<<<<<<<<<<
4485 * if not isinstance(infile, file):
4486 * infile = file(infile, "rb")
4489 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_read(PyObject *__pyx_v_self, PyObject *__pyx_v_infile); /*proto*/
4490 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_read(PyObject *__pyx_v_self, PyObject *__pyx_v_infile) {
4491 PyObject *__pyx_r = NULL;
4494 PyObject *__pyx_t_3 = NULL;
4495 PyObject *__pyx_t_4 = NULL;
4496 huff_code_t *__pyx_t_5;
4497 __Pyx_RefNannySetupContext("read");
4498 __Pyx_INCREF((PyObject *)__pyx_v_self);
4499 __Pyx_INCREF(__pyx_v_infile);
4501 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":513
4503 * def read(self, infile):
4504 * if not isinstance(infile, file): # <<<<<<<<<<<<<<
4505 * infile = file(infile, "rb")
4506 * huff_code_free(self.hc)
4508 __pyx_t_1 = PyObject_TypeCheck(__pyx_v_infile, ((PyTypeObject *)((PyObject*)&PyFile_Type)));
4509 __pyx_t_2 = (!__pyx_t_1);
4512 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":514
4513 * def read(self, infile):
4514 * if not isinstance(infile, file):
4515 * infile = file(infile, "rb") # <<<<<<<<<<<<<<
4516 * huff_code_free(self.hc)
4517 * self.hc = huff_code_read(PyFile_AsFile(infile))
4519 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4520 __Pyx_GOTREF(__pyx_t_3);
4521 __Pyx_INCREF(__pyx_v_infile);
4522 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_infile);
4523 __Pyx_GIVEREF(__pyx_v_infile);
4524 __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
4525 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__rb));
4526 __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
4527 __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyFile_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4528 __Pyx_GOTREF(__pyx_t_4);
4529 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4530 __Pyx_DECREF(__pyx_v_infile);
4531 __pyx_v_infile = __pyx_t_4;
4537 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":515
4538 * if not isinstance(infile, file):
4539 * infile = file(infile, "rb")
4540 * huff_code_free(self.hc) # <<<<<<<<<<<<<<
4541 * self.hc = huff_code_read(PyFile_AsFile(infile))
4544 huff_code_free(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc);
4546 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":516
4547 * infile = file(infile, "rb")
4548 * huff_code_free(self.hc)
4549 * self.hc = huff_code_read(PyFile_AsFile(infile)) # <<<<<<<<<<<<<<
4551 * def write(self, outfile):
4553 __pyx_t_5 = huff_code_read(PyFile_AsFile(__pyx_v_infile)); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4554 ((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc = __pyx_t_5;
4556 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4559 __Pyx_XDECREF(__pyx_t_3);
4560 __Pyx_XDECREF(__pyx_t_4);
4561 __Pyx_AddTraceback("sphinxbase.HuffCode.read");
4564 __Pyx_DECREF((PyObject *)__pyx_v_self);
4565 __Pyx_DECREF(__pyx_v_infile);
4566 __Pyx_XGIVEREF(__pyx_r);
4567 __Pyx_RefNannyFinishContext();
4571 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":518
4572 * self.hc = huff_code_read(PyFile_AsFile(infile))
4574 * def write(self, outfile): # <<<<<<<<<<<<<<
4575 * if not isinstance(outfile, file):
4576 * outfile = file(outfile, "wb")
4579 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_write(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile); /*proto*/
4580 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_write(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile) {
4581 PyObject *__pyx_r = NULL;
4584 PyObject *__pyx_t_3 = NULL;
4585 PyObject *__pyx_t_4 = NULL;
4587 __Pyx_RefNannySetupContext("write");
4588 __Pyx_INCREF((PyObject *)__pyx_v_self);
4589 __Pyx_INCREF(__pyx_v_outfile);
4591 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":519
4593 * def write(self, outfile):
4594 * if not isinstance(outfile, file): # <<<<<<<<<<<<<<
4595 * outfile = file(outfile, "wb")
4596 * huff_code_write(self.hc, PyFile_AsFile(outfile))
4598 __pyx_t_1 = PyObject_TypeCheck(__pyx_v_outfile, ((PyTypeObject *)((PyObject*)&PyFile_Type)));
4599 __pyx_t_2 = (!__pyx_t_1);
4602 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":520
4603 * def write(self, outfile):
4604 * if not isinstance(outfile, file):
4605 * outfile = file(outfile, "wb") # <<<<<<<<<<<<<<
4606 * huff_code_write(self.hc, PyFile_AsFile(outfile))
4609 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4610 __Pyx_GOTREF(__pyx_t_3);
4611 __Pyx_INCREF(__pyx_v_outfile);
4612 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_outfile);
4613 __Pyx_GIVEREF(__pyx_v_outfile);
4614 __Pyx_INCREF(((PyObject *)__pyx_n_s__wb));
4615 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__wb));
4616 __Pyx_GIVEREF(((PyObject *)__pyx_n_s__wb));
4617 __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyFile_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4618 __Pyx_GOTREF(__pyx_t_4);
4619 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4620 __Pyx_DECREF(__pyx_v_outfile);
4621 __pyx_v_outfile = __pyx_t_4;
4627 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":521
4628 * if not isinstance(outfile, file):
4629 * outfile = file(outfile, "wb")
4630 * huff_code_write(self.hc, PyFile_AsFile(outfile)) # <<<<<<<<<<<<<<
4632 * def dump(self, outfile):
4634 __pyx_t_5 = huff_code_write(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, PyFile_AsFile(__pyx_v_outfile)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4636 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4639 __Pyx_XDECREF(__pyx_t_3);
4640 __Pyx_XDECREF(__pyx_t_4);
4641 __Pyx_AddTraceback("sphinxbase.HuffCode.write");
4644 __Pyx_DECREF((PyObject *)__pyx_v_self);
4645 __Pyx_DECREF(__pyx_v_outfile);
4646 __Pyx_XGIVEREF(__pyx_r);
4647 __Pyx_RefNannyFinishContext();
4651 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":523
4652 * huff_code_write(self.hc, PyFile_AsFile(outfile))
4654 * def dump(self, outfile): # <<<<<<<<<<<<<<
4655 * if not isinstance(outfile, file):
4656 * outfile = file(outfile, "w")
4659 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_dump(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile); /*proto*/
4660 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_dump(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile) {
4661 PyObject *__pyx_r = NULL;
4664 PyObject *__pyx_t_3 = NULL;
4665 PyObject *__pyx_t_4 = NULL;
4667 __Pyx_RefNannySetupContext("dump");
4668 __Pyx_INCREF((PyObject *)__pyx_v_self);
4669 __Pyx_INCREF(__pyx_v_outfile);
4671 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":524
4673 * def dump(self, outfile):
4674 * if not isinstance(outfile, file): # <<<<<<<<<<<<<<
4675 * outfile = file(outfile, "w")
4676 * huff_code_dump(self.hc, PyFile_AsFile(outfile))
4678 __pyx_t_1 = PyObject_TypeCheck(__pyx_v_outfile, ((PyTypeObject *)((PyObject*)&PyFile_Type)));
4679 __pyx_t_2 = (!__pyx_t_1);
4682 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":525
4683 * def dump(self, outfile):
4684 * if not isinstance(outfile, file):
4685 * outfile = file(outfile, "w") # <<<<<<<<<<<<<<
4686 * huff_code_dump(self.hc, PyFile_AsFile(outfile))
4689 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4690 __Pyx_GOTREF(__pyx_t_3);
4691 __Pyx_INCREF(__pyx_v_outfile);
4692 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_outfile);
4693 __Pyx_GIVEREF(__pyx_v_outfile);
4694 __Pyx_INCREF(((PyObject *)__pyx_n_s__w));
4695 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__w));
4696 __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w));
4697 __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)&PyFile_Type)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4698 __Pyx_GOTREF(__pyx_t_4);
4699 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4700 __Pyx_DECREF(__pyx_v_outfile);
4701 __pyx_v_outfile = __pyx_t_4;
4707 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":526
4708 * if not isinstance(outfile, file):
4709 * outfile = file(outfile, "w")
4710 * huff_code_dump(self.hc, PyFile_AsFile(outfile)) # <<<<<<<<<<<<<<
4712 * def encode(self, seq):
4714 __pyx_t_5 = huff_code_dump(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, PyFile_AsFile(__pyx_v_outfile)); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4716 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4719 __Pyx_XDECREF(__pyx_t_3);
4720 __Pyx_XDECREF(__pyx_t_4);
4721 __Pyx_AddTraceback("sphinxbase.HuffCode.dump");
4724 __Pyx_DECREF((PyObject *)__pyx_v_self);
4725 __Pyx_DECREF(__pyx_v_outfile);
4726 __Pyx_XGIVEREF(__pyx_r);
4727 __Pyx_RefNannyFinishContext();
4731 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":528
4732 * huff_code_dump(self.hc, PyFile_AsFile(outfile))
4734 * def encode(self, seq): # <<<<<<<<<<<<<<
4736 * Encode a sequence of symbols to a byte array, returning that
4739 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_encode(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
4740 static char __pyx_doc_10sphinxbase_8HuffCode_encode[] = "\n Encode a sequence of symbols to a byte array, returning that\n array and the bit offset of the next codeword in the last\n byte (i.e. 8 minutes the number of extra zero bits)\n ";
4741 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_encode(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
4742 unsigned int __pyx_v_cw;
4748 unsigned char __pyx_v_buf;
4749 char *__pyx_v_output;
4750 PyObject *__pyx_v_sym;
4751 PyObject *__pyx_v_sss;
4752 PyObject *__pyx_v_outstr;
4753 PyObject *__pyx_r = NULL;
4754 Py_ssize_t __pyx_t_1;
4755 PyObject *__pyx_t_2 = NULL;
4756 PyObject *__pyx_t_3 = NULL;
4759 __Pyx_RefNannySetupContext("encode");
4760 __Pyx_INCREF((PyObject *)__pyx_v_self);
4761 __Pyx_INCREF(__pyx_v_seq);
4762 __pyx_v_sym = Py_None; __Pyx_INCREF(Py_None);
4763 __pyx_v_sss = Py_None; __Pyx_INCREF(Py_None);
4764 __pyx_v_outstr = Py_None; __Pyx_INCREF(Py_None);
4766 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":535
4768 * cdef unsigned int cw
4769 * cdef int cwlen, nbits = 0, nbytes, offset, i # <<<<<<<<<<<<<<
4770 * cdef unsigned char buf = 0
4775 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":536
4776 * cdef unsigned int cw
4777 * cdef int cwlen, nbits = 0, nbytes, offset, i
4778 * cdef unsigned char buf = 0 # <<<<<<<<<<<<<<
4784 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":539
4787 * for sym in seq: # <<<<<<<<<<<<<<
4789 * cwlen = huff_code_encode_str(self.hc, sss, &cw)
4791 if (PyList_CheckExact(__pyx_v_seq) || PyTuple_CheckExact(__pyx_v_seq)) {
4792 __pyx_t_1 = 0; __pyx_t_2 = __pyx_v_seq; __Pyx_INCREF(__pyx_t_2);
4794 __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_seq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4795 __Pyx_GOTREF(__pyx_t_2);
4798 if (likely(PyList_CheckExact(__pyx_t_2))) {
4799 if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
4800 __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
4801 } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
4802 if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
4803 __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
4805 __pyx_t_3 = PyIter_Next(__pyx_t_2);
4807 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4810 __Pyx_GOTREF(__pyx_t_3);
4812 __Pyx_DECREF(__pyx_v_sym);
4813 __pyx_v_sym = __pyx_t_3;
4816 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":540
4819 * sss = repr(sym) # <<<<<<<<<<<<<<
4820 * cwlen = huff_code_encode_str(self.hc, sss, &cw)
4823 __pyx_t_3 = PyObject_Repr(__pyx_v_sym); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4824 __Pyx_GOTREF(__pyx_t_3);
4825 __Pyx_DECREF(__pyx_v_sss);
4826 __pyx_v_sss = __pyx_t_3;
4829 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":541
4832 * cwlen = huff_code_encode_str(self.hc, sss, &cw) # <<<<<<<<<<<<<<
4834 * nbytes = int((nbits + 7) / 8)
4836 __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_sss); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 541; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4837 __pyx_v_cwlen = huff_code_encode_str(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, __pyx_t_4, (&__pyx_v_cw));
4839 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":542
4841 * cwlen = huff_code_encode_str(self.hc, sss, &cw)
4842 * nbits += cwlen # <<<<<<<<<<<<<<
4843 * nbytes = int((nbits + 7) / 8)
4846 __pyx_v_nbits += __pyx_v_cwlen;
4848 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4850 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":543
4851 * cwlen = huff_code_encode_str(self.hc, sss, &cw)
4853 * nbytes = int((nbits + 7) / 8) # <<<<<<<<<<<<<<
4855 * output = <char *>PyMem_Malloc(nbytes + 1)
4857 __pyx_v_nbytes = ((int)__Pyx_div_long((__pyx_v_nbits + 7), 8));
4859 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":544
4861 * nbytes = int((nbits + 7) / 8)
4862 * offset = 0 # <<<<<<<<<<<<<<
4863 * output = <char *>PyMem_Malloc(nbytes + 1)
4864 * output[nbytes] = 0
4868 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":545
4869 * nbytes = int((nbits + 7) / 8)
4871 * output = <char *>PyMem_Malloc(nbytes + 1) # <<<<<<<<<<<<<<
4872 * output[nbytes] = 0
4875 __pyx_v_output = ((char *)PyMem_Malloc((__pyx_v_nbytes + 1)));
4877 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":546
4879 * output = <char *>PyMem_Malloc(nbytes + 1)
4880 * output[nbytes] = 0 # <<<<<<<<<<<<<<
4884 (__pyx_v_output[__pyx_v_nbytes]) = 0;
4886 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":547
4887 * output = <char *>PyMem_Malloc(nbytes + 1)
4888 * output[nbytes] = 0
4889 * i = 0 # <<<<<<<<<<<<<<
4895 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":548
4896 * output[nbytes] = 0
4898 * nbits = 0 # <<<<<<<<<<<<<<
4904 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":549
4907 * for sym in seq: # <<<<<<<<<<<<<<
4909 * cwlen = huff_code_encode_str(self.hc, sss, &cw)
4911 if (PyList_CheckExact(__pyx_v_seq) || PyTuple_CheckExact(__pyx_v_seq)) {
4912 __pyx_t_1 = 0; __pyx_t_2 = __pyx_v_seq; __Pyx_INCREF(__pyx_t_2);
4914 __pyx_t_1 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_seq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4915 __Pyx_GOTREF(__pyx_t_2);
4918 if (likely(PyList_CheckExact(__pyx_t_2))) {
4919 if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_2)) break;
4920 __pyx_t_3 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
4921 } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
4922 if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
4923 __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_1); __Pyx_INCREF(__pyx_t_3); __pyx_t_1++;
4925 __pyx_t_3 = PyIter_Next(__pyx_t_2);
4927 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4930 __Pyx_GOTREF(__pyx_t_3);
4932 __Pyx_DECREF(__pyx_v_sym);
4933 __pyx_v_sym = __pyx_t_3;
4936 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":550
4939 * sss = repr(sym) # <<<<<<<<<<<<<<
4940 * cwlen = huff_code_encode_str(self.hc, sss, &cw)
4941 * #print "sym: %s cw: %s buf: %s output: %s" \
4943 __pyx_t_3 = PyObject_Repr(__pyx_v_sym); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4944 __Pyx_GOTREF(__pyx_t_3);
4945 __Pyx_DECREF(__pyx_v_sss);
4946 __pyx_v_sss = __pyx_t_3;
4949 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":551
4952 * cwlen = huff_code_encode_str(self.hc, sss, &cw) # <<<<<<<<<<<<<<
4953 * #print "sym: %s cw: %s buf: %s output: %s" \
4954 * # % (sym, bincw(cw, cwlen), bincw(buf >> (8-offset), offset),
4956 __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_v_sss); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4957 __pyx_v_cwlen = huff_code_encode_str(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, __pyx_t_4, (&__pyx_v_cw));
4959 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":557
4960 * #print "cwlen",cwlen
4961 * # Do one byte at a time while full bytes are available
4962 * while cwlen >= 8: # <<<<<<<<<<<<<<
4963 * # Fill low bits of buf with high bits of cw
4964 * buf |= (cw >> (cwlen - (8 - offset))) & ((1 << (8 - offset)) - 1)
4967 __pyx_t_5 = (__pyx_v_cwlen >= 8);
4968 if (!__pyx_t_5) break;
4970 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":559
4972 * # Fill low bits of buf with high bits of cw
4973 * buf |= (cw >> (cwlen - (8 - offset))) & ((1 << (8 - offset)) - 1) # <<<<<<<<<<<<<<
4974 * # Append buf to output
4977 __pyx_v_buf |= ((__pyx_v_cw >> (__pyx_v_cwlen - (8 - __pyx_v_offset))) & ((1 << (8 - __pyx_v_offset)) - 1));
4979 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":561
4980 * buf |= (cw >> (cwlen - (8 - offset))) & ((1 << (8 - offset)) - 1)
4981 * # Append buf to output
4982 * output[i] = buf # <<<<<<<<<<<<<<
4986 (__pyx_v_output[__pyx_v_i]) = __pyx_v_buf;
4988 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":562
4989 * # Append buf to output
4991 * i += 1 # <<<<<<<<<<<<<<
4993 * # Fill high bits of buf with low bits of this byte
4997 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":563
5000 * nbits += 8 # <<<<<<<<<<<<<<
5001 * # Fill high bits of buf with low bits of this byte
5006 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":565
5008 * # Fill high bits of buf with low bits of this byte
5009 * cwlen -= 8 # <<<<<<<<<<<<<<
5010 * buf = (cw >> cwlen) & ((1 << offset) - 1)
5011 * buf <<= (8-offset)
5015 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":566
5016 * # Fill high bits of buf with low bits of this byte
5018 * buf = (cw >> cwlen) & ((1 << offset) - 1) # <<<<<<<<<<<<<<
5019 * buf <<= (8-offset)
5020 * #print "cwlen",cwlen
5022 __pyx_v_buf = ((__pyx_v_cw >> __pyx_v_cwlen) & ((1 << __pyx_v_offset) - 1));
5024 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":567
5026 * buf = (cw >> cwlen) & ((1 << offset) - 1)
5027 * buf <<= (8-offset) # <<<<<<<<<<<<<<
5028 * #print "cwlen",cwlen
5029 * # Now cwlen will be less than 8, but it might still be
5031 __pyx_v_buf <<= (8 - __pyx_v_offset);
5034 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":571
5035 * # Now cwlen will be less than 8, but it might still be
5036 * # more than the available space in buf.
5037 * if cwlen >= (8 - offset): # <<<<<<<<<<<<<<
5038 * # Fill low bits of buf with (8-offset) highest bits of cw
5039 * buf |= (cw >> (cwlen - (8 - offset))) & ((1 << (8 - offset)) - 1)
5041 __pyx_t_5 = (__pyx_v_cwlen >= (8 - __pyx_v_offset));
5044 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":573
5045 * if cwlen >= (8 - offset):
5046 * # Fill low bits of buf with (8-offset) highest bits of cw
5047 * buf |= (cw >> (cwlen - (8 - offset))) & ((1 << (8 - offset)) - 1) # <<<<<<<<<<<<<<
5048 * # Append buf to output
5051 __pyx_v_buf |= ((__pyx_v_cw >> (__pyx_v_cwlen - (8 - __pyx_v_offset))) & ((1 << (8 - __pyx_v_offset)) - 1));
5053 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":575
5054 * buf |= (cw >> (cwlen - (8 - offset))) & ((1 << (8 - offset)) - 1)
5055 * # Append buf to output
5056 * output[i] = buf # <<<<<<<<<<<<<<
5060 (__pyx_v_output[__pyx_v_i]) = __pyx_v_buf;
5062 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":576
5063 * # Append buf to output
5065 * i += 1 # <<<<<<<<<<<<<<
5067 * # cwlen is down to the remaining bits
5071 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":577
5074 * nbits += 8 # <<<<<<<<<<<<<<
5075 * # cwlen is down to the remaining bits
5076 * cwlen -= (8 - offset)
5080 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":579
5082 * # cwlen is down to the remaining bits
5083 * cwlen -= (8 - offset) # <<<<<<<<<<<<<<
5084 * # Offset is now zero since we just completed and emptied buf
5087 __pyx_v_cwlen -= (8 - __pyx_v_offset);
5089 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":581
5090 * cwlen -= (8 - offset)
5091 * # Offset is now zero since we just completed and emptied buf
5092 * offset = 0 # <<<<<<<<<<<<<<
5093 * # buf is zero, because we just emptied it without putting stuff in
5098 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":583
5100 * # buf is zero, because we just emptied it without putting stuff in
5101 * buf = 0 # <<<<<<<<<<<<<<
5102 * #print "cwlen",cwlen
5103 * # Any remaining bits will be taken care of below (we hope)
5110 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":588
5111 * # Add remaining high bits of cw to low bits of buf
5112 * #print "cwlen",cwlen
5113 * buf |= ((cw & ((1 << cwlen) - 1)) << (8 - offset - cwlen)) # <<<<<<<<<<<<<<
5115 * #print "after buf: %s output: %s" \
5117 __pyx_v_buf |= ((__pyx_v_cw & ((1 << __pyx_v_cwlen) - 1)) << ((8 - __pyx_v_offset) - __pyx_v_cwlen));
5119 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":589
5120 * #print "cwlen",cwlen
5121 * buf |= ((cw & ((1 << cwlen) - 1)) << (8 - offset - cwlen))
5122 * offset += cwlen # <<<<<<<<<<<<<<
5123 * #print "after buf: %s output: %s" \
5124 * # % (bincw(buf >> (8-offset), offset), binstr(output, nbits))
5126 __pyx_v_offset += __pyx_v_cwlen;
5128 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5130 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":592
5131 * #print "after buf: %s output: %s" \
5132 * # % (bincw(buf >> (8-offset), offset), binstr(output, nbits))
5133 * if offset > 0: # <<<<<<<<<<<<<<
5134 * # Append buf to output
5137 __pyx_t_5 = (__pyx_v_offset > 0);
5140 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":594
5142 * # Append buf to output
5143 * output[i] = buf # <<<<<<<<<<<<<<
5147 (__pyx_v_output[__pyx_v_i]) = __pyx_v_buf;
5149 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":595
5150 * # Append buf to output
5152 * nbits += offset # <<<<<<<<<<<<<<
5154 * #print "output:", binstr(output, nbits)
5156 __pyx_v_nbits += __pyx_v_offset;
5158 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":596
5161 * i += 1 # <<<<<<<<<<<<<<
5162 * #print "output:", binstr(output, nbits)
5163 * outstr = PyString_FromStringAndSize(output, nbytes)
5170 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":598
5172 * #print "output:", binstr(output, nbits)
5173 * outstr = PyString_FromStringAndSize(output, nbytes) # <<<<<<<<<<<<<<
5174 * PyMem_Free(output)
5175 * return (outstr, offset)
5177 __pyx_t_2 = PyString_FromStringAndSize(__pyx_v_output, __pyx_v_nbytes); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5178 __Pyx_GOTREF(__pyx_t_2);
5179 __Pyx_DECREF(__pyx_v_outstr);
5180 __pyx_v_outstr = __pyx_t_2;
5183 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":599
5184 * #print "output:", binstr(output, nbits)
5185 * outstr = PyString_FromStringAndSize(output, nbytes)
5186 * PyMem_Free(output) # <<<<<<<<<<<<<<
5187 * return (outstr, offset)
5190 PyMem_Free(__pyx_v_output);
5192 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":600
5193 * outstr = PyString_FromStringAndSize(output, nbytes)
5194 * PyMem_Free(output)
5195 * return (outstr, offset) # <<<<<<<<<<<<<<
5197 * def decode(self, data):
5199 __Pyx_XDECREF(__pyx_r);
5200 __pyx_t_2 = PyInt_FromLong(__pyx_v_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5201 __Pyx_GOTREF(__pyx_t_2);
5202 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5203 __Pyx_GOTREF(__pyx_t_3);
5204 __Pyx_INCREF(__pyx_v_outstr);
5205 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_outstr);
5206 __Pyx_GIVEREF(__pyx_v_outstr);
5207 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
5208 __Pyx_GIVEREF(__pyx_t_2);
5210 __pyx_r = __pyx_t_3;
5214 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5217 __Pyx_XDECREF(__pyx_t_2);
5218 __Pyx_XDECREF(__pyx_t_3);
5219 __Pyx_AddTraceback("sphinxbase.HuffCode.encode");
5222 __Pyx_DECREF(__pyx_v_sym);
5223 __Pyx_DECREF(__pyx_v_sss);
5224 __Pyx_DECREF(__pyx_v_outstr);
5225 __Pyx_DECREF((PyObject *)__pyx_v_self);
5226 __Pyx_DECREF(__pyx_v_seq);
5227 __Pyx_XGIVEREF(__pyx_r);
5228 __Pyx_RefNannyFinishContext();
5232 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":602
5233 * return (outstr, offset)
5235 * def decode(self, data): # <<<<<<<<<<<<<<
5237 * Decode a sequence of symbols from a string, returning the
5240 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_decode(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
5241 static char __pyx_doc_10sphinxbase_8HuffCode_decode[] = "\n Decode a sequence of symbols from a string, returning the\n sequence and the bit offset of the next codeword in the last\n byte (i.e. 8 minutes the number of remaining bits)\n ";
5242 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_decode(PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
5245 char *__pyx_v_strval;
5246 size_t __pyx_v_dlen;
5247 PyObject *__pyx_v_output;
5248 PyObject *__pyx_r = NULL;
5249 Py_ssize_t __pyx_t_1;
5251 PyObject *__pyx_t_3 = NULL;
5253 PyObject *__pyx_t_5 = NULL;
5254 __Pyx_RefNannySetupContext("decode");
5255 __Pyx_INCREF((PyObject *)__pyx_v_self);
5256 __Pyx_INCREF(__pyx_v_data);
5257 __pyx_v_output = Py_None; __Pyx_INCREF(Py_None);
5259 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":613
5262 * dlen = len(data) # <<<<<<<<<<<<<<
5266 __pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5267 __pyx_v_dlen = __pyx_t_1;
5269 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":614
5272 * offset = 0 # <<<<<<<<<<<<<<
5278 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":615
5281 * dptr = data # <<<<<<<<<<<<<<
5285 __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_data); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5286 __pyx_v_dptr = __pyx_t_2;
5288 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":616
5291 * output = [] # <<<<<<<<<<<<<<
5293 * strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5295 __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5296 __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5297 __Pyx_DECREF(__pyx_v_output);
5298 __pyx_v_output = ((PyObject *)__pyx_t_3);
5301 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":617
5304 * while True: # <<<<<<<<<<<<<<
5305 * strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5306 * if strval == NULL:
5310 if (!__pyx_t_4) break;
5312 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":618
5315 * strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset) # <<<<<<<<<<<<<<
5316 * if strval == NULL:
5319 __pyx_v_strval = huff_code_decode_str(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, (&__pyx_v_dptr), (&__pyx_v_dlen), (&__pyx_v_offset));
5321 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":619
5323 * strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5324 * if strval == NULL: # <<<<<<<<<<<<<<
5326 * output.append(strval)
5328 __pyx_t_4 = (__pyx_v_strval == NULL);
5331 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":620
5332 * strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5333 * if strval == NULL:
5334 * break # <<<<<<<<<<<<<<
5335 * output.append(strval)
5338 goto __pyx_L6_break;
5343 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":621
5344 * if strval == NULL:
5346 * output.append(strval) # <<<<<<<<<<<<<<
5348 * raise ValueError, "Invalid data at position %d" % (len(data) - dlen)
5350 __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_strval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5351 __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5352 __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_output, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5353 __Pyx_GOTREF(__pyx_t_5);
5354 __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
5355 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5359 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":622
5361 * output.append(strval)
5362 * if dlen > 1: # <<<<<<<<<<<<<<
5363 * raise ValueError, "Invalid data at position %d" % (len(data) - dlen)
5364 * return (output, offset)
5366 __pyx_t_4 = (__pyx_v_dlen > 1);
5369 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":623
5370 * output.append(strval)
5372 * raise ValueError, "Invalid data at position %d" % (len(data) - dlen) # <<<<<<<<<<<<<<
5373 * return (output, offset)
5376 __pyx_t_1 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5377 __pyx_t_5 = __Pyx_PyInt_FromSize_t((__pyx_t_1 - __pyx_v_dlen)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5378 __Pyx_GOTREF(__pyx_t_5);
5379 __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5380 __Pyx_GOTREF(__pyx_t_3);
5381 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5382 __Pyx_Raise(__pyx_builtin_ValueError, __pyx_t_3, 0);
5383 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5384 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5389 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":624
5391 * raise ValueError, "Invalid data at position %d" % (len(data) - dlen)
5392 * return (output, offset) # <<<<<<<<<<<<<<
5394 * def attach(self, fh, char *mode):
5396 __Pyx_XDECREF(__pyx_r);
5397 __pyx_t_3 = PyInt_FromLong(__pyx_v_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5398 __Pyx_GOTREF(__pyx_t_3);
5399 __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5400 __Pyx_GOTREF(__pyx_t_5);
5401 __Pyx_INCREF(__pyx_v_output);
5402 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_output);
5403 __Pyx_GIVEREF(__pyx_v_output);
5404 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
5405 __Pyx_GIVEREF(__pyx_t_3);
5407 __pyx_r = __pyx_t_5;
5411 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5414 __Pyx_XDECREF(__pyx_t_3);
5415 __Pyx_XDECREF(__pyx_t_5);
5416 __Pyx_AddTraceback("sphinxbase.HuffCode.decode");
5419 __Pyx_DECREF(__pyx_v_output);
5420 __Pyx_DECREF((PyObject *)__pyx_v_self);
5421 __Pyx_DECREF(__pyx_v_data);
5422 __Pyx_XGIVEREF(__pyx_r);
5423 __Pyx_RefNannyFinishContext();
5427 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":626
5428 * return (output, offset)
5430 * def attach(self, fh, char *mode): # <<<<<<<<<<<<<<
5431 * if not isinstance(fh, file):
5432 * fh = file(fh, mode)
5435 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_attach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5436 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_attach(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5437 PyObject *__pyx_v_fh = 0;
5439 PyObject *__pyx_r = NULL;
5442 PyObject *__pyx_t_3 = NULL;
5443 PyObject *__pyx_t_4 = NULL;
5444 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fh,&__pyx_n_s__mode,0};
5445 __Pyx_RefNannySetupContext("attach");
5446 if (unlikely(__pyx_kwds)) {
5447 Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
5448 PyObject* values[2] = {0,0};
5449 switch (PyTuple_GET_SIZE(__pyx_args)) {
5450 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5451 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5453 default: goto __pyx_L5_argtuple_error;
5455 switch (PyTuple_GET_SIZE(__pyx_args)) {
5457 values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fh);
5458 if (likely(values[0])) kw_args--;
5459 else goto __pyx_L5_argtuple_error;
5461 values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode);
5462 if (likely(values[1])) kw_args--;
5464 __Pyx_RaiseArgtupleInvalid("attach", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5467 if (unlikely(kw_args > 0)) {
5468 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "attach") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5470 __pyx_v_fh = values[0];
5471 __pyx_v_mode = __Pyx_PyBytes_AsString(values[1]); if (unlikely((!__pyx_v_mode) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5472 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5473 goto __pyx_L5_argtuple_error;
5475 __pyx_v_fh = PyTuple_GET_ITEM(__pyx_args, 0);
5476 __pyx_v_mode = __Pyx_PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((!__pyx_v_mode) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5478 goto __pyx_L4_argument_unpacking_done;
5479 __pyx_L5_argtuple_error:;
5480 __Pyx_RaiseArgtupleInvalid("attach", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5482 __Pyx_AddTraceback("sphinxbase.HuffCode.attach");
5484 __pyx_L4_argument_unpacking_done:;
5485 __Pyx_INCREF((PyObject *)__pyx_v_self);
5486 __Pyx_INCREF(__pyx_v_fh);
5488 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":627
5490 * def attach(self, fh, char *mode):
5491 * if not isinstance(fh, file): # <<<<<<<<<<<<<<
5492 * fh = file(fh, mode)
5495 __pyx_t_1 = PyObject_TypeCheck(__pyx_v_fh, ((PyTypeObject *)((PyObject*)&PyFile_Type)));
5496 __pyx_t_2 = (!__pyx_t_1);
5499 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":628
5500 * def attach(self, fh, char *mode):
5501 * if not isinstance(fh, file):
5502 * fh = file(fh, mode) # <<<<<<<<<<<<<<
5504 * huff_code_attach(self.hc, PyFile_AsFile(fh), mode)
5506 __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5507 __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5508 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5509 __Pyx_GOTREF(__pyx_t_4);
5510 __Pyx_INCREF(__pyx_v_fh);
5511 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fh);
5512 __Pyx_GIVEREF(__pyx_v_fh);
5513 PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_3));
5514 __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
5516 __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)&PyFile_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5517 __Pyx_GOTREF(__pyx_t_3);
5518 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5519 __Pyx_DECREF(__pyx_v_fh);
5520 __pyx_v_fh = __pyx_t_3;
5526 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":629
5527 * if not isinstance(fh, file):
5528 * fh = file(fh, mode)
5529 * self.fh = fh # <<<<<<<<<<<<<<
5530 * huff_code_attach(self.hc, PyFile_AsFile(fh), mode)
5533 __Pyx_INCREF(__pyx_v_fh);
5534 __Pyx_GIVEREF(__pyx_v_fh);
5535 __Pyx_GOTREF(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh);
5536 __Pyx_DECREF(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh);
5537 ((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh = __pyx_v_fh;
5539 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":630
5540 * fh = file(fh, mode)
5542 * huff_code_attach(self.hc, PyFile_AsFile(fh), mode) # <<<<<<<<<<<<<<
5546 huff_code_attach(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, PyFile_AsFile(__pyx_v_fh), __pyx_v_mode);
5548 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5551 __Pyx_XDECREF(__pyx_t_3);
5552 __Pyx_XDECREF(__pyx_t_4);
5553 __Pyx_AddTraceback("sphinxbase.HuffCode.attach");
5556 __Pyx_DECREF((PyObject *)__pyx_v_self);
5557 __Pyx_DECREF(__pyx_v_fh);
5558 __Pyx_XGIVEREF(__pyx_r);
5559 __Pyx_RefNannyFinishContext();
5563 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":632
5564 * huff_code_attach(self.hc, PyFile_AsFile(fh), mode)
5566 * def detach(self): # <<<<<<<<<<<<<<
5567 * huff_code_detach(self.hc)
5571 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_detach(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
5572 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_detach(PyObject *__pyx_v_self, PyObject *unused) {
5573 PyObject *__pyx_r = NULL;
5574 __Pyx_RefNannySetupContext("detach");
5576 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":633
5579 * huff_code_detach(self.hc) # <<<<<<<<<<<<<<
5583 huff_code_detach(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc);
5585 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":634
5587 * huff_code_detach(self.hc)
5588 * self.fh = None # <<<<<<<<<<<<<<
5590 * def encode_to_file(self, seq):
5592 __Pyx_INCREF(Py_None);
5593 __Pyx_GIVEREF(Py_None);
5594 __Pyx_GOTREF(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh);
5595 __Pyx_DECREF(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh);
5596 ((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh = Py_None;
5598 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5599 __Pyx_XGIVEREF(__pyx_r);
5600 __Pyx_RefNannyFinishContext();
5604 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":636
5607 * def encode_to_file(self, seq): # <<<<<<<<<<<<<<
5608 * if self.fh == None:
5609 * raise RuntimeError, "No file is attached"
5612 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_encode_to_file(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
5613 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_encode_to_file(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
5614 PyObject *__pyx_v_sym;
5615 PyObject *__pyx_v_strsym;
5616 PyObject *__pyx_r = NULL;
5617 PyObject *__pyx_t_1 = NULL;
5619 Py_ssize_t __pyx_t_3;
5620 PyObject *__pyx_t_4 = NULL;
5622 __Pyx_RefNannySetupContext("encode_to_file");
5623 __Pyx_INCREF((PyObject *)__pyx_v_self);
5624 __Pyx_INCREF(__pyx_v_seq);
5625 __pyx_v_sym = Py_None; __Pyx_INCREF(Py_None);
5626 __pyx_v_strsym = Py_None; __Pyx_INCREF(Py_None);
5628 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":637
5630 * def encode_to_file(self, seq):
5631 * if self.fh == None: # <<<<<<<<<<<<<<
5632 * raise RuntimeError, "No file is attached"
5635 __pyx_t_1 = PyObject_RichCompare(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5636 __Pyx_GOTREF(__pyx_t_1);
5637 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5638 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5641 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":638
5642 * def encode_to_file(self, seq):
5643 * if self.fh == None:
5644 * raise RuntimeError, "No file is attached" # <<<<<<<<<<<<<<
5646 * strsym = repr(sym)
5648 __Pyx_Raise(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_kp_s_19), 0);
5649 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5654 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":639
5655 * if self.fh == None:
5656 * raise RuntimeError, "No file is attached"
5657 * for sym in seq: # <<<<<<<<<<<<<<
5658 * strsym = repr(sym)
5659 * huff_code_encode_str(self.hc, strsym, NULL)
5661 if (PyList_CheckExact(__pyx_v_seq) || PyTuple_CheckExact(__pyx_v_seq)) {
5662 __pyx_t_3 = 0; __pyx_t_1 = __pyx_v_seq; __Pyx_INCREF(__pyx_t_1);
5664 __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_seq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5665 __Pyx_GOTREF(__pyx_t_1);
5668 if (likely(PyList_CheckExact(__pyx_t_1))) {
5669 if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
5670 __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
5671 } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
5672 if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
5673 __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_4); __pyx_t_3++;
5675 __pyx_t_4 = PyIter_Next(__pyx_t_1);
5677 if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5680 __Pyx_GOTREF(__pyx_t_4);
5682 __Pyx_DECREF(__pyx_v_sym);
5683 __pyx_v_sym = __pyx_t_4;
5686 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":640
5687 * raise RuntimeError, "No file is attached"
5689 * strsym = repr(sym) # <<<<<<<<<<<<<<
5690 * huff_code_encode_str(self.hc, strsym, NULL)
5693 __pyx_t_4 = PyObject_Repr(__pyx_v_sym); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5694 __Pyx_GOTREF(__pyx_t_4);
5695 __Pyx_DECREF(__pyx_v_strsym);
5696 __pyx_v_strsym = __pyx_t_4;
5699 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":641
5701 * strsym = repr(sym)
5702 * huff_code_encode_str(self.hc, strsym, NULL) # <<<<<<<<<<<<<<
5704 * def decode_from_file(self):
5706 __pyx_t_5 = __Pyx_PyBytes_AsString(__pyx_v_strsym); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5707 huff_code_encode_str(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, __pyx_t_5, NULL);
5709 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5711 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5714 __Pyx_XDECREF(__pyx_t_1);
5715 __Pyx_XDECREF(__pyx_t_4);
5716 __Pyx_AddTraceback("sphinxbase.HuffCode.encode_to_file");
5719 __Pyx_DECREF(__pyx_v_sym);
5720 __Pyx_DECREF(__pyx_v_strsym);
5721 __Pyx_DECREF((PyObject *)__pyx_v_self);
5722 __Pyx_DECREF(__pyx_v_seq);
5723 __Pyx_XGIVEREF(__pyx_r);
5724 __Pyx_RefNannyFinishContext();
5728 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":643
5729 * huff_code_encode_str(self.hc, strsym, NULL)
5731 * def decode_from_file(self): # <<<<<<<<<<<<<<
5733 * if self.fh == None:
5736 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_decode_from_file(PyObject *__pyx_v_self, PyObject *unused); /*proto*/
5737 static PyObject *__pyx_pf_10sphinxbase_8HuffCode_decode_from_file(PyObject *__pyx_v_self, PyObject *unused) {
5739 PyObject *__pyx_r = NULL;
5740 PyObject *__pyx_t_1 = NULL;
5742 __Pyx_RefNannySetupContext("decode_from_file");
5743 __Pyx_INCREF((PyObject *)__pyx_v_self);
5745 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":645
5746 * def decode_from_file(self):
5748 * if self.fh == None: # <<<<<<<<<<<<<<
5749 * raise RuntimeError, "No file is attached"
5750 * sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5752 __pyx_t_1 = PyObject_RichCompare(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5753 __Pyx_GOTREF(__pyx_t_1);
5754 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5755 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5758 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":646
5760 * if self.fh == None:
5761 * raise RuntimeError, "No file is attached" # <<<<<<<<<<<<<<
5762 * sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5765 __Pyx_Raise(__pyx_builtin_RuntimeError, ((PyObject *)__pyx_kp_s_19), 0);
5766 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5771 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":647
5772 * if self.fh == None:
5773 * raise RuntimeError, "No file is attached"
5774 * sym = huff_code_decode_str(self.hc, NULL, NULL, NULL) # <<<<<<<<<<<<<<
5778 __pyx_v_sym = huff_code_decode_str(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, NULL, NULL, NULL);
5780 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":648
5781 * raise RuntimeError, "No file is attached"
5782 * sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5783 * if sym == NULL: # <<<<<<<<<<<<<<
5787 __pyx_t_2 = (__pyx_v_sym == NULL);
5790 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":649
5791 * sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5793 * return None # <<<<<<<<<<<<<<
5797 __Pyx_XDECREF(__pyx_r);
5798 __Pyx_INCREF(Py_None);
5805 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":651
5808 * return sym # <<<<<<<<<<<<<<
5810 * def __dealloc__(self):
5812 __Pyx_XDECREF(__pyx_r);
5813 __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_sym); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5814 __Pyx_GOTREF(((PyObject *)__pyx_t_1));
5815 __pyx_r = ((PyObject *)__pyx_t_1);
5821 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5824 __Pyx_XDECREF(__pyx_t_1);
5825 __Pyx_AddTraceback("sphinxbase.HuffCode.decode_from_file");
5828 __Pyx_DECREF((PyObject *)__pyx_v_self);
5829 __Pyx_XGIVEREF(__pyx_r);
5830 __Pyx_RefNannyFinishContext();
5834 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":653
5837 * def __dealloc__(self): # <<<<<<<<<<<<<<
5842 static void __pyx_pf_10sphinxbase_8HuffCode___dealloc__(PyObject *__pyx_v_self); /*proto*/
5843 static void __pyx_pf_10sphinxbase_8HuffCode___dealloc__(PyObject *__pyx_v_self) {
5845 PyObject *__pyx_t_2 = NULL;
5846 PyObject *__pyx_t_3 = NULL;
5847 __Pyx_RefNannySetupContext("__dealloc__");
5848 __Pyx_INCREF((PyObject *)__pyx_v_self);
5850 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":654
5852 * def __dealloc__(self):
5853 * if self.fh: # <<<<<<<<<<<<<<
5855 * huff_code_free(self.hc)
5857 __pyx_t_1 = __Pyx_PyObject_IsTrue(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->fh); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5860 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":655
5861 * def __dealloc__(self):
5863 * self.detach() # <<<<<<<<<<<<<<
5864 * huff_code_free(self.hc)
5866 __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__detach); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5867 __Pyx_GOTREF(__pyx_t_2);
5868 __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5869 __Pyx_GOTREF(__pyx_t_3);
5870 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5871 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5876 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":656
5879 * huff_code_free(self.hc) # <<<<<<<<<<<<<<
5881 huff_code_free(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc);
5885 __Pyx_XDECREF(__pyx_t_2);
5886 __Pyx_XDECREF(__pyx_t_3);
5887 __Pyx_AddTraceback("sphinxbase.HuffCode.__dealloc__");
5889 __Pyx_DECREF((PyObject *)__pyx_v_self);
5890 __Pyx_RefNannyFinishContext();
5892 static struct __pyx_vtabstruct_10sphinxbase_NGramModel __pyx_vtable_10sphinxbase_NGramModel;
5894 static PyObject *__pyx_tp_new_10sphinxbase_NGramModel(PyTypeObject *t, PyObject *a, PyObject *k) {
5895 struct __pyx_obj_10sphinxbase_NGramModel *p;
5896 PyObject *o = (*t->tp_alloc)(t, 0);
5898 p = ((struct __pyx_obj_10sphinxbase_NGramModel *)o);
5899 p->__pyx_vtab = __pyx_vtabptr_10sphinxbase_NGramModel;
5903 static void __pyx_tp_dealloc_10sphinxbase_NGramModel(PyObject *o) {
5905 PyObject *etype, *eval, *etb;
5906 PyErr_Fetch(&etype, &eval, &etb);
5908 __pyx_pf_10sphinxbase_10NGramModel___dealloc__(o);
5909 if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
5911 PyErr_Restore(etype, eval, etb);
5913 (*Py_TYPE(o)->tp_free)(o);
5916 static struct PyMethodDef __pyx_methods_10sphinxbase_NGramModel[] = {
5917 {__Pyx_NAMESTR("apply_weights"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_apply_weights, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_apply_weights)},
5918 {__Pyx_NAMESTR("get_size"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_get_size, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_get_size)},
5919 {__Pyx_NAMESTR("get_counts"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_get_counts, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_get_counts)},
5920 {__Pyx_NAMESTR("unknown_wid"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_unknown_wid, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_unknown_wid)},
5921 {__Pyx_NAMESTR("zero"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_zero, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_zero)},
5922 {__Pyx_NAMESTR("wid"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_wid, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_wid)},
5923 {__Pyx_NAMESTR("word"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_word, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_word)},
5924 {__Pyx_NAMESTR("score"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_score, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_score)},
5925 {__Pyx_NAMESTR("prob"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_prob, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_prob)},
5926 {__Pyx_NAMESTR("mgrams"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_mgrams, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_mgrams)},
5927 {__Pyx_NAMESTR("ngram"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_ngram, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_10NGramModel_ngram)},
5928 {__Pyx_NAMESTR("add_word"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_add_word, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
5929 {__Pyx_NAMESTR("recode"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_recode, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
5930 {__Pyx_NAMESTR("casefold"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_casefold, METH_O, __Pyx_DOCSTR(0)},
5931 {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_10sphinxbase_10NGramModel_write, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
5935 static struct PyMemberDef __pyx_members_10sphinxbase_NGramModel[] = {
5936 {(char *)"lw", T_FLOAT, offsetof(struct __pyx_obj_10sphinxbase_NGramModel, lw), READONLY, 0},
5937 {(char *)"wip", T_FLOAT, offsetof(struct __pyx_obj_10sphinxbase_NGramModel, wip), READONLY, 0},
5938 {(char *)"uw", T_FLOAT, offsetof(struct __pyx_obj_10sphinxbase_NGramModel, uw), READONLY, 0},
5942 static PyNumberMethods __pyx_tp_as_number_NGramModel = {
5946 #if PY_MAJOR_VERSION < 3
5962 #if PY_MAJOR_VERSION < 3
5966 #if PY_MAJOR_VERSION >= 3
5972 #if PY_MAJOR_VERSION < 3
5975 #if PY_MAJOR_VERSION < 3
5978 0, /*nb_inplace_add*/
5979 0, /*nb_inplace_subtract*/
5980 0, /*nb_inplace_multiply*/
5981 #if PY_MAJOR_VERSION < 3
5982 0, /*nb_inplace_divide*/
5984 0, /*nb_inplace_remainder*/
5985 0, /*nb_inplace_power*/
5986 0, /*nb_inplace_lshift*/
5987 0, /*nb_inplace_rshift*/
5988 0, /*nb_inplace_and*/
5989 0, /*nb_inplace_xor*/
5990 0, /*nb_inplace_or*/
5991 0, /*nb_floor_divide*/
5992 0, /*nb_true_divide*/
5993 0, /*nb_inplace_floor_divide*/
5994 0, /*nb_inplace_true_divide*/
5995 #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
6000 static PySequenceMethods __pyx_tp_as_sequence_NGramModel = {
6009 0, /*sq_inplace_concat*/
6010 0, /*sq_inplace_repeat*/
6013 static PyMappingMethods __pyx_tp_as_mapping_NGramModel = {
6016 0, /*mp_ass_subscript*/
6019 static PyBufferProcs __pyx_tp_as_buffer_NGramModel = {
6020 #if PY_MAJOR_VERSION < 3
6021 0, /*bf_getreadbuffer*/
6023 #if PY_MAJOR_VERSION < 3
6024 0, /*bf_getwritebuffer*/
6026 #if PY_MAJOR_VERSION < 3
6027 0, /*bf_getsegcount*/
6029 #if PY_MAJOR_VERSION < 3
6030 0, /*bf_getcharbuffer*/
6032 #if PY_VERSION_HEX >= 0x02060000
6035 #if PY_VERSION_HEX >= 0x02060000
6036 0, /*bf_releasebuffer*/
6040 PyTypeObject __pyx_type_10sphinxbase_NGramModel = {
6041 PyVarObject_HEAD_INIT(0, 0)
6042 __Pyx_NAMESTR("sphinxbase.NGramModel"), /*tp_name*/
6043 sizeof(struct __pyx_obj_10sphinxbase_NGramModel), /*tp_basicsize*/
6045 __pyx_tp_dealloc_10sphinxbase_NGramModel, /*tp_dealloc*/
6051 &__pyx_tp_as_number_NGramModel, /*tp_as_number*/
6052 &__pyx_tp_as_sequence_NGramModel, /*tp_as_sequence*/
6053 &__pyx_tp_as_mapping_NGramModel, /*tp_as_mapping*/
6059 &__pyx_tp_as_buffer_NGramModel, /*tp_as_buffer*/
6060 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6061 __Pyx_DOCSTR("\n N-Gram language model class.\n\n This class provides access to N-Gram language models stored on\n disk. These can be in ARPABO text format or Sphinx DMP format.\n Methods are provided for scoring N-Grams based on the model\n and looking up words in the model.\n\n @param file: Path to an N-Gram model file.\n @type file: string\n @param lw: Language weight to apply to model probabilities.\n @type lw: float\n @param wip: Word insertion penalty to add to model probabilities\n @type wip: float\n @param uw: Weight to give unigrams when interpolating with uniform distribution.\n @type uw: float\n "), /*tp_doc*/
6064 0, /*tp_richcompare*/
6065 0, /*tp_weaklistoffset*/
6068 __pyx_methods_10sphinxbase_NGramModel, /*tp_methods*/
6069 __pyx_members_10sphinxbase_NGramModel, /*tp_members*/
6075 0, /*tp_dictoffset*/
6076 __pyx_pf_10sphinxbase_10NGramModel___init__, /*tp_init*/
6078 __pyx_tp_new_10sphinxbase_NGramModel, /*tp_new*/
6084 0, /*tp_subclasses*/
6087 #if PY_VERSION_HEX >= 0x02060000
6088 0, /*tp_version_tag*/
6092 static PyObject *__pyx_tp_new_10sphinxbase_LogMath(PyTypeObject *t, PyObject *a, PyObject *k) {
6093 PyObject *o = (*t->tp_alloc)(t, 0);
6098 static void __pyx_tp_dealloc_10sphinxbase_LogMath(PyObject *o) {
6100 PyObject *etype, *eval, *etb;
6101 PyErr_Fetch(&etype, &eval, &etb);
6103 __pyx_pf_10sphinxbase_7LogMath___dealloc__(o);
6104 if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
6106 PyErr_Restore(etype, eval, etb);
6108 (*Py_TYPE(o)->tp_free)(o);
6111 static struct PyMethodDef __pyx_methods_10sphinxbase_LogMath[] = {
6112 {__Pyx_NAMESTR("get_zero"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_get_zero, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_get_zero)},
6113 {__Pyx_NAMESTR("add"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_add, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_add)},
6114 {__Pyx_NAMESTR("log"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_log, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_log)},
6115 {__Pyx_NAMESTR("exp"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_exp, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_exp)},
6116 {__Pyx_NAMESTR("log_to_ln"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_log_to_ln, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_log_to_ln)},
6117 {__Pyx_NAMESTR("log_to_log10"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_log_to_log10, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_log_to_log10)},
6118 {__Pyx_NAMESTR("ln_to_log"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_ln_to_log, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_ln_to_log)},
6119 {__Pyx_NAMESTR("log10_to_log"), (PyCFunction)__pyx_pf_10sphinxbase_7LogMath_log10_to_log, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_7LogMath_log10_to_log)},
6123 static PyNumberMethods __pyx_tp_as_number_LogMath = {
6127 #if PY_MAJOR_VERSION < 3
6143 #if PY_MAJOR_VERSION < 3
6147 #if PY_MAJOR_VERSION >= 3
6153 #if PY_MAJOR_VERSION < 3
6156 #if PY_MAJOR_VERSION < 3
6159 0, /*nb_inplace_add*/
6160 0, /*nb_inplace_subtract*/
6161 0, /*nb_inplace_multiply*/
6162 #if PY_MAJOR_VERSION < 3
6163 0, /*nb_inplace_divide*/
6165 0, /*nb_inplace_remainder*/
6166 0, /*nb_inplace_power*/
6167 0, /*nb_inplace_lshift*/
6168 0, /*nb_inplace_rshift*/
6169 0, /*nb_inplace_and*/
6170 0, /*nb_inplace_xor*/
6171 0, /*nb_inplace_or*/
6172 0, /*nb_floor_divide*/
6173 0, /*nb_true_divide*/
6174 0, /*nb_inplace_floor_divide*/
6175 0, /*nb_inplace_true_divide*/
6176 #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
6181 static PySequenceMethods __pyx_tp_as_sequence_LogMath = {
6190 0, /*sq_inplace_concat*/
6191 0, /*sq_inplace_repeat*/
6194 static PyMappingMethods __pyx_tp_as_mapping_LogMath = {
6197 0, /*mp_ass_subscript*/
6200 static PyBufferProcs __pyx_tp_as_buffer_LogMath = {
6201 #if PY_MAJOR_VERSION < 3
6202 0, /*bf_getreadbuffer*/
6204 #if PY_MAJOR_VERSION < 3
6205 0, /*bf_getwritebuffer*/
6207 #if PY_MAJOR_VERSION < 3
6208 0, /*bf_getsegcount*/
6210 #if PY_MAJOR_VERSION < 3
6211 0, /*bf_getcharbuffer*/
6213 #if PY_VERSION_HEX >= 0x02060000
6216 #if PY_VERSION_HEX >= 0x02060000
6217 0, /*bf_releasebuffer*/
6221 PyTypeObject __pyx_type_10sphinxbase_LogMath = {
6222 PyVarObject_HEAD_INIT(0, 0)
6223 __Pyx_NAMESTR("sphinxbase.LogMath"), /*tp_name*/
6224 sizeof(struct __pyx_obj_10sphinxbase_LogMath), /*tp_basicsize*/
6226 __pyx_tp_dealloc_10sphinxbase_LogMath, /*tp_dealloc*/
6232 &__pyx_tp_as_number_LogMath, /*tp_as_number*/
6233 &__pyx_tp_as_sequence_LogMath, /*tp_as_sequence*/
6234 &__pyx_tp_as_mapping_LogMath, /*tp_as_mapping*/
6240 &__pyx_tp_as_buffer_LogMath, /*tp_as_buffer*/
6241 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6242 __Pyx_DOCSTR("\n Log-space math class.\n \n This class provides fast logarithmic math functions in base\n 1.000+epsilon, useful for fixed point speech recognition.\n\n @param base: The base B in which computation is to be done.\n @type base: float\n @param shift: Log values are shifted right by this many bits.\n @type shift: int\n @param use_table Whether to use an add table or not\n @type use_table: bool\n "), /*tp_doc*/
6245 0, /*tp_richcompare*/
6246 0, /*tp_weaklistoffset*/
6249 __pyx_methods_10sphinxbase_LogMath, /*tp_methods*/
6256 0, /*tp_dictoffset*/
6257 __pyx_pf_10sphinxbase_7LogMath___init__, /*tp_init*/
6259 __pyx_tp_new_10sphinxbase_LogMath, /*tp_new*/
6265 0, /*tp_subclasses*/
6268 #if PY_VERSION_HEX >= 0x02060000
6269 0, /*tp_version_tag*/
6272 static struct __pyx_vtabstruct_10sphinxbase_NGramIter __pyx_vtable_10sphinxbase_NGramIter;
6274 static PyObject *__pyx_tp_new_10sphinxbase_NGramIter(PyTypeObject *t, PyObject *a, PyObject *k) {
6275 struct __pyx_obj_10sphinxbase_NGramIter *p;
6276 PyObject *o = (*t->tp_alloc)(t, 0);
6278 p = ((struct __pyx_obj_10sphinxbase_NGramIter *)o);
6279 p->__pyx_vtab = __pyx_vtabptr_10sphinxbase_NGramIter;
6280 p->lm = ((struct __pyx_obj_10sphinxbase_NGramModel *)Py_None); Py_INCREF(Py_None);
6281 p->words = Py_None; Py_INCREF(Py_None);
6282 if (__pyx_pf_10sphinxbase_9NGramIter___cinit__(o, a, k) < 0) {
6283 Py_DECREF(o); o = 0;
6288 static void __pyx_tp_dealloc_10sphinxbase_NGramIter(PyObject *o) {
6289 struct __pyx_obj_10sphinxbase_NGramIter *p = (struct __pyx_obj_10sphinxbase_NGramIter *)o;
6290 Py_XDECREF(((PyObject *)p->lm));
6291 Py_XDECREF(p->words);
6292 (*Py_TYPE(o)->tp_free)(o);
6295 static int __pyx_tp_traverse_10sphinxbase_NGramIter(PyObject *o, visitproc v, void *a) {
6297 struct __pyx_obj_10sphinxbase_NGramIter *p = (struct __pyx_obj_10sphinxbase_NGramIter *)o;
6299 e = (*v)(((PyObject*)p->lm), a); if (e) return e;
6302 e = (*v)(p->words, a); if (e) return e;
6307 static int __pyx_tp_clear_10sphinxbase_NGramIter(PyObject *o) {
6308 struct __pyx_obj_10sphinxbase_NGramIter *p = (struct __pyx_obj_10sphinxbase_NGramIter *)o;
6310 tmp = ((PyObject*)p->lm);
6311 p->lm = ((struct __pyx_obj_10sphinxbase_NGramModel *)Py_None); Py_INCREF(Py_None);
6313 tmp = ((PyObject*)p->words);
6314 p->words = Py_None; Py_INCREF(Py_None);
6319 static struct PyMethodDef __pyx_methods_10sphinxbase_NGramIter[] = {
6320 {__Pyx_NAMESTR("__iter__"), (PyCFunction)__pyx_pf_10sphinxbase_9NGramIter___iter__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
6321 {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_10sphinxbase_9NGramIter___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(0)},
6322 {__Pyx_NAMESTR("successors"), (PyCFunction)__pyx_pf_10sphinxbase_9NGramIter_successors, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_9NGramIter_successors)},
6326 static struct PyMemberDef __pyx_members_10sphinxbase_NGramIter[] = {
6327 {(char *)"log_prob", T_FLOAT, offsetof(struct __pyx_obj_10sphinxbase_NGramIter, log_prob), READONLY, 0},
6328 {(char *)"log_bowt", T_FLOAT, offsetof(struct __pyx_obj_10sphinxbase_NGramIter, log_bowt), READONLY, 0},
6329 {(char *)"words", T_OBJECT, offsetof(struct __pyx_obj_10sphinxbase_NGramIter, words), READONLY, 0},
6333 static PyNumberMethods __pyx_tp_as_number_NGramIter = {
6337 #if PY_MAJOR_VERSION < 3
6353 #if PY_MAJOR_VERSION < 3
6357 #if PY_MAJOR_VERSION >= 3
6363 #if PY_MAJOR_VERSION < 3
6366 #if PY_MAJOR_VERSION < 3
6369 0, /*nb_inplace_add*/
6370 0, /*nb_inplace_subtract*/
6371 0, /*nb_inplace_multiply*/
6372 #if PY_MAJOR_VERSION < 3
6373 0, /*nb_inplace_divide*/
6375 0, /*nb_inplace_remainder*/
6376 0, /*nb_inplace_power*/
6377 0, /*nb_inplace_lshift*/
6378 0, /*nb_inplace_rshift*/
6379 0, /*nb_inplace_and*/
6380 0, /*nb_inplace_xor*/
6381 0, /*nb_inplace_or*/
6382 0, /*nb_floor_divide*/
6383 0, /*nb_true_divide*/
6384 0, /*nb_inplace_floor_divide*/
6385 0, /*nb_inplace_true_divide*/
6386 #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
6391 static PySequenceMethods __pyx_tp_as_sequence_NGramIter = {
6400 0, /*sq_inplace_concat*/
6401 0, /*sq_inplace_repeat*/
6404 static PyMappingMethods __pyx_tp_as_mapping_NGramIter = {
6407 0, /*mp_ass_subscript*/
6410 static PyBufferProcs __pyx_tp_as_buffer_NGramIter = {
6411 #if PY_MAJOR_VERSION < 3
6412 0, /*bf_getreadbuffer*/
6414 #if PY_MAJOR_VERSION < 3
6415 0, /*bf_getwritebuffer*/
6417 #if PY_MAJOR_VERSION < 3
6418 0, /*bf_getsegcount*/
6420 #if PY_MAJOR_VERSION < 3
6421 0, /*bf_getcharbuffer*/
6423 #if PY_VERSION_HEX >= 0x02060000
6426 #if PY_VERSION_HEX >= 0x02060000
6427 0, /*bf_releasebuffer*/
6431 PyTypeObject __pyx_type_10sphinxbase_NGramIter = {
6432 PyVarObject_HEAD_INIT(0, 0)
6433 __Pyx_NAMESTR("sphinxbase.NGramIter"), /*tp_name*/
6434 sizeof(struct __pyx_obj_10sphinxbase_NGramIter), /*tp_basicsize*/
6436 __pyx_tp_dealloc_10sphinxbase_NGramIter, /*tp_dealloc*/
6442 &__pyx_tp_as_number_NGramIter, /*tp_as_number*/
6443 &__pyx_tp_as_sequence_NGramIter, /*tp_as_sequence*/
6444 &__pyx_tp_as_mapping_NGramIter, /*tp_as_mapping*/
6450 &__pyx_tp_as_buffer_NGramIter, /*tp_as_buffer*/
6451 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
6452 __Pyx_DOCSTR("\n N-Gram language model iterator class.\n\n This class provides access to the individual N-grams stored in a\n language model.\n "), /*tp_doc*/
6453 __pyx_tp_traverse_10sphinxbase_NGramIter, /*tp_traverse*/
6454 __pyx_tp_clear_10sphinxbase_NGramIter, /*tp_clear*/
6455 0, /*tp_richcompare*/
6456 0, /*tp_weaklistoffset*/
6457 __pyx_pf_10sphinxbase_9NGramIter___iter__, /*tp_iter*/
6458 __pyx_pf_10sphinxbase_9NGramIter___next__, /*tp_iternext*/
6459 __pyx_methods_10sphinxbase_NGramIter, /*tp_methods*/
6460 __pyx_members_10sphinxbase_NGramIter, /*tp_members*/
6466 0, /*tp_dictoffset*/
6469 __pyx_tp_new_10sphinxbase_NGramIter, /*tp_new*/
6475 0, /*tp_subclasses*/
6478 #if PY_VERSION_HEX >= 0x02060000
6479 0, /*tp_version_tag*/
6483 static PyObject *__pyx_tp_new_10sphinxbase_HuffCode(PyTypeObject *t, PyObject *a, PyObject *k) {
6484 struct __pyx_obj_10sphinxbase_HuffCode *p;
6485 PyObject *o = (*t->tp_alloc)(t, 0);
6487 p = ((struct __pyx_obj_10sphinxbase_HuffCode *)o);
6488 p->fh = Py_None; Py_INCREF(Py_None);
6492 static void __pyx_tp_dealloc_10sphinxbase_HuffCode(PyObject *o) {
6493 struct __pyx_obj_10sphinxbase_HuffCode *p = (struct __pyx_obj_10sphinxbase_HuffCode *)o;
6495 PyObject *etype, *eval, *etb;
6496 PyErr_Fetch(&etype, &eval, &etb);
6498 __pyx_pf_10sphinxbase_8HuffCode___dealloc__(o);
6499 if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
6501 PyErr_Restore(etype, eval, etb);
6504 (*Py_TYPE(o)->tp_free)(o);
6507 static int __pyx_tp_traverse_10sphinxbase_HuffCode(PyObject *o, visitproc v, void *a) {
6509 struct __pyx_obj_10sphinxbase_HuffCode *p = (struct __pyx_obj_10sphinxbase_HuffCode *)o;
6511 e = (*v)(p->fh, a); if (e) return e;
6516 static int __pyx_tp_clear_10sphinxbase_HuffCode(PyObject *o) {
6517 struct __pyx_obj_10sphinxbase_HuffCode *p = (struct __pyx_obj_10sphinxbase_HuffCode *)o;
6519 tmp = ((PyObject*)p->fh);
6520 p->fh = Py_None; Py_INCREF(Py_None);
6525 static struct PyMethodDef __pyx_methods_10sphinxbase_HuffCode[] = {
6526 {__Pyx_NAMESTR("read"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_read, METH_O, __Pyx_DOCSTR(0)},
6527 {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_write, METH_O, __Pyx_DOCSTR(0)},
6528 {__Pyx_NAMESTR("dump"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_dump, METH_O, __Pyx_DOCSTR(0)},
6529 {__Pyx_NAMESTR("encode"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_encode, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_8HuffCode_encode)},
6530 {__Pyx_NAMESTR("decode"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_decode, METH_O, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_8HuffCode_decode)},
6531 {__Pyx_NAMESTR("attach"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_attach, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(0)},
6532 {__Pyx_NAMESTR("detach"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_detach, METH_NOARGS, __Pyx_DOCSTR(0)},
6533 {__Pyx_NAMESTR("encode_to_file"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_encode_to_file, METH_O, __Pyx_DOCSTR(0)},
6534 {__Pyx_NAMESTR("decode_from_file"), (PyCFunction)__pyx_pf_10sphinxbase_8HuffCode_decode_from_file, METH_NOARGS, __Pyx_DOCSTR(0)},
6538 static PyNumberMethods __pyx_tp_as_number_HuffCode = {
6542 #if PY_MAJOR_VERSION < 3
6558 #if PY_MAJOR_VERSION < 3
6562 #if PY_MAJOR_VERSION >= 3
6568 #if PY_MAJOR_VERSION < 3
6571 #if PY_MAJOR_VERSION < 3
6574 0, /*nb_inplace_add*/
6575 0, /*nb_inplace_subtract*/
6576 0, /*nb_inplace_multiply*/
6577 #if PY_MAJOR_VERSION < 3
6578 0, /*nb_inplace_divide*/
6580 0, /*nb_inplace_remainder*/
6581 0, /*nb_inplace_power*/
6582 0, /*nb_inplace_lshift*/
6583 0, /*nb_inplace_rshift*/
6584 0, /*nb_inplace_and*/
6585 0, /*nb_inplace_xor*/
6586 0, /*nb_inplace_or*/
6587 0, /*nb_floor_divide*/
6588 0, /*nb_true_divide*/
6589 0, /*nb_inplace_floor_divide*/
6590 0, /*nb_inplace_true_divide*/
6591 #if (PY_MAJOR_VERSION >= 3) || (Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX)
6596 static PySequenceMethods __pyx_tp_as_sequence_HuffCode = {
6605 0, /*sq_inplace_concat*/
6606 0, /*sq_inplace_repeat*/
6609 static PyMappingMethods __pyx_tp_as_mapping_HuffCode = {
6612 0, /*mp_ass_subscript*/
6615 static PyBufferProcs __pyx_tp_as_buffer_HuffCode = {
6616 #if PY_MAJOR_VERSION < 3
6617 0, /*bf_getreadbuffer*/
6619 #if PY_MAJOR_VERSION < 3
6620 0, /*bf_getwritebuffer*/
6622 #if PY_MAJOR_VERSION < 3
6623 0, /*bf_getsegcount*/
6625 #if PY_MAJOR_VERSION < 3
6626 0, /*bf_getcharbuffer*/
6628 #if PY_VERSION_HEX >= 0x02060000
6631 #if PY_VERSION_HEX >= 0x02060000
6632 0, /*bf_releasebuffer*/
6636 PyTypeObject __pyx_type_10sphinxbase_HuffCode = {
6637 PyVarObject_HEAD_INIT(0, 0)
6638 __Pyx_NAMESTR("sphinxbase.HuffCode"), /*tp_name*/
6639 sizeof(struct __pyx_obj_10sphinxbase_HuffCode), /*tp_basicsize*/
6641 __pyx_tp_dealloc_10sphinxbase_HuffCode, /*tp_dealloc*/
6647 &__pyx_tp_as_number_HuffCode, /*tp_as_number*/
6648 &__pyx_tp_as_sequence_HuffCode, /*tp_as_sequence*/
6649 &__pyx_tp_as_mapping_HuffCode, /*tp_as_mapping*/
6655 &__pyx_tp_as_buffer_HuffCode, /*tp_as_buffer*/
6656 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
6657 __Pyx_DOCSTR("\n Huffman coding class.\n\n You can either construct a Huffman code from an alphabet of\n symbols with frequencies, or read one from a file. Either the\n alphabet or infile argument (but not both) must be passed to the\n constructor.\n\n @param alphabet: Alphabet of (symbol, frequency) pairs\n @type alphabet: [(str, int)]\n @param infile: File handle or filename to read from\n @type infile: file | str\n "), /*tp_doc*/
6658 __pyx_tp_traverse_10sphinxbase_HuffCode, /*tp_traverse*/
6659 __pyx_tp_clear_10sphinxbase_HuffCode, /*tp_clear*/
6660 0, /*tp_richcompare*/
6661 0, /*tp_weaklistoffset*/
6664 __pyx_methods_10sphinxbase_HuffCode, /*tp_methods*/
6671 0, /*tp_dictoffset*/
6672 __pyx_pf_10sphinxbase_8HuffCode___init__, /*tp_init*/
6674 __pyx_tp_new_10sphinxbase_HuffCode, /*tp_new*/
6680 0, /*tp_subclasses*/
6683 #if PY_VERSION_HEX >= 0x02060000
6684 0, /*tp_version_tag*/
6688 static struct PyMethodDef __pyx_methods[] = {
6689 {__Pyx_NAMESTR("binstr"), (PyCFunction)__pyx_pf_10sphinxbase_binstr, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_binstr)},
6690 {__Pyx_NAMESTR("bincw"), (PyCFunction)__pyx_pf_10sphinxbase_bincw, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_10sphinxbase_bincw)},
6694 static void __pyx_init_filenames(void); /*proto*/
6696 #if PY_MAJOR_VERSION >= 3
6697 static struct PyModuleDef __pyx_moduledef = {
6698 PyModuleDef_HEAD_INIT,
6699 __Pyx_NAMESTR("sphinxbase"),
6702 __pyx_methods /* m_methods */,
6703 NULL, /* m_reload */
6704 NULL, /* m_traverse */
6710 static __Pyx_StringTabEntry __pyx_string_tab[] = {
6711 {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
6712 {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
6713 {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
6714 {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
6715 {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
6716 {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
6717 {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
6718 {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
6719 {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
6720 {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
6721 {&__pyx_n_s__ARPA, __pyx_k__ARPA, sizeof(__pyx_k__ARPA), 0, 0, 1, 1},
6722 {&__pyx_n_s__AUTO, __pyx_k__AUTO, sizeof(__pyx_k__AUTO), 0, 0, 1, 1},
6723 {&__pyx_n_s__DMP, __pyx_k__DMP, sizeof(__pyx_k__DMP), 0, 0, 1, 1},
6724 {&__pyx_n_s__LOWER, __pyx_k__LOWER, sizeof(__pyx_k__LOWER), 0, 0, 1, 1},
6725 {&__pyx_n_s__RuntimeError, __pyx_k__RuntimeError, sizeof(__pyx_k__RuntimeError), 0, 0, 1, 1},
6726 {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
6727 {&__pyx_n_s__UPPER, __pyx_k__UPPER, sizeof(__pyx_k__UPPER), 0, 0, 1, 1},
6728 {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
6729 {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
6730 {&__pyx_n_s__a, __pyx_k__a, sizeof(__pyx_k__a), 0, 0, 1, 1},
6731 {&__pyx_n_s__alphabet, __pyx_k__alphabet, sizeof(__pyx_k__alphabet), 0, 0, 1, 1},
6732 {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
6733 {&__pyx_n_s__base, __pyx_k__base, sizeof(__pyx_k__base), 0, 0, 1, 1},
6734 {&__pyx_n_s__cw, __pyx_k__cw, sizeof(__pyx_k__cw), 0, 0, 1, 1},
6735 {&__pyx_n_s__detach, __pyx_k__detach, sizeof(__pyx_k__detach), 0, 0, 1, 1},
6736 {&__pyx_n_s__enumerate, __pyx_k__enumerate, sizeof(__pyx_k__enumerate), 0, 0, 1, 1},
6737 {&__pyx_n_s__fh, __pyx_k__fh, sizeof(__pyx_k__fh), 0, 0, 1, 1},
6738 {&__pyx_n_s__file, __pyx_k__file, sizeof(__pyx_k__file), 0, 0, 1, 1},
6739 {&__pyx_n_s__file_name, __pyx_k__file_name, sizeof(__pyx_k__file_name), 0, 0, 1, 1},
6740 {&__pyx_n_s__first_item, __pyx_k__first_item, sizeof(__pyx_k__first_item), 0, 0, 1, 1},
6741 {&__pyx_n_s__format, __pyx_k__format, sizeof(__pyx_k__format), 0, 0, 1, 1},
6742 {&__pyx_n_s__frum, __pyx_k__frum, sizeof(__pyx_k__frum), 0, 0, 1, 1},
6743 {&__pyx_n_s__hc, __pyx_k__hc, sizeof(__pyx_k__hc), 0, 0, 1, 1},
6744 {&__pyx_n_s__infile, __pyx_k__infile, sizeof(__pyx_k__infile), 0, 0, 1, 1},
6745 {&__pyx_n_s__itor, __pyx_k__itor, sizeof(__pyx_k__itor), 0, 0, 1, 1},
6746 {&__pyx_n_s__lm, __pyx_k__lm, sizeof(__pyx_k__lm), 0, 0, 1, 1},
6747 {&__pyx_n_s__lmath, __pyx_k__lmath, sizeof(__pyx_k__lmath), 0, 0, 1, 1},
6748 {&__pyx_n_s__lmctl, __pyx_k__lmctl, sizeof(__pyx_k__lmctl), 0, 0, 1, 1},
6749 {&__pyx_n_s__log_bowt, __pyx_k__log_bowt, sizeof(__pyx_k__log_bowt), 0, 0, 1, 1},
6750 {&__pyx_n_s__log_prob, __pyx_k__log_prob, sizeof(__pyx_k__log_prob), 0, 0, 1, 1},
6751 {&__pyx_n_s__lw, __pyx_k__lw, sizeof(__pyx_k__lw), 0, 0, 1, 1},
6752 {&__pyx_n_s__m, __pyx_k__m, sizeof(__pyx_k__m), 0, 0, 1, 1},
6753 {&__pyx_n_s__min, __pyx_k__min, sizeof(__pyx_k__min), 0, 0, 1, 1},
6754 {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
6755 {&__pyx_n_s__nbits, __pyx_k__nbits, sizeof(__pyx_k__nbits), 0, 0, 1, 1},
6756 {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1},
6757 {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
6758 {&__pyx_n_s__rb, __pyx_k__rb, sizeof(__pyx_k__rb), 0, 0, 1, 1},
6759 {&__pyx_n_s__read, __pyx_k__read, sizeof(__pyx_k__read), 0, 0, 1, 1},
6760 {&__pyx_n_s__set_iter, __pyx_k__set_iter, sizeof(__pyx_k__set_iter), 0, 0, 1, 1},
6761 {&__pyx_n_s__shift, __pyx_k__shift, sizeof(__pyx_k__shift), 0, 0, 1, 1},
6762 {&__pyx_n_s__too, __pyx_k__too, sizeof(__pyx_k__too), 0, 0, 1, 1},
6763 {&__pyx_n_s__use_table, __pyx_k__use_table, sizeof(__pyx_k__use_table), 0, 0, 1, 1},
6764 {&__pyx_n_s__uw, __pyx_k__uw, sizeof(__pyx_k__uw), 0, 0, 1, 1},
6765 {&__pyx_n_s__val, __pyx_k__val, sizeof(__pyx_k__val), 0, 0, 1, 1},
6766 {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1},
6767 {&__pyx_n_s__wb, __pyx_k__wb, sizeof(__pyx_k__wb), 0, 0, 1, 1},
6768 {&__pyx_n_s__weight, __pyx_k__weight, sizeof(__pyx_k__weight), 0, 0, 1, 1},
6769 {&__pyx_n_s__wip, __pyx_k__wip, sizeof(__pyx_k__wip), 0, 0, 1, 1},
6770 {&__pyx_n_s__word, __pyx_k__word, sizeof(__pyx_k__word), 0, 0, 1, 1},
6771 {&__pyx_n_s__words, __pyx_k__words, sizeof(__pyx_k__words), 0, 0, 1, 1},
6772 {0, 0, 0, 0, 0, 0, 0}
6774 static int __Pyx_InitCachedBuiltins(void) {
6775 __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6776 __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6777 __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6778 __pyx_builtin_ord = __Pyx_GetName(__pyx_b, __pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6779 __pyx_builtin_min = __Pyx_GetName(__pyx_b, __pyx_n_s__min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6780 __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6781 __pyx_builtin_RuntimeError = __Pyx_GetName(__pyx_b, __pyx_n_s__RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6787 static int __Pyx_InitGlobals(void) {
6788 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
6789 __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;};
6790 __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;};
6791 __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
6797 #if PY_MAJOR_VERSION < 3
6798 PyMODINIT_FUNC initsphinxbase(void); /*proto*/
6799 PyMODINIT_FUNC initsphinxbase(void)
6801 PyMODINIT_FUNC PyInit_sphinxbase(void); /*proto*/
6802 PyMODINIT_FUNC PyInit_sphinxbase(void)
6805 PyObject *__pyx_t_1 = NULL;
6807 void* __pyx_refnanny = NULL;
6808 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
6809 if (!__Pyx_RefNanny) {
6811 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
6812 if (!__Pyx_RefNanny)
6813 Py_FatalError("failed to import 'refnanny' module");
6815 __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_sphinxbase(void)", __LINE__, __FILE__);
6817 __pyx_init_filenames();
6818 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6819 #if PY_MAJOR_VERSION < 3
6820 __pyx_empty_bytes = PyString_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6822 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6824 /*--- Library function declarations ---*/
6825 /*--- Threads initialization code ---*/
6826 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
6827 #ifdef WITH_THREAD /* Python build with threading support? */
6828 PyEval_InitThreads();
6831 /*--- Module creation code ---*/
6832 #if PY_MAJOR_VERSION < 3
6833 __pyx_m = Py_InitModule4(__Pyx_NAMESTR("sphinxbase"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
6835 __pyx_m = PyModule_Create(&__pyx_moduledef);
6837 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
6838 #if PY_MAJOR_VERSION < 3
6841 __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
6842 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
6843 if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
6844 /*--- Initialize various global constants etc. ---*/
6845 if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6846 if (__pyx_module_is_main_sphinxbase) {
6847 if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
6849 /*--- Builtin init code ---*/
6850 if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6851 /*--- Global init code ---*/
6852 /*--- Function export code ---*/
6853 /*--- Type init code ---*/
6854 __pyx_vtabptr_10sphinxbase_NGramModel = &__pyx_vtable_10sphinxbase_NGramModel;
6855 #if PY_MAJOR_VERSION >= 3
6856 __pyx_vtable_10sphinxbase_NGramModel.set_lm = (PyObject *(*)(struct __pyx_obj_10sphinxbase_NGramModel *, ngram_model_t *))__pyx_f_10sphinxbase_10NGramModel_set_lm;
6857 __pyx_vtable_10sphinxbase_NGramModel.set_lmath = (PyObject *(*)(struct __pyx_obj_10sphinxbase_NGramModel *, logmath_t *))__pyx_f_10sphinxbase_10NGramModel_set_lmath;
6859 *(void(**)(void))&__pyx_vtable_10sphinxbase_NGramModel.set_lm = (void(*)(void))__pyx_f_10sphinxbase_10NGramModel_set_lm;
6860 *(void(**)(void))&__pyx_vtable_10sphinxbase_NGramModel.set_lmath = (void(*)(void))__pyx_f_10sphinxbase_10NGramModel_set_lmath;
6862 if (PyType_Ready(&__pyx_type_10sphinxbase_NGramModel) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6863 if (__Pyx_SetVtable(__pyx_type_10sphinxbase_NGramModel.tp_dict, __pyx_vtabptr_10sphinxbase_NGramModel) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6864 if (__Pyx_SetAttrString(__pyx_m, "NGramModel", (PyObject *)&__pyx_type_10sphinxbase_NGramModel) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6865 __pyx_ptype_10sphinxbase_NGramModel = &__pyx_type_10sphinxbase_NGramModel;
6866 if (PyType_Ready(&__pyx_type_10sphinxbase_LogMath) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6867 if (__Pyx_SetAttrString(__pyx_m, "LogMath", (PyObject *)&__pyx_type_10sphinxbase_LogMath) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6868 __pyx_ptype_10sphinxbase_LogMath = &__pyx_type_10sphinxbase_LogMath;
6869 __pyx_vtabptr_10sphinxbase_NGramIter = &__pyx_vtable_10sphinxbase_NGramIter;
6870 #if PY_MAJOR_VERSION >= 3
6871 __pyx_vtable_10sphinxbase_NGramIter.set_iter = (PyObject *(*)(struct __pyx_obj_10sphinxbase_NGramIter *, ngram_iter_t *))__pyx_f_10sphinxbase_9NGramIter_set_iter;
6873 *(void(**)(void))&__pyx_vtable_10sphinxbase_NGramIter.set_iter = (void(*)(void))__pyx_f_10sphinxbase_9NGramIter_set_iter;
6875 if (PyType_Ready(&__pyx_type_10sphinxbase_NGramIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6876 if (__Pyx_SetVtable(__pyx_type_10sphinxbase_NGramIter.tp_dict, __pyx_vtabptr_10sphinxbase_NGramIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6877 if (__Pyx_SetAttrString(__pyx_m, "NGramIter", (PyObject *)&__pyx_type_10sphinxbase_NGramIter) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6878 __pyx_ptype_10sphinxbase_NGramIter = &__pyx_type_10sphinxbase_NGramIter;
6879 if (PyType_Ready(&__pyx_type_10sphinxbase_HuffCode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6880 if (__Pyx_SetAttrString(__pyx_m, "HuffCode", (PyObject *)&__pyx_type_10sphinxbase_HuffCode) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6881 __pyx_ptype_10sphinxbase_HuffCode = &__pyx_type_10sphinxbase_HuffCode;
6882 /*--- Type import code ---*/
6883 /*--- Function import code ---*/
6884 /*--- Execution code ---*/
6886 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":24
6887 * @type use_table: bool
6889 * def __init__(self, base=1.0001, shift=0, use_table=1): # <<<<<<<<<<<<<<
6890 * self.lmath = logmath_init(base, shift, use_table)
6893 __pyx_t_1 = PyFloat_FromDouble(1.0001); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6894 __Pyx_GOTREF(__pyx_t_1);
6895 __pyx_k_1 = __pyx_t_1;
6896 __Pyx_GIVEREF(__pyx_t_1);
6899 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":122
6901 * # Unfortunately, Cython doesn't actually export enums to Python...
6902 * AUTO = NGRAM_AUTO # <<<<<<<<<<<<<<
6906 __pyx_t_1 = PyInt_FromLong(NGRAM_AUTO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6907 __Pyx_GOTREF(__pyx_t_1);
6908 if (PyObject_SetAttr(__pyx_m, __pyx_n_s__AUTO, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6909 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6911 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":123
6912 * # Unfortunately, Cython doesn't actually export enums to Python...
6914 * ARPA = NGRAM_ARPA # <<<<<<<<<<<<<<
6916 * UPPER = NGRAM_UPPER
6918 __pyx_t_1 = PyInt_FromLong(NGRAM_ARPA); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6919 __Pyx_GOTREF(__pyx_t_1);
6920 if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ARPA, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6921 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6923 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":124
6926 * DMP = NGRAM_DMP # <<<<<<<<<<<<<<
6927 * UPPER = NGRAM_UPPER
6928 * LOWER = NGRAM_LOWER
6930 __pyx_t_1 = PyInt_FromLong(NGRAM_DMP); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6931 __Pyx_GOTREF(__pyx_t_1);
6932 if (PyObject_SetAttr(__pyx_m, __pyx_n_s__DMP, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6933 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6935 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":125
6938 * UPPER = NGRAM_UPPER # <<<<<<<<<<<<<<
6939 * LOWER = NGRAM_LOWER
6942 __pyx_t_1 = PyInt_FromLong(NGRAM_UPPER); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6943 __Pyx_GOTREF(__pyx_t_1);
6944 if (PyObject_SetAttr(__pyx_m, __pyx_n_s__UPPER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6945 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6947 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":126
6949 * UPPER = NGRAM_UPPER
6950 * LOWER = NGRAM_LOWER # <<<<<<<<<<<<<<
6952 * cdef class NGramModel:
6954 __pyx_t_1 = PyInt_FromLong(NGRAM_LOWER); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6955 __Pyx_GOTREF(__pyx_t_1);
6956 if (PyObject_SetAttr(__pyx_m, __pyx_n_s__LOWER, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6957 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6959 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":146
6962 * def __init__(self, file=None, lw=1.0, wip=1.0, uw=1.0, lmctl=None): # <<<<<<<<<<<<<<
6963 * self.lmath = logmath_init(1.0001, 0, 0)
6966 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6967 __Pyx_GOTREF(__pyx_t_1);
6968 __pyx_k_2 = __pyx_t_1;
6969 __Pyx_GIVEREF(__pyx_t_1);
6971 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6972 __Pyx_GOTREF(__pyx_t_1);
6973 __pyx_k_3 = __pyx_t_1;
6974 __Pyx_GIVEREF(__pyx_t_1);
6976 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6977 __Pyx_GOTREF(__pyx_t_1);
6978 __pyx_k_4 = __pyx_t_1;
6979 __Pyx_GIVEREF(__pyx_t_1);
6982 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":176
6983 * ngram_model_free(self.lm)
6985 * def apply_weights(self, lw=1.0, wip=1.0, uw=1.0): # <<<<<<<<<<<<<<
6987 * Change the language model weights applied in L{score}.
6989 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6990 __Pyx_GOTREF(__pyx_t_1);
6991 __pyx_k_5 = __pyx_t_1;
6992 __Pyx_GIVEREF(__pyx_t_1);
6994 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6995 __Pyx_GOTREF(__pyx_t_1);
6996 __pyx_k_6 = __pyx_t_1;
6997 __Pyx_GIVEREF(__pyx_t_1);
6999 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7000 __Pyx_GOTREF(__pyx_t_1);
7001 __pyx_k_7 = __pyx_t_1;
7002 __Pyx_GIVEREF(__pyx_t_1);
7005 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":369
7008 * def add_word(self, word, weight=1.0): # <<<<<<<<<<<<<<
7009 * return ngram_model_add_word(self.lm, word, weight)
7012 __pyx_t_1 = PyFloat_FromDouble(1.0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7013 __Pyx_GOTREF(__pyx_t_1);
7014 __pyx_k_8 = __pyx_t_1;
7015 __Pyx_GIVEREF(__pyx_t_1);
7018 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":384
7019 * raise ValueError, "Casefolding failed"
7021 * def write(self, file_name, format=NGRAM_AUTO): # <<<<<<<<<<<<<<
7023 * rv = ngram_model_write(self.lm, file_name, format)
7025 __pyx_t_1 = PyInt_FromLong(NGRAM_AUTO); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 384; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7026 __Pyx_GOTREF(__pyx_t_1);
7027 __pyx_k_11 = __pyx_t_1;
7028 __Pyx_GIVEREF(__pyx_t_1);
7031 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":1
7032 * # Copyright (c) 2008 Carnegie Mellon University. All rights # <<<<<<<<<<<<<<
7038 __Pyx_XDECREF(__pyx_t_1);
7040 __Pyx_AddTraceback("init sphinxbase");
7041 Py_DECREF(__pyx_m); __pyx_m = 0;
7042 } else if (!PyErr_Occurred()) {
7043 PyErr_SetString(PyExc_ImportError, "init sphinxbase");
7046 __Pyx_RefNannyFinishContext();
7047 #if PY_MAJOR_VERSION < 3
7054 static const char *__pyx_filenames[] = {
7058 /* Runtime support code */
7060 static void __pyx_init_filenames(void) {
7061 __pyx_f = __pyx_filenames;
7064 static void __Pyx_RaiseDoubleKeywordsError(
7065 const char* func_name,
7068 PyErr_Format(PyExc_TypeError,
7069 #if PY_MAJOR_VERSION >= 3
7070 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
7072 "%s() got multiple values for keyword argument '%s'", func_name,
7073 PyString_AS_STRING(kw_name));
7077 static void __Pyx_RaiseArgtupleInvalid(
7078 const char* func_name,
7082 Py_ssize_t num_found)
7084 Py_ssize_t num_expected;
7085 const char *number, *more_or_less;
7087 if (num_found < num_min) {
7088 num_expected = num_min;
7089 more_or_less = "at least";
7091 num_expected = num_max;
7092 more_or_less = "at most";
7095 more_or_less = "exactly";
7097 number = (num_expected == 1) ? "" : "s";
7098 PyErr_Format(PyExc_TypeError,
7099 #if PY_VERSION_HEX < 0x02050000
7100 "%s() takes %s %d positional argument%s (%d given)",
7102 "%s() takes %s %zd positional argument%s (%zd given)",
7104 func_name, more_or_less, num_expected, number, num_found);
7107 static int __Pyx_ParseOptionalKeywords(
7109 PyObject **argnames[],
7112 Py_ssize_t num_pos_args,
7113 const char* function_name)
7115 PyObject *key = 0, *value = 0;
7118 PyObject*** first_kw_arg = argnames + num_pos_args;
7120 while (PyDict_Next(kwds, &pos, &key, &value)) {
7121 name = first_kw_arg;
7122 while (*name && (**name != key)) name++;
7124 values[name-argnames] = value;
7126 #if PY_MAJOR_VERSION < 3
7127 if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
7129 if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
7131 goto invalid_keyword_type;
7133 for (name = first_kw_arg; *name; name++) {
7134 #if PY_MAJOR_VERSION >= 3
7135 if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
7136 PyUnicode_Compare(**name, key) == 0) break;
7138 if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
7139 _PyString_Eq(**name, key)) break;
7143 values[name-argnames] = value;
7145 /* unexpected keyword found */
7146 for (name=argnames; name != first_kw_arg; name++) {
7147 if (**name == key) goto arg_passed_twice;
7148 #if PY_MAJOR_VERSION >= 3
7149 if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
7150 PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
7152 if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
7153 _PyString_Eq(**name, key)) goto arg_passed_twice;
7157 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
7159 goto invalid_keyword;
7167 __Pyx_RaiseDoubleKeywordsError(function_name, **name);
7169 invalid_keyword_type:
7170 PyErr_Format(PyExc_TypeError,
7171 "%s() keywords must be strings", function_name);
7174 PyErr_Format(PyExc_TypeError,
7175 #if PY_MAJOR_VERSION < 3
7176 "%s() got an unexpected keyword argument '%s'",
7177 function_name, PyString_AsString(key));
7179 "%s() got an unexpected keyword argument '%U'",
7180 function_name, key);
7186 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
7187 PyErr_Format(PyExc_ValueError,
7188 #if PY_VERSION_HEX < 0x02050000
7189 "need more than %d value%s to unpack", (int)index,
7191 "need more than %zd value%s to unpack", index,
7193 (index == 1) ? "" : "s");
7196 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
7197 PyErr_SetString(PyExc_ValueError, "too many values to unpack");
7200 static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
7202 if (!(item = PyIter_Next(iter))) {
7203 if (!PyErr_Occurred()) {
7204 __Pyx_RaiseNeedMoreValuesError(index);
7210 static int __Pyx_EndUnpack(PyObject *iter) {
7212 if ((item = PyIter_Next(iter))) {
7214 __Pyx_RaiseTooManyValuesError();
7217 else if (!PyErr_Occurred())
7224 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
7227 q -= ((r != 0) & ((r ^ b) < 0));
7231 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
7232 const char *name, int exact)
7235 PyErr_Format(PyExc_SystemError, "Missing type object");
7238 if (none_allowed && obj == Py_None) return 1;
7240 if (Py_TYPE(obj) == type) return 1;
7243 if (PyObject_TypeCheck(obj, type)) return 1;
7245 PyErr_Format(PyExc_TypeError,
7246 "Argument '%s' has incorrect type (expected %s, got %s)",
7247 name, type->tp_name, Py_TYPE(obj)->tp_name);
7251 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
7253 result = PyObject_GetAttr(dict, name);
7255 PyErr_SetObject(PyExc_NameError, name);
7259 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
7260 PyObject *tmp_type, *tmp_value, *tmp_tb;
7261 PyThreadState *tstate = PyThreadState_GET();
7263 tmp_type = tstate->curexc_type;
7264 tmp_value = tstate->curexc_value;
7265 tmp_tb = tstate->curexc_traceback;
7266 tstate->curexc_type = type;
7267 tstate->curexc_value = value;
7268 tstate->curexc_traceback = tb;
7269 Py_XDECREF(tmp_type);
7270 Py_XDECREF(tmp_value);
7274 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
7275 PyThreadState *tstate = PyThreadState_GET();
7276 *type = tstate->curexc_type;
7277 *value = tstate->curexc_value;
7278 *tb = tstate->curexc_traceback;
7280 tstate->curexc_type = 0;
7281 tstate->curexc_value = 0;
7282 tstate->curexc_traceback = 0;
7286 #if PY_MAJOR_VERSION < 3
7287 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
7291 /* First, check the traceback argument, replacing None with NULL. */
7292 if (tb == Py_None) {
7296 else if (tb != NULL && !PyTraceBack_Check(tb)) {
7297 PyErr_SetString(PyExc_TypeError,
7298 "raise: arg 3 must be a traceback or None");
7301 /* Next, replace a missing value with None */
7302 if (value == NULL) {
7306 #if PY_VERSION_HEX < 0x02050000
7307 if (!PyClass_Check(type))
7309 if (!PyType_Check(type))
7312 /* Raising an instance. The value should be a dummy. */
7313 if (value != Py_None) {
7314 PyErr_SetString(PyExc_TypeError,
7315 "instance exception may not have a separate value");
7318 /* Normalize to raise <class>, <instance> */
7321 #if PY_VERSION_HEX < 0x02050000
7322 if (PyInstance_Check(type)) {
7323 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
7328 PyErr_SetString(PyExc_TypeError,
7329 "raise: exception must be an old-style class or instance");
7333 type = (PyObject*) Py_TYPE(type);
7335 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
7336 PyErr_SetString(PyExc_TypeError,
7337 "raise: exception class must be a subclass of BaseException");
7343 __Pyx_ErrRestore(type, value, tb);
7352 #else /* Python 3+ */
7354 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
7355 if (tb == Py_None) {
7357 } else if (tb && !PyTraceBack_Check(tb)) {
7358 PyErr_SetString(PyExc_TypeError,
7359 "raise: arg 3 must be a traceback or None");
7362 if (value == Py_None)
7365 if (PyExceptionInstance_Check(type)) {
7367 PyErr_SetString(PyExc_TypeError,
7368 "instance exception may not have a separate value");
7372 type = (PyObject*) Py_TYPE(value);
7373 } else if (!PyExceptionClass_Check(type)) {
7374 PyErr_SetString(PyExc_TypeError,
7375 "raise: exception class must be a subclass of BaseException");
7379 PyErr_SetObject(type, value);
7382 PyThreadState *tstate = PyThreadState_GET();
7383 PyObject* tmp_tb = tstate->curexc_traceback;
7386 tstate->curexc_traceback = tb;
7396 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
7397 const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
7398 const int is_unsigned = neg_one > const_zero;
7399 if (sizeof(unsigned char) < sizeof(long)) {
7400 long val = __Pyx_PyInt_AsLong(x);
7401 if (unlikely(val != (long)(unsigned char)val)) {
7402 if (!unlikely(val == -1 && PyErr_Occurred())) {
7403 PyErr_SetString(PyExc_OverflowError,
7404 (is_unsigned && unlikely(val < 0)) ?
7405 "can't convert negative value to unsigned char" :
7406 "value too large to convert to unsigned char");
7408 return (unsigned char)-1;
7410 return (unsigned char)val;
7412 return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
7415 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
7416 const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
7417 const int is_unsigned = neg_one > const_zero;
7418 if (sizeof(unsigned short) < sizeof(long)) {
7419 long val = __Pyx_PyInt_AsLong(x);
7420 if (unlikely(val != (long)(unsigned short)val)) {
7421 if (!unlikely(val == -1 && PyErr_Occurred())) {
7422 PyErr_SetString(PyExc_OverflowError,
7423 (is_unsigned && unlikely(val < 0)) ?
7424 "can't convert negative value to unsigned short" :
7425 "value too large to convert to unsigned short");
7427 return (unsigned short)-1;
7429 return (unsigned short)val;
7431 return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
7434 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
7435 const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
7436 const int is_unsigned = neg_one > const_zero;
7437 if (sizeof(unsigned int) < sizeof(long)) {
7438 long val = __Pyx_PyInt_AsLong(x);
7439 if (unlikely(val != (long)(unsigned int)val)) {
7440 if (!unlikely(val == -1 && PyErr_Occurred())) {
7441 PyErr_SetString(PyExc_OverflowError,
7442 (is_unsigned && unlikely(val < 0)) ?
7443 "can't convert negative value to unsigned int" :
7444 "value too large to convert to unsigned int");
7446 return (unsigned int)-1;
7448 return (unsigned int)val;
7450 return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
7453 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
7454 const char neg_one = (char)-1, const_zero = 0;
7455 const int is_unsigned = neg_one > const_zero;
7456 if (sizeof(char) < sizeof(long)) {
7457 long val = __Pyx_PyInt_AsLong(x);
7458 if (unlikely(val != (long)(char)val)) {
7459 if (!unlikely(val == -1 && PyErr_Occurred())) {
7460 PyErr_SetString(PyExc_OverflowError,
7461 (is_unsigned && unlikely(val < 0)) ?
7462 "can't convert negative value to char" :
7463 "value too large to convert to char");
7469 return (char)__Pyx_PyInt_AsLong(x);
7472 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
7473 const short neg_one = (short)-1, const_zero = 0;
7474 const int is_unsigned = neg_one > const_zero;
7475 if (sizeof(short) < sizeof(long)) {
7476 long val = __Pyx_PyInt_AsLong(x);
7477 if (unlikely(val != (long)(short)val)) {
7478 if (!unlikely(val == -1 && PyErr_Occurred())) {
7479 PyErr_SetString(PyExc_OverflowError,
7480 (is_unsigned && unlikely(val < 0)) ?
7481 "can't convert negative value to short" :
7482 "value too large to convert to short");
7488 return (short)__Pyx_PyInt_AsLong(x);
7491 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
7492 const int neg_one = (int)-1, const_zero = 0;
7493 const int is_unsigned = neg_one > const_zero;
7494 if (sizeof(int) < sizeof(long)) {
7495 long val = __Pyx_PyInt_AsLong(x);
7496 if (unlikely(val != (long)(int)val)) {
7497 if (!unlikely(val == -1 && PyErr_Occurred())) {
7498 PyErr_SetString(PyExc_OverflowError,
7499 (is_unsigned && unlikely(val < 0)) ?
7500 "can't convert negative value to int" :
7501 "value too large to convert to int");
7507 return (int)__Pyx_PyInt_AsLong(x);
7510 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
7511 const signed char neg_one = (signed char)-1, const_zero = 0;
7512 const int is_unsigned = neg_one > const_zero;
7513 if (sizeof(signed char) < sizeof(long)) {
7514 long val = __Pyx_PyInt_AsLong(x);
7515 if (unlikely(val != (long)(signed char)val)) {
7516 if (!unlikely(val == -1 && PyErr_Occurred())) {
7517 PyErr_SetString(PyExc_OverflowError,
7518 (is_unsigned && unlikely(val < 0)) ?
7519 "can't convert negative value to signed char" :
7520 "value too large to convert to signed char");
7522 return (signed char)-1;
7524 return (signed char)val;
7526 return (signed char)__Pyx_PyInt_AsSignedLong(x);
7529 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
7530 const signed short neg_one = (signed short)-1, const_zero = 0;
7531 const int is_unsigned = neg_one > const_zero;
7532 if (sizeof(signed short) < sizeof(long)) {
7533 long val = __Pyx_PyInt_AsLong(x);
7534 if (unlikely(val != (long)(signed short)val)) {
7535 if (!unlikely(val == -1 && PyErr_Occurred())) {
7536 PyErr_SetString(PyExc_OverflowError,
7537 (is_unsigned && unlikely(val < 0)) ?
7538 "can't convert negative value to signed short" :
7539 "value too large to convert to signed short");
7541 return (signed short)-1;
7543 return (signed short)val;
7545 return (signed short)__Pyx_PyInt_AsSignedLong(x);
7548 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
7549 const signed int neg_one = (signed int)-1, const_zero = 0;
7550 const int is_unsigned = neg_one > const_zero;
7551 if (sizeof(signed int) < sizeof(long)) {
7552 long val = __Pyx_PyInt_AsLong(x);
7553 if (unlikely(val != (long)(signed int)val)) {
7554 if (!unlikely(val == -1 && PyErr_Occurred())) {
7555 PyErr_SetString(PyExc_OverflowError,
7556 (is_unsigned && unlikely(val < 0)) ?
7557 "can't convert negative value to signed int" :
7558 "value too large to convert to signed int");
7560 return (signed int)-1;
7562 return (signed int)val;
7564 return (signed int)__Pyx_PyInt_AsSignedLong(x);
7567 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
7568 const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
7569 const int is_unsigned = neg_one > const_zero;
7570 #if PY_VERSION_HEX < 0x03000000
7571 if (likely(PyInt_Check(x))) {
7572 long val = PyInt_AS_LONG(x);
7573 if (is_unsigned && unlikely(val < 0)) {
7574 PyErr_SetString(PyExc_OverflowError,
7575 "can't convert negative value to unsigned long");
7576 return (unsigned long)-1;
7578 return (unsigned long)val;
7581 if (likely(PyLong_Check(x))) {
7583 if (unlikely(Py_SIZE(x) < 0)) {
7584 PyErr_SetString(PyExc_OverflowError,
7585 "can't convert negative value to unsigned long");
7586 return (unsigned long)-1;
7588 return PyLong_AsUnsignedLong(x);
7590 return PyLong_AsLong(x);
7594 PyObject *tmp = __Pyx_PyNumber_Int(x);
7595 if (!tmp) return (unsigned long)-1;
7596 val = __Pyx_PyInt_AsUnsignedLong(tmp);
7602 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
7603 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
7604 const int is_unsigned = neg_one > const_zero;
7605 #if PY_VERSION_HEX < 0x03000000
7606 if (likely(PyInt_Check(x))) {
7607 long val = PyInt_AS_LONG(x);
7608 if (is_unsigned && unlikely(val < 0)) {
7609 PyErr_SetString(PyExc_OverflowError,
7610 "can't convert negative value to unsigned PY_LONG_LONG");
7611 return (unsigned PY_LONG_LONG)-1;
7613 return (unsigned PY_LONG_LONG)val;
7616 if (likely(PyLong_Check(x))) {
7618 if (unlikely(Py_SIZE(x) < 0)) {
7619 PyErr_SetString(PyExc_OverflowError,
7620 "can't convert negative value to unsigned PY_LONG_LONG");
7621 return (unsigned PY_LONG_LONG)-1;
7623 return PyLong_AsUnsignedLongLong(x);
7625 return PyLong_AsLongLong(x);
7628 unsigned PY_LONG_LONG val;
7629 PyObject *tmp = __Pyx_PyNumber_Int(x);
7630 if (!tmp) return (unsigned PY_LONG_LONG)-1;
7631 val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
7637 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
7638 const long neg_one = (long)-1, const_zero = 0;
7639 const int is_unsigned = neg_one > const_zero;
7640 #if PY_VERSION_HEX < 0x03000000
7641 if (likely(PyInt_Check(x))) {
7642 long val = PyInt_AS_LONG(x);
7643 if (is_unsigned && unlikely(val < 0)) {
7644 PyErr_SetString(PyExc_OverflowError,
7645 "can't convert negative value to long");
7651 if (likely(PyLong_Check(x))) {
7653 if (unlikely(Py_SIZE(x) < 0)) {
7654 PyErr_SetString(PyExc_OverflowError,
7655 "can't convert negative value to long");
7658 return PyLong_AsUnsignedLong(x);
7660 return PyLong_AsLong(x);
7664 PyObject *tmp = __Pyx_PyNumber_Int(x);
7665 if (!tmp) return (long)-1;
7666 val = __Pyx_PyInt_AsLong(tmp);
7672 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
7673 const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
7674 const int is_unsigned = neg_one > const_zero;
7675 #if PY_VERSION_HEX < 0x03000000
7676 if (likely(PyInt_Check(x))) {
7677 long val = PyInt_AS_LONG(x);
7678 if (is_unsigned && unlikely(val < 0)) {
7679 PyErr_SetString(PyExc_OverflowError,
7680 "can't convert negative value to PY_LONG_LONG");
7681 return (PY_LONG_LONG)-1;
7683 return (PY_LONG_LONG)val;
7686 if (likely(PyLong_Check(x))) {
7688 if (unlikely(Py_SIZE(x) < 0)) {
7689 PyErr_SetString(PyExc_OverflowError,
7690 "can't convert negative value to PY_LONG_LONG");
7691 return (PY_LONG_LONG)-1;
7693 return PyLong_AsUnsignedLongLong(x);
7695 return PyLong_AsLongLong(x);
7699 PyObject *tmp = __Pyx_PyNumber_Int(x);
7700 if (!tmp) return (PY_LONG_LONG)-1;
7701 val = __Pyx_PyInt_AsLongLong(tmp);
7707 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
7708 const signed long neg_one = (signed long)-1, const_zero = 0;
7709 const int is_unsigned = neg_one > const_zero;
7710 #if PY_VERSION_HEX < 0x03000000
7711 if (likely(PyInt_Check(x))) {
7712 long val = PyInt_AS_LONG(x);
7713 if (is_unsigned && unlikely(val < 0)) {
7714 PyErr_SetString(PyExc_OverflowError,
7715 "can't convert negative value to signed long");
7716 return (signed long)-1;
7718 return (signed long)val;
7721 if (likely(PyLong_Check(x))) {
7723 if (unlikely(Py_SIZE(x) < 0)) {
7724 PyErr_SetString(PyExc_OverflowError,
7725 "can't convert negative value to signed long");
7726 return (signed long)-1;
7728 return PyLong_AsUnsignedLong(x);
7730 return PyLong_AsLong(x);
7734 PyObject *tmp = __Pyx_PyNumber_Int(x);
7735 if (!tmp) return (signed long)-1;
7736 val = __Pyx_PyInt_AsSignedLong(tmp);
7742 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
7743 const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
7744 const int is_unsigned = neg_one > const_zero;
7745 #if PY_VERSION_HEX < 0x03000000
7746 if (likely(PyInt_Check(x))) {
7747 long val = PyInt_AS_LONG(x);
7748 if (is_unsigned && unlikely(val < 0)) {
7749 PyErr_SetString(PyExc_OverflowError,
7750 "can't convert negative value to signed PY_LONG_LONG");
7751 return (signed PY_LONG_LONG)-1;
7753 return (signed PY_LONG_LONG)val;
7756 if (likely(PyLong_Check(x))) {
7758 if (unlikely(Py_SIZE(x) < 0)) {
7759 PyErr_SetString(PyExc_OverflowError,
7760 "can't convert negative value to signed PY_LONG_LONG");
7761 return (signed PY_LONG_LONG)-1;
7763 return PyLong_AsUnsignedLongLong(x);
7765 return PyLong_AsLongLong(x);
7768 signed PY_LONG_LONG val;
7769 PyObject *tmp = __Pyx_PyNumber_Int(x);
7770 if (!tmp) return (signed PY_LONG_LONG)-1;
7771 val = __Pyx_PyInt_AsSignedLongLong(tmp);
7777 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
7778 #if PY_VERSION_HEX < 0x03010000
7779 PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
7781 PyObject *ob = PyCapsule_New(vtable, 0, 0);
7785 if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
7794 #include "compile.h"
7795 #include "frameobject.h"
7796 #include "traceback.h"
7798 static void __Pyx_AddTraceback(const char *funcname) {
7799 PyObject *py_srcfile = 0;
7800 PyObject *py_funcname = 0;
7801 PyObject *py_globals = 0;
7802 PyCodeObject *py_code = 0;
7803 PyFrameObject *py_frame = 0;
7805 #if PY_MAJOR_VERSION < 3
7806 py_srcfile = PyString_FromString(__pyx_filename);
7808 py_srcfile = PyUnicode_FromString(__pyx_filename);
7810 if (!py_srcfile) goto bad;
7811 if (__pyx_clineno) {
7812 #if PY_MAJOR_VERSION < 3
7813 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
7815 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
7819 #if PY_MAJOR_VERSION < 3
7820 py_funcname = PyString_FromString(funcname);
7822 py_funcname = PyUnicode_FromString(funcname);
7825 if (!py_funcname) goto bad;
7826 py_globals = PyModule_GetDict(__pyx_m);
7827 if (!py_globals) goto bad;
7828 py_code = PyCode_New(
7829 0, /*int argcount,*/
7830 #if PY_MAJOR_VERSION >= 3
7831 0, /*int kwonlyargcount,*/
7834 0, /*int stacksize,*/
7836 __pyx_empty_bytes, /*PyObject *code,*/
7837 __pyx_empty_tuple, /*PyObject *consts,*/
7838 __pyx_empty_tuple, /*PyObject *names,*/
7839 __pyx_empty_tuple, /*PyObject *varnames,*/
7840 __pyx_empty_tuple, /*PyObject *freevars,*/
7841 __pyx_empty_tuple, /*PyObject *cellvars,*/
7842 py_srcfile, /*PyObject *filename,*/
7843 py_funcname, /*PyObject *name,*/
7844 __pyx_lineno, /*int firstlineno,*/
7845 __pyx_empty_bytes /*PyObject *lnotab*/
7847 if (!py_code) goto bad;
7848 py_frame = PyFrame_New(
7849 PyThreadState_GET(), /*PyThreadState *tstate,*/
7850 py_code, /*PyCodeObject *code,*/
7851 py_globals, /*PyObject *globals,*/
7852 0 /*PyObject *locals*/
7854 if (!py_frame) goto bad;
7855 py_frame->f_lineno = __pyx_lineno;
7856 PyTraceBack_Here(py_frame);
7858 Py_XDECREF(py_srcfile);
7859 Py_XDECREF(py_funcname);
7860 Py_XDECREF(py_code);
7861 Py_XDECREF(py_frame);
7864 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
7866 #if PY_MAJOR_VERSION < 3
7867 if (t->is_unicode) {
7868 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
7869 } else if (t->intern) {
7870 *t->p = PyString_InternFromString(t->s);
7872 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
7874 #else /* Python 3+ has unicode identifiers */
7875 if (t->is_unicode | t->is_str) {
7877 *t->p = PyUnicode_InternFromString(t->s);
7878 } else if (t->encoding) {
7879 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
7881 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
7884 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
7894 /* Type Conversion Functions */
7896 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
7897 if (x == Py_True) return 1;
7898 else if ((x == Py_False) | (x == Py_None)) return 0;
7899 else return PyObject_IsTrue(x);
7902 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
7904 const char *name = NULL;
7905 PyObject *res = NULL;
7906 #if PY_VERSION_HEX < 0x03000000
7907 if (PyInt_Check(x) || PyLong_Check(x))
7909 if (PyLong_Check(x))
7911 return Py_INCREF(x), x;
7912 m = Py_TYPE(x)->tp_as_number;
7913 #if PY_VERSION_HEX < 0x03000000
7914 if (m && m->nb_int) {
7916 res = PyNumber_Int(x);
7918 else if (m && m->nb_long) {
7920 res = PyNumber_Long(x);
7923 if (m && m->nb_int) {
7925 res = PyNumber_Long(x);
7929 #if PY_VERSION_HEX < 0x03000000
7930 if (!PyInt_Check(res) && !PyLong_Check(res)) {
7932 if (!PyLong_Check(res)) {
7934 PyErr_Format(PyExc_TypeError,
7935 "__%s__ returned non-%s (type %.200s)",
7936 name, name, Py_TYPE(res)->tp_name);
7941 else if (!PyErr_Occurred()) {
7942 PyErr_SetString(PyExc_TypeError,
7943 "an integer is required");
7948 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
7950 PyObject* x = PyNumber_Index(b);
7952 ival = PyInt_AsSsize_t(x);
7957 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
7958 #if PY_VERSION_HEX < 0x02050000
7959 if (ival <= LONG_MAX)
7960 return PyInt_FromLong((long)ival);
7962 unsigned char *bytes = (unsigned char *) &ival;
7963 int one = 1; int little = (int)*(unsigned char*)&one;
7964 return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
7967 return PyInt_FromSize_t(ival);
7971 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
7972 unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
7973 if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
7975 } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
7976 PyErr_SetString(PyExc_OverflowError,
7977 "value too large to convert to size_t");
7984 #endif /* Py_PYTHON_H */