packaging: updated changelog.
[profile/ivi/sphinxbase.git] / python / sphinxbase.c
1 /* Generated by Cython 0.12.1 on Mon May 16 07:44:10 2011 */
2
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #include "structmember.h"
6 #ifndef Py_PYTHON_H
7     #error Python headers needed to compile C extensions, please install development version of Python.
8 #else
9
10 #ifndef PY_LONG_LONG
11   #define PY_LONG_LONG LONG_LONG
12 #endif
13 #ifndef DL_EXPORT
14   #define DL_EXPORT(t) t
15 #endif
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)
20 #endif
21
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)
32 #endif
33
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)
41
42   typedef struct {
43      void *buf;
44      PyObject *obj;
45      Py_ssize_t len;
46      Py_ssize_t itemsize;
47      int readonly;
48      int ndim;
49      char *format;
50      Py_ssize_t *shape;
51      Py_ssize_t *strides;
52      Py_ssize_t *suboffsets;
53      void *internal;
54   } Py_buffer;
55
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)
65
66 #endif
67
68 #if PY_MAJOR_VERSION < 3
69   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
70 #else
71   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
72 #endif
73
74 #if PY_MAJOR_VERSION >= 3
75   #define Py_TPFLAGS_CHECKTYPES 0
76   #define Py_TPFLAGS_HAVE_INDEX 0
77 #endif
78
79 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
80   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
81 #endif
82
83 #if PY_MAJOR_VERSION >= 3
84   #define PyBaseString_Type            PyUnicode_Type
85   #define PyString_Type                PyUnicode_Type
86   #define PyString_CheckExact          PyUnicode_CheckExact
87 #else
88   #define PyBytes_Type                 PyString_Type
89   #define PyBytes_CheckExact           PyString_CheckExact
90 #endif
91
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)
108 #else
109   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
110   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
111
112 #endif
113
114 #if PY_MAJOR_VERSION >= 3
115   #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
116 #endif
117
118 #if !defined(WIN32) && !defined(MS_WINDOWS)
119   #ifndef __stdcall
120     #define __stdcall
121   #endif
122   #ifndef __cdecl
123     #define __cdecl
124   #endif
125   #ifndef __fastcall
126     #define __fastcall
127   #endif
128 #else
129   #define _USE_MATH_DEFINES
130 #endif
131
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)))
136 #else
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))
140 #endif
141
142 #if PY_VERSION_HEX < 0x02050000
143   #define __Pyx_NAMESTR(n) ((char *)(n))
144   #define __Pyx_DOCSTR(n)  ((char *)(n))
145 #else
146   #define __Pyx_NAMESTR(n) (n)
147   #define __Pyx_DOCSTR(n)  (n)
148 #endif
149 #ifdef __cplusplus
150 #define __PYX_EXTERN_C extern "C"
151 #else
152 #define __PYX_EXTERN_C extern
153 #endif
154 #include <math.h>
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"
162
163 #ifndef CYTHON_INLINE
164   #if defined(__GNUC__)
165     #define CYTHON_INLINE __inline__
166   #elif defined(_MSC_VER)
167     #define CYTHON_INLINE __inline
168   #else
169     #define CYTHON_INLINE 
170   #endif
171 #endif
172
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*/
174
175
176 /* Type Conversion Predeclarations */
177
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
182 #else
183 #define __Pyx_PyBytes_FromString          PyBytes_FromString
184 #define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
185 #define __Pyx_PyBytes_AsString            PyBytes_AsString
186 #endif
187
188 #define __Pyx_PyBytes_FromUString(s)      __Pyx_PyBytes_FromString((char*)s)
189 #define __Pyx_PyBytes_AsUString(s)        ((unsigned char*) __Pyx_PyBytes_AsString(s))
190
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);
194
195 #if !defined(T_PYSSIZET)
196 #if PY_VERSION_HEX < 0x02050000
197 #define T_PYSSIZET T_INT
198 #elif !defined(T_LONGLONG)
199 #define T_PYSSIZET \
200         ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
201         ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
202 #else
203 #define T_PYSSIZET \
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)))
207 #endif
208 #endif
209
210
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))))
217 #else
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)))))
224 #endif
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))))
231 #else
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)))))
238 #endif
239
240 #define __Pyx_T_FLOATING(x) \
241         ((sizeof(x) == sizeof(float)) ? T_FLOAT : \
242         ((sizeof(x) == sizeof(double)) ? T_DOUBLE : -1))
243
244 #if !defined(T_SIZET)
245 #if !defined(T_ULONGLONG)
246 #define T_SIZET \
247         ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
248         ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
249 #else
250 #define T_SIZET \
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)))
254 #endif
255 #endif
256
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*);
260
261 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
262
263
264 #ifdef __GNUC__
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 ... */
273 #else /* __GNUC__ */
274 #define likely(x)   (x)
275 #define unlikely(x) (x)
276 #endif /* __GNUC__ */
277     
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;
287
288
289 typedef float __pyx_t_10sphinxbase_float32;
290
291 typedef int __pyx_t_10sphinxbase_int32;
292
293 typedef double __pyx_t_10sphinxbase_float64;
294
295 /* Type declarations */
296
297 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":149
298  *     cdef logmath_t *lmath
299  * 
300  * cdef class NGramIter:             # <<<<<<<<<<<<<<
301  *     cdef NGramModel lm
302  *     cdef ngram_iter_t *itor
303  */
304
305 struct __pyx_obj_10sphinxbase_NGramIter {
306   PyObject_HEAD
307   struct __pyx_vtabstruct_10sphinxbase_NGramIter *__pyx_vtab;
308   struct __pyx_obj_10sphinxbase_NGramModel *lm;
309   ngram_iter_t *itor;
310   int first_item;
311   int m;
312   float log_prob;
313   float log_bowt;
314   PyObject *words;
315 };
316
317 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":159
318  *     cdef set_iter(NGramIter self, ngram_iter_t *itor)
319  * 
320  * cdef class HuffCode:             # <<<<<<<<<<<<<<
321  *     cdef huff_code_t *hc
322  *     cdef object fh
323  */
324
325 struct __pyx_obj_10sphinxbase_HuffCode {
326   PyObject_HEAD
327   huff_code_t *hc;
328   PyObject *fh;
329 };
330
331 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":138
332  * 
333  * # Extension classes
334  * cdef class NGramModel:             # <<<<<<<<<<<<<<
335  *     cdef ngram_model_t *lm
336  *     cdef logmath_t *lmath
337  */
338
339 struct __pyx_obj_10sphinxbase_NGramModel {
340   PyObject_HEAD
341   struct __pyx_vtabstruct_10sphinxbase_NGramModel *__pyx_vtab;
342   ngram_model_t *lm;
343   logmath_t *lmath;
344   float lw;
345   float wip;
346   float uw;
347 };
348
349 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":146
350  *     cdef set_lmath(NGramModel self, logmath_t *lmath)
351  * 
352  * cdef class LogMath:             # <<<<<<<<<<<<<<
353  *     cdef logmath_t *lmath
354  * 
355  */
356
357 struct __pyx_obj_10sphinxbase_LogMath {
358   PyObject_HEAD
359   logmath_t *lmath;
360 };
361
362
363 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":390
364  *             raise ValueError, "Write %s to file failed" % file_name
365  * 
366  * cdef class NGramIter:             # <<<<<<<<<<<<<<
367  *     """
368  *     N-Gram language model iterator class.
369  */
370
371 struct __pyx_vtabstruct_10sphinxbase_NGramIter {
372   PyObject *(*set_iter)(struct __pyx_obj_10sphinxbase_NGramIter *, ngram_iter_t *);
373 };
374 static struct __pyx_vtabstruct_10sphinxbase_NGramIter *__pyx_vtabptr_10sphinxbase_NGramIter;
375
376
377 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":128
378  * LOWER = NGRAM_LOWER
379  * 
380  * cdef class NGramModel:             # <<<<<<<<<<<<<<
381  *     """
382  *     N-Gram language model class.
383  */
384
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 *);
388 };
389 static struct __pyx_vtabstruct_10sphinxbase_NGramModel *__pyx_vtabptr_10sphinxbase_NGramModel;
390
391 #ifndef CYTHON_REFNANNY
392   #define CYTHON_REFNANNY 0
393 #endif
394
395 #if CYTHON_REFNANNY
396   typedef struct {
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;
407     void *r = NULL;
408     m = PyImport_ImportModule((char *)modname);
409     if (!m) goto end;
410     p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
411     if (!p) goto end;
412     r = PyLong_AsVoidPtr(p);
413   end:
414     Py_XDECREF(p);
415     Py_XDECREF(m);
416     return (__Pyx_RefNannyAPIStruct *)r;
417   }
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)
425 #else
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)
436
437 static void __Pyx_RaiseDoubleKeywordsError(
438     const char* func_name, PyObject* kw_name); /*proto*/
439
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*/
442
443 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
444
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;
448         Py_INCREF(Py_None);
449         return Py_None; /* this is just to have an accurate signature */
450     }
451     else {
452         PyObject *r, *m;
453         m = __Pyx_GetAttrString(L, "append");
454         if (!m) return NULL;
455         r = PyObject_CallFunctionObjArgs(m, x, NULL);
456         Py_DECREF(m);
457         return r;
458     }
459 }
460
461 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
462
463 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void);
464
465 static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
466 static int __Pyx_EndUnpack(PyObject *); /*proto*/
467
468
469 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
470     PyObject *r;
471     if (!j) return NULL;
472     r = PyObject_GetItem(o, j);
473     Py_DECREF(j);
474     return r;
475 }
476
477
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)))
481
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);
486             Py_INCREF(r);
487             return r;
488         }
489         else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
490             PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
491             Py_INCREF(r);
492             return r;
493         }
494     }
495     return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
496 }
497
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)))
501
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);
506             Py_INCREF(r);
507             return r;
508         }
509         else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
510             PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
511             Py_INCREF(r);
512             return r;
513         }
514     }
515     return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
516 }
517
518
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)))
522
523 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
524     PyObject *r;
525     if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
526         r = PyList_GET_ITEM(o, i);
527         Py_INCREF(r);
528     }
529     else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
530         r = PyTuple_GET_ITEM(o, i);
531         Py_INCREF(r);
532     }
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);
535     }
536     else {
537         r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
538     }
539     return r;
540 }
541
542 static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */
543
544 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
545     const char *name, int exact); /*proto*/
546
547 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
548
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*/
551
552 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
553
554 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
555
556 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
557
558 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
559
560 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
561
562 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
563
564 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
565
566 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
567
568 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
569
570 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
571
572 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
573
574 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
575
576 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
577
578 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
579
580 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
581
582 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
583
584 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
585
586 static void __Pyx_AddTraceback(const char *funcname); /*proto*/
587
588 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
589 /* Module declarations from sphinxbase */
590
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;
597
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;
740
741 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":24
742  *     @type use_table: bool
743  *     """
744  *     def __init__(self, base=1.0001, shift=0, use_table=1):             # <<<<<<<<<<<<<<
745  *         self.lmath = logmath_init(base, shift, use_table)
746  * 
747  */
748
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;
754   int __pyx_r;
755   __pyx_t_10sphinxbase_float64 __pyx_t_1;
756   int __pyx_t_2;
757   int __pyx_t_3;
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);
770       case  0: break;
771       default: goto __pyx_L5_argtuple_error;
772     }
773     switch (PyTuple_GET_SIZE(__pyx_args)) {
774       case  0:
775       if (kw_args > 1) {
776         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__base);
777         if (unlikely(value)) { values[0] = value; kw_args--; }
778       }
779       case  1:
780       if (kw_args > 1) {
781         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__shift);
782         if (unlikely(value)) { values[1] = value; kw_args--; }
783       }
784       case  2:
785       if (kw_args > 1) {
786         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__use_table);
787         if (unlikely(value)) { values[2] = value; kw_args--; }
788       }
789     }
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;}
792     }
793     __pyx_v_base = values[0];
794     __pyx_v_shift = values[1];
795     __pyx_v_use_table = values[2];
796   } else {
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);
804       case  0: break;
805       default: goto __pyx_L5_argtuple_error;
806     }
807   }
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;}
811   __pyx_L3_error:;
812   __Pyx_AddTraceback("sphinxbase.LogMath.__init__");
813   return -1;
814   __pyx_L4_argument_unpacking_done:;
815
816   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":25
817  *     """
818  *     def __init__(self, base=1.0001, shift=0, use_table=1):
819  *         self.lmath = logmath_init(base, shift, use_table)             # <<<<<<<<<<<<<<
820  * 
821  *     def __dealloc__(self):
822  */
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);
827
828   __pyx_r = 0;
829   goto __pyx_L0;
830   __pyx_L1_error:;
831   __Pyx_AddTraceback("sphinxbase.LogMath.__init__");
832   __pyx_r = -1;
833   __pyx_L0:;
834   __Pyx_RefNannyFinishContext();
835   return __pyx_r;
836 }
837
838 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":27
839  *         self.lmath = logmath_init(base, shift, use_table)
840  * 
841  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
842  *         """
843  *         Destructor for LogMath class.
844  */
845
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__");
850
851   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":31
852  *         Destructor for LogMath class.
853  *         """
854  *         logmath_free(self.lmath)             # <<<<<<<<<<<<<<
855  * 
856  *     def get_zero(self):
857  */
858   logmath_free(((struct __pyx_obj_10sphinxbase_LogMath *)__pyx_v_self)->lmath);
859
860   __Pyx_RefNannyFinishContext();
861 }
862
863 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":33
864  *         logmath_free(self.lmath)
865  * 
866  *     def get_zero(self):             # <<<<<<<<<<<<<<
867  *         """
868  *         Get the log-zero value.
869  */
870
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");
877
878   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":40
879  *         @rtype: int
880  *         """
881  *         return logmath_get_zero(self.lmath)             # <<<<<<<<<<<<<<
882  * 
883  *     def add(self, a, b):
884  */
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);
888   __pyx_r = __pyx_t_1;
889   __pyx_t_1 = 0;
890   goto __pyx_L0;
891
892   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
893   goto __pyx_L0;
894   __pyx_L1_error:;
895   __Pyx_XDECREF(__pyx_t_1);
896   __Pyx_AddTraceback("sphinxbase.LogMath.get_zero");
897   __pyx_r = NULL;
898   __pyx_L0:;
899   __Pyx_XGIVEREF(__pyx_r);
900   __Pyx_RefNannyFinishContext();
901   return __pyx_r;
902 }
903
904 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":42
905  *         return logmath_get_zero(self.lmath)
906  * 
907  *     def add(self, a, b):             # <<<<<<<<<<<<<<
908  *         """
909  *         Add two numbers in log-space.
910  */
911
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;
918   int __pyx_t_1;
919   int __pyx_t_2;
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);
929       case  0: break;
930       default: goto __pyx_L5_argtuple_error;
931     }
932     switch (PyTuple_GET_SIZE(__pyx_args)) {
933       case  0:
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;
937       case  1:
938       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__b);
939       if (likely(values[1])) kw_args--;
940       else {
941         __Pyx_RaiseArgtupleInvalid("add", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
942       }
943     }
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;}
946     }
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;
951   } else {
952     __pyx_v_a = PyTuple_GET_ITEM(__pyx_args, 0);
953     __pyx_v_b = PyTuple_GET_ITEM(__pyx_args, 1);
954   }
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;}
958   __pyx_L3_error:;
959   __Pyx_AddTraceback("sphinxbase.LogMath.add");
960   return NULL;
961   __pyx_L4_argument_unpacking_done:;
962
963   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":53
964  *         @rtype: int
965  *         """
966  *         return logmath_add(self.lmath, a, b)             # <<<<<<<<<<<<<<
967  * 
968  *     def log(self, x):
969  */
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);
975   __pyx_r = __pyx_t_3;
976   __pyx_t_3 = 0;
977   goto __pyx_L0;
978
979   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
980   goto __pyx_L0;
981   __pyx_L1_error:;
982   __Pyx_XDECREF(__pyx_t_3);
983   __Pyx_AddTraceback("sphinxbase.LogMath.add");
984   __pyx_r = NULL;
985   __pyx_L0:;
986   __Pyx_XGIVEREF(__pyx_r);
987   __Pyx_RefNannyFinishContext();
988   return __pyx_r;
989 }
990
991 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":55
992  *         return logmath_add(self.lmath, a, b)
993  * 
994  *     def log(self, x):             # <<<<<<<<<<<<<<
995  *         """
996  *         Return log-value of a number.
997  */
998
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");
1006
1007   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":64
1008  *         @rtype: int
1009  *         """
1010  *         return logmath_log(self.lmath, x)             # <<<<<<<<<<<<<<
1011  * 
1012  *     def exp(self, x):
1013  */
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;
1019   __pyx_t_2 = 0;
1020   goto __pyx_L0;
1021
1022   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1023   goto __pyx_L0;
1024   __pyx_L1_error:;
1025   __Pyx_XDECREF(__pyx_t_2);
1026   __Pyx_AddTraceback("sphinxbase.LogMath.log");
1027   __pyx_r = NULL;
1028   __pyx_L0:;
1029   __Pyx_XGIVEREF(__pyx_r);
1030   __Pyx_RefNannyFinishContext();
1031   return __pyx_r;
1032 }
1033
1034 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":66
1035  *         return logmath_log(self.lmath, x)
1036  * 
1037  *     def exp(self, x):             # <<<<<<<<<<<<<<
1038  *         """
1039  *         Return linear of a log-value
1040  */
1041
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;
1046   int __pyx_t_1;
1047   PyObject *__pyx_t_2 = NULL;
1048   __Pyx_RefNannySetupContext("exp");
1049
1050   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":75
1051  *         @rtype: float
1052  *         """
1053  *         return logmath_exp(self.lmath, x)             # <<<<<<<<<<<<<<
1054  * 
1055  *     def log_to_ln(self, x):
1056  */
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;
1062   __pyx_t_2 = 0;
1063   goto __pyx_L0;
1064
1065   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1066   goto __pyx_L0;
1067   __pyx_L1_error:;
1068   __Pyx_XDECREF(__pyx_t_2);
1069   __Pyx_AddTraceback("sphinxbase.LogMath.exp");
1070   __pyx_r = NULL;
1071   __pyx_L0:;
1072   __Pyx_XGIVEREF(__pyx_r);
1073   __Pyx_RefNannyFinishContext();
1074   return __pyx_r;
1075 }
1076
1077 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":77
1078  *         return logmath_exp(self.lmath, x)
1079  * 
1080  *     def log_to_ln(self, x):             # <<<<<<<<<<<<<<
1081  *         """
1082  *         Return natural logarithm of a log-value.
1083  */
1084
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;
1089   int __pyx_t_1;
1090   PyObject *__pyx_t_2 = NULL;
1091   __Pyx_RefNannySetupContext("log_to_ln");
1092
1093   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":86
1094  *         @rtype: float
1095  *         """
1096  *         return logmath_log_to_ln(self.lmath, x)             # <<<<<<<<<<<<<<
1097  * 
1098  *     def log_to_log10(self, x):
1099  */
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;
1105   __pyx_t_2 = 0;
1106   goto __pyx_L0;
1107
1108   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1109   goto __pyx_L0;
1110   __pyx_L1_error:;
1111   __Pyx_XDECREF(__pyx_t_2);
1112   __Pyx_AddTraceback("sphinxbase.LogMath.log_to_ln");
1113   __pyx_r = NULL;
1114   __pyx_L0:;
1115   __Pyx_XGIVEREF(__pyx_r);
1116   __Pyx_RefNannyFinishContext();
1117   return __pyx_r;
1118 }
1119
1120 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":88
1121  *         return logmath_log_to_ln(self.lmath, x)
1122  * 
1123  *     def log_to_log10(self, x):             # <<<<<<<<<<<<<<
1124  *         """
1125  *         Return logarithm in base 10 of a log-value.
1126  */
1127
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;
1132   int __pyx_t_1;
1133   PyObject *__pyx_t_2 = NULL;
1134   __Pyx_RefNannySetupContext("log_to_log10");
1135
1136   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":97
1137  *         @rtype: float
1138  *         """
1139  *         return logmath_log_to_log10(self.lmath, x)             # <<<<<<<<<<<<<<
1140  * 
1141  *     def ln_to_log(self, x):
1142  */
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;
1148   __pyx_t_2 = 0;
1149   goto __pyx_L0;
1150
1151   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1152   goto __pyx_L0;
1153   __pyx_L1_error:;
1154   __Pyx_XDECREF(__pyx_t_2);
1155   __Pyx_AddTraceback("sphinxbase.LogMath.log_to_log10");
1156   __pyx_r = NULL;
1157   __pyx_L0:;
1158   __Pyx_XGIVEREF(__pyx_r);
1159   __Pyx_RefNannyFinishContext();
1160   return __pyx_r;
1161 }
1162
1163 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":99
1164  *         return logmath_log_to_log10(self.lmath, x)
1165  * 
1166  *     def ln_to_log(self, x):             # <<<<<<<<<<<<<<
1167  *         """
1168  *         Return log-value of a natural logarithm.
1169  */
1170
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");
1178
1179   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":108
1180  *         @rtype: int
1181  *         """
1182  *         return logmath_ln_to_log(self.lmath, x)             # <<<<<<<<<<<<<<
1183  * 
1184  *     def log10_to_log(self, x):
1185  */
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;
1191   __pyx_t_2 = 0;
1192   goto __pyx_L0;
1193
1194   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1195   goto __pyx_L0;
1196   __pyx_L1_error:;
1197   __Pyx_XDECREF(__pyx_t_2);
1198   __Pyx_AddTraceback("sphinxbase.LogMath.ln_to_log");
1199   __pyx_r = NULL;
1200   __pyx_L0:;
1201   __Pyx_XGIVEREF(__pyx_r);
1202   __Pyx_RefNannyFinishContext();
1203   return __pyx_r;
1204 }
1205
1206 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":110
1207  *         return logmath_ln_to_log(self.lmath, x)
1208  * 
1209  *     def log10_to_log(self, x):             # <<<<<<<<<<<<<<
1210  *         """
1211  *         Return log-value of a base 10 logarithm.
1212  */
1213
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");
1221
1222   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":119
1223  *         @rtype: int
1224  *         """
1225  *         return logmath_log10_to_log(self.lmath, x)             # <<<<<<<<<<<<<<
1226  * 
1227  * # Unfortunately, Cython doesn't actually export enums to Python...
1228  */
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;
1234   __pyx_t_2 = 0;
1235   goto __pyx_L0;
1236
1237   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1238   goto __pyx_L0;
1239   __pyx_L1_error:;
1240   __Pyx_XDECREF(__pyx_t_2);
1241   __Pyx_AddTraceback("sphinxbase.LogMath.log10_to_log");
1242   __pyx_r = NULL;
1243   __pyx_L0:;
1244   __Pyx_XGIVEREF(__pyx_r);
1245   __Pyx_RefNannyFinishContext();
1246   return __pyx_r;
1247 }
1248
1249 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":146
1250  *     @type uw: float
1251  *     """
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)
1254  *         if file:
1255  */
1256
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;
1264   int __pyx_r;
1265   int __pyx_t_1;
1266   char *__pyx_t_2;
1267   __pyx_t_10sphinxbase_float32 __pyx_t_3;
1268   __pyx_t_10sphinxbase_float32 __pyx_t_4;
1269   __pyx_t_10sphinxbase_float32 __pyx_t_5;
1270   float __pyx_t_6;
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);
1287       case  0: break;
1288       default: goto __pyx_L5_argtuple_error;
1289     }
1290     switch (PyTuple_GET_SIZE(__pyx_args)) {
1291       case  0:
1292       if (kw_args > 1) {
1293         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__file);
1294         if (unlikely(value)) { values[0] = value; kw_args--; }
1295       }
1296       case  1:
1297       if (kw_args > 1) {
1298         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lw);
1299         if (unlikely(value)) { values[1] = value; kw_args--; }
1300       }
1301       case  2:
1302       if (kw_args > 1) {
1303         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wip);
1304         if (unlikely(value)) { values[2] = value; kw_args--; }
1305       }
1306       case  3:
1307       if (kw_args > 1) {
1308         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__uw);
1309         if (unlikely(value)) { values[3] = value; kw_args--; }
1310       }
1311       case  4:
1312       if (kw_args > 1) {
1313         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lmctl);
1314         if (unlikely(value)) { values[4] = value; kw_args--; }
1315       }
1316     }
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;}
1319     }
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];
1325   } else {
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);
1337       case  0: break;
1338       default: goto __pyx_L5_argtuple_error;
1339     }
1340   }
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;}
1344   __pyx_L3_error:;
1345   __Pyx_AddTraceback("sphinxbase.NGramModel.__init__");
1346   return -1;
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);
1354
1355   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":147
1356  *     """
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)             # <<<<<<<<<<<<<<
1359  *         if file:
1360  *             self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)
1361  */
1362   ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath = logmath_init(1.0001, 0, 0);
1363
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)
1370  */
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;}
1372   if (__pyx_t_1) {
1373
1374     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":149
1375  *         self.lmath = logmath_init(1.0001, 0, 0)
1376  *         if file:
1377  *             self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)             # <<<<<<<<<<<<<<
1378  *             ngram_model_apply_weights(self.lm, lw, wip, uw)
1379  *         elif lmctl:
1380  */
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);
1383
1384     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":150
1385  *         if file:
1386  *             self.lm = ngram_model_read(NULL, file, NGRAM_AUTO, self.lmath)
1387  *             ngram_model_apply_weights(self.lm, lw, wip, uw)             # <<<<<<<<<<<<<<
1388  *         elif lmctl:
1389  *             self.lm = ngram_model_set_read(NULL, lmctl, self.lmath)
1390  */
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);
1395     goto __pyx_L6;
1396   }
1397
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)
1403  *         else:
1404  */
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;}
1406   if (__pyx_t_1) {
1407
1408     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":152
1409  *             ngram_model_apply_weights(self.lm, lw, wip, uw)
1410  *         elif lmctl:
1411  *             self.lm = ngram_model_set_read(NULL, lmctl, self.lmath)             # <<<<<<<<<<<<<<
1412  *         else:
1413  *             self.lm = NULL
1414  */
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);
1417     goto __pyx_L6;
1418   }
1419   /*else*/ {
1420
1421     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":154
1422  *             self.lm = ngram_model_set_read(NULL, lmctl, self.lmath)
1423  *         else:
1424  *             self.lm = NULL             # <<<<<<<<<<<<<<
1425  *         self.lw = lw
1426  *         self.wip = wip
1427  */
1428     ((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm = NULL;
1429   }
1430   __pyx_L6:;
1431
1432   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":155
1433  *         else:
1434  *             self.lm = NULL
1435  *         self.lw = lw             # <<<<<<<<<<<<<<
1436  *         self.wip = wip
1437  *         self.uw = uw
1438  */
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;
1441
1442   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":156
1443  *             self.lm = NULL
1444  *         self.lw = lw
1445  *         self.wip = wip             # <<<<<<<<<<<<<<
1446  *         self.uw = uw
1447  * 
1448  */
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;
1451
1452   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":157
1453  *         self.lw = lw
1454  *         self.wip = wip
1455  *         self.uw = uw             # <<<<<<<<<<<<<<
1456  * 
1457  *     cdef set_lm(NGramModel self, ngram_model_t *lm):
1458  */
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;
1461
1462   __pyx_r = 0;
1463   goto __pyx_L0;
1464   __pyx_L1_error:;
1465   __Pyx_AddTraceback("sphinxbase.NGramModel.__init__");
1466   __pyx_r = -1;
1467   __pyx_L0:;
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();
1475   return __pyx_r;
1476 }
1477
1478 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":159
1479  *         self.uw = uw
1480  * 
1481  *     cdef set_lm(NGramModel self, ngram_model_t *lm):             # <<<<<<<<<<<<<<
1482  *         ngram_model_retain(lm)
1483  *         ngram_model_free(self.lm)
1484  */
1485
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");
1489
1490   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":160
1491  * 
1492  *     cdef set_lm(NGramModel self, ngram_model_t *lm):
1493  *         ngram_model_retain(lm)             # <<<<<<<<<<<<<<
1494  *         ngram_model_free(self.lm)
1495  *         self.lm = lm
1496  */
1497   ngram_model_retain(__pyx_v_lm);
1498
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)             # <<<<<<<<<<<<<<
1503  *         self.lm = lm
1504  * 
1505  */
1506   ngram_model_free(__pyx_v_self->lm);
1507
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             # <<<<<<<<<<<<<<
1512  * 
1513  *     cdef set_lmath(NGramModel self, logmath_t *lmath):
1514  */
1515   __pyx_v_self->lm = __pyx_v_lm;
1516
1517   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1518   __Pyx_XGIVEREF(__pyx_r);
1519   __Pyx_RefNannyFinishContext();
1520   return __pyx_r;
1521 }
1522
1523 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":164
1524  *         self.lm = lm
1525  * 
1526  *     cdef set_lmath(NGramModel self, logmath_t *lmath):             # <<<<<<<<<<<<<<
1527  *         logmath_retain(lmath)
1528  *         logmath_free(self.lmath)
1529  */
1530
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");
1534
1535   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":165
1536  * 
1537  *     cdef set_lmath(NGramModel self, logmath_t *lmath):
1538  *         logmath_retain(lmath)             # <<<<<<<<<<<<<<
1539  *         logmath_free(self.lmath)
1540  *         self.lmath = lmath
1541  */
1542   logmath_retain(__pyx_v_lmath);
1543
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
1549  * 
1550  */
1551   logmath_free(__pyx_v_self->lmath);
1552
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             # <<<<<<<<<<<<<<
1557  * 
1558  *     def __dealloc__(self):
1559  */
1560   __pyx_v_self->lmath = __pyx_v_lmath;
1561
1562   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1563   __Pyx_XGIVEREF(__pyx_r);
1564   __Pyx_RefNannyFinishContext();
1565   return __pyx_r;
1566 }
1567
1568 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":169
1569  *         self.lmath = lmath
1570  * 
1571  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1572  *         """
1573  *         Destructor for N-Gram model class.
1574  */
1575
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__");
1580
1581   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":173
1582  *         Destructor for N-Gram model class.
1583  *         """
1584  *         logmath_free(self.lmath)             # <<<<<<<<<<<<<<
1585  *         ngram_model_free(self.lm)
1586  * 
1587  */
1588   logmath_free(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lmath);
1589
1590   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":174
1591  *         """
1592  *         logmath_free(self.lmath)
1593  *         ngram_model_free(self.lm)             # <<<<<<<<<<<<<<
1594  * 
1595  *     def apply_weights(self, lw=1.0, wip=1.0, uw=1.0):
1596  */
1597   ngram_model_free(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm);
1598
1599   __Pyx_RefNannyFinishContext();
1600 }
1601
1602 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":176
1603  *         ngram_model_free(self.lm)
1604  * 
1605  *     def apply_weights(self, lw=1.0, wip=1.0, uw=1.0):             # <<<<<<<<<<<<<<
1606  *         """
1607  *         Change the language model weights applied in L{score}.
1608  */
1609
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;
1617   float __pyx_t_1;
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);
1633       case  0: break;
1634       default: goto __pyx_L5_argtuple_error;
1635     }
1636     switch (PyTuple_GET_SIZE(__pyx_args)) {
1637       case  0:
1638       if (kw_args > 1) {
1639         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__lw);
1640         if (unlikely(value)) { values[0] = value; kw_args--; }
1641       }
1642       case  1:
1643       if (kw_args > 1) {
1644         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wip);
1645         if (unlikely(value)) { values[1] = value; kw_args--; }
1646       }
1647       case  2:
1648       if (kw_args > 1) {
1649         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__uw);
1650         if (unlikely(value)) { values[2] = value; kw_args--; }
1651       }
1652     }
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;}
1655     }
1656     __pyx_v_lw = values[0];
1657     __pyx_v_wip = values[1];
1658     __pyx_v_uw = values[2];
1659   } else {
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);
1667       case  0: break;
1668       default: goto __pyx_L5_argtuple_error;
1669     }
1670   }
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;}
1674   __pyx_L3_error:;
1675   __Pyx_AddTraceback("sphinxbase.NGramModel.apply_weights");
1676   return NULL;
1677   __pyx_L4_argument_unpacking_done:;
1678
1679   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":187
1680  *         @type uw: float
1681  *         """
1682  *         self.lw = lw             # <<<<<<<<<<<<<<
1683  *         self.wip = wip
1684  *         self.uw = uw
1685  */
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;
1688
1689   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":188
1690  *         """
1691  *         self.lw = lw
1692  *         self.wip = wip             # <<<<<<<<<<<<<<
1693  *         self.uw = uw
1694  *         ngram_model_apply_weights(self.lm, lw, wip, uw)
1695  */
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;
1698
1699   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":189
1700  *         self.lw = lw
1701  *         self.wip = wip
1702  *         self.uw = uw             # <<<<<<<<<<<<<<
1703  *         ngram_model_apply_weights(self.lm, lw, wip, uw)
1704  * 
1705  */
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;
1708
1709   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":190
1710  *         self.wip = wip
1711  *         self.uw = uw
1712  *         ngram_model_apply_weights(self.lm, lw, wip, uw)             # <<<<<<<<<<<<<<
1713  * 
1714  *     def get_size(self):
1715  */
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);
1720
1721   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1722   goto __pyx_L0;
1723   __pyx_L1_error:;
1724   __Pyx_AddTraceback("sphinxbase.NGramModel.apply_weights");
1725   __pyx_r = NULL;
1726   __pyx_L0:;
1727   __Pyx_XGIVEREF(__pyx_r);
1728   __Pyx_RefNannyFinishContext();
1729   return __pyx_r;
1730 }
1731
1732 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":192
1733  *         ngram_model_apply_weights(self.lm, lw, wip, uw)
1734  * 
1735  *     def get_size(self):             # <<<<<<<<<<<<<<
1736  *         """
1737  *         Get the order of this model (i.e. the 'N' in 'N-gram')
1738  */
1739
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");
1746
1747   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":199
1748  *         @rtype: int
1749  *         """
1750  *         return ngram_model_get_size(self.lm)             # <<<<<<<<<<<<<<
1751  * 
1752  *     def get_counts(self):
1753  */
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;
1758   __pyx_t_1 = 0;
1759   goto __pyx_L0;
1760
1761   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1762   goto __pyx_L0;
1763   __pyx_L1_error:;
1764   __Pyx_XDECREF(__pyx_t_1);
1765   __Pyx_AddTraceback("sphinxbase.NGramModel.get_size");
1766   __pyx_r = NULL;
1767   __pyx_L0:;
1768   __Pyx_XGIVEREF(__pyx_r);
1769   __Pyx_RefNannyFinishContext();
1770   return __pyx_r;
1771 }
1772
1773 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":201
1774  *         return ngram_model_get_size(self.lm)
1775  * 
1776  *     def get_counts(self):             # <<<<<<<<<<<<<<
1777  *         """
1778  *         Get the counts of each size of N-gram.
1779  */
1780
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;
1792   int __pyx_t_6;
1793   __Pyx_RefNannySetupContext("get_counts");
1794   __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
1795
1796   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":209
1797  *         """
1798  *         cdef int *counts
1799  *         counts = ngram_model_get_counts(self.lm)             # <<<<<<<<<<<<<<
1800  *         return tuple([counts[i] for i in range(ngram_model_get_size(self.lm))])
1801  * 
1802  */
1803   __pyx_v_counts = ngram_model_get_counts(((struct __pyx_obj_10sphinxbase_NGramModel *)__pyx_v_self)->lm);
1804
1805   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":210
1806  *         cdef int *counts
1807  *         counts = ngram_model_get_counts(self.lm)
1808  *         return tuple([counts[i] for i in range(ngram_model_get_size(self.lm))])             # <<<<<<<<<<<<<<
1809  * 
1810  *     def unknown_wid(self):
1811  */
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);
1821   __pyx_t_3 = 0;
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);
1827   } else {
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);
1830   }
1831   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1832   for (;;) {
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++;
1839     } else {
1840       __pyx_t_3 = PyIter_Next(__pyx_t_4);
1841       if (!__pyx_t_3) {
1842         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1843         break;
1844       }
1845       __Pyx_GOTREF(__pyx_t_3);
1846     }
1847     __Pyx_DECREF(__pyx_v_i);
1848     __pyx_v_i = __pyx_t_3;
1849     __pyx_t_3 = 0;
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;
1855   }
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);
1861   __pyx_t_4 = 0;
1862   goto __pyx_L0;
1863
1864   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1865   goto __pyx_L0;
1866   __pyx_L1_error:;
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");
1871   __pyx_r = NULL;
1872   __pyx_L0:;
1873   __Pyx_DECREF(__pyx_v_i);
1874   __Pyx_XGIVEREF(__pyx_r);
1875   __Pyx_RefNannyFinishContext();
1876   return __pyx_r;
1877 }
1878
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))])
1881  * 
1882  *     def unknown_wid(self):             # <<<<<<<<<<<<<<
1883  *         """
1884  *         Get the ID for an unknown word.
1885  */
1886
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");
1893
1894   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":221
1895  *         @rtype: int
1896  *         """
1897  *         return ngram_unknown_wid(self.lm)             # <<<<<<<<<<<<<<
1898  * 
1899  *     def zero(self):
1900  */
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;
1905   __pyx_t_1 = 0;
1906   goto __pyx_L0;
1907
1908   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1909   goto __pyx_L0;
1910   __pyx_L1_error:;
1911   __Pyx_XDECREF(__pyx_t_1);
1912   __Pyx_AddTraceback("sphinxbase.NGramModel.unknown_wid");
1913   __pyx_r = NULL;
1914   __pyx_L0:;
1915   __Pyx_XGIVEREF(__pyx_r);
1916   __Pyx_RefNannyFinishContext();
1917   return __pyx_r;
1918 }
1919
1920 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":223
1921  *         return ngram_unknown_wid(self.lm)
1922  * 
1923  *     def zero(self):             # <<<<<<<<<<<<<<
1924  *         """
1925  *         Get the log-zero value for this language model.
1926  */
1927
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");
1934
1935   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":230
1936  *         @rtype: float
1937  *         """
1938  *         return logmath_log_to_ln(self.lmath, ngram_zero(self.lm))             # <<<<<<<<<<<<<<
1939  * 
1940  *     def wid(self, word):
1941  */
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;
1946   __pyx_t_1 = 0;
1947   goto __pyx_L0;
1948
1949   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1950   goto __pyx_L0;
1951   __pyx_L1_error:;
1952   __Pyx_XDECREF(__pyx_t_1);
1953   __Pyx_AddTraceback("sphinxbase.NGramModel.zero");
1954   __pyx_r = NULL;
1955   __pyx_L0:;
1956   __Pyx_XGIVEREF(__pyx_r);
1957   __Pyx_RefNannyFinishContext();
1958   return __pyx_r;
1959 }
1960
1961 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":232
1962  *         return logmath_log_to_ln(self.lmath, ngram_zero(self.lm))
1963  * 
1964  *     def wid(self, word):             # <<<<<<<<<<<<<<
1965  *         """
1966  *         Get the internal ID for a word.
1967  */
1968
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;
1973   char *__pyx_t_1;
1974   PyObject *__pyx_t_2 = NULL;
1975   __Pyx_RefNannySetupContext("wid");
1976
1977   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":241
1978  *         @rtype: int
1979  *         """
1980  *         return ngram_wid(self.lm, word)             # <<<<<<<<<<<<<<
1981  * 
1982  *     def word(self, wid):
1983  */
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;
1989   __pyx_t_2 = 0;
1990   goto __pyx_L0;
1991
1992   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1993   goto __pyx_L0;
1994   __pyx_L1_error:;
1995   __Pyx_XDECREF(__pyx_t_2);
1996   __Pyx_AddTraceback("sphinxbase.NGramModel.wid");
1997   __pyx_r = NULL;
1998   __pyx_L0:;
1999   __Pyx_XGIVEREF(__pyx_r);
2000   __Pyx_RefNannyFinishContext();
2001   return __pyx_r;
2002 }
2003
2004 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":243
2005  *         return ngram_wid(self.lm, word)
2006  * 
2007  *     def word(self, wid):             # <<<<<<<<<<<<<<
2008  *         """
2009  *         Get the string corresponding to an internal word ID.
2010  */
2011
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");
2019
2020   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":252
2021  *         @rtype: string
2022  *         """
2023  *         return ngram_word(self.lm, wid)             # <<<<<<<<<<<<<<
2024  * 
2025  *     # Note that this and prob() are almost exactly the same...
2026  */
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);
2032   __pyx_t_2 = 0;
2033   goto __pyx_L0;
2034
2035   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2036   goto __pyx_L0;
2037   __pyx_L1_error:;
2038   __Pyx_XDECREF(__pyx_t_2);
2039   __Pyx_AddTraceback("sphinxbase.NGramModel.word");
2040   __pyx_r = NULL;
2041   __pyx_L0:;
2042   __Pyx_XGIVEREF(__pyx_r);
2043   __Pyx_RefNannyFinishContext();
2044   return __pyx_r;
2045 }
2046
2047 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":255
2048  * 
2049  *     # Note that this and prob() are almost exactly the same...
2050  *     def score(self, word, *args):             # <<<<<<<<<<<<<<
2051  *         """
2052  *         Get the score for an N-Gram.
2053  */
2054
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;
2068   char *__pyx_t_1;
2069   Py_ssize_t __pyx_t_2;
2070   __pyx_t_10sphinxbase_int32 __pyx_t_3;
2071   long __pyx_t_4;
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;
2080   } else {
2081     __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2082   }
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)) {
2087       default:
2088       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2089       case  0: break;
2090     }
2091     switch (PyTuple_GET_SIZE(__pyx_args)) {
2092       case  0:
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;
2096     }
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;}
2100     }
2101     __pyx_v_word = values[0];
2102   } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
2103     goto __pyx_L5_argtuple_error;
2104   } else {
2105     __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2106   }
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;}
2110   __pyx_L3_error:;
2111   __Pyx_DECREF(__pyx_v_args);
2112   __Pyx_AddTraceback("sphinxbase.NGramModel.score");
2113   return NULL;
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);
2119
2120   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":288
2121  *         cdef int32 n_used
2122  *         cdef int32 score
2123  *         wid = ngram_wid(self.lm, word)             # <<<<<<<<<<<<<<
2124  *         n_hist = len(args)
2125  *         hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2126  */
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);
2129
2130   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":289
2131  *         cdef int32 score
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:
2136  */
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;
2139
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:
2145  *             spam = args[i]
2146  */
2147   __pyx_v_hist = ((__pyx_t_10sphinxbase_int32 *)ckd_calloc(__pyx_v_n_hist, (sizeof(__pyx_t_10sphinxbase_int32))));
2148
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:             # <<<<<<<<<<<<<<
2153  *             spam = args[i]
2154  *             hist[i] = ngram_wid(self.lm, spam)
2155  */
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;
2162     __pyx_t_5 = 0;
2163
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)
2170  */
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;
2175     __pyx_t_5 = 0;
2176
2177     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":293
2178  *         for i from 0 <= i < n_hist:
2179  *             spam = args[i]
2180  *             hist[i] = ngram_wid(self.lm, spam)             # <<<<<<<<<<<<<<
2181  *         score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used)
2182  *         ckd_free(hist)
2183  */
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;}
2188   }
2189
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:             # <<<<<<<<<<<<<<
2194  *             spam = args[i]
2195  *             hist[i] = ngram_wid(self.lm, spam)
2196  */
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;
2201   __pyx_t_5 = 0;
2202
2203   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":294
2204  *             spam = args[i]
2205  *             hist[i] = ngram_wid(self.lm, spam)
2206  *         score = ngram_ng_score(self.lm, wid, hist, n_hist, &n_used)             # <<<<<<<<<<<<<<
2207  *         ckd_free(hist)
2208  *         return logmath_log_to_ln(self.lmath, score), n_used
2209  */
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));
2211
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
2217  * 
2218  */
2219   ckd_free(__pyx_v_hist);
2220
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)
2223  *         ckd_free(hist)
2224  *         return logmath_log_to_ln(self.lmath, score), n_used             # <<<<<<<<<<<<<<
2225  * 
2226  *     def prob(self, word, *args):
2227  */
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);
2239   __pyx_t_5 = 0;
2240   __pyx_t_6 = 0;
2241   __pyx_r = __pyx_t_7;
2242   __pyx_t_7 = 0;
2243   goto __pyx_L0;
2244
2245   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2246   goto __pyx_L0;
2247   __pyx_L1_error:;
2248   __Pyx_XDECREF(__pyx_t_5);
2249   __Pyx_XDECREF(__pyx_t_6);
2250   __Pyx_XDECREF(__pyx_t_7);
2251   __Pyx_AddTraceback("sphinxbase.NGramModel.score");
2252   __pyx_r = NULL;
2253   __pyx_L0:;
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();
2261   return __pyx_r;
2262 }
2263
2264 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":298
2265  *         return logmath_log_to_ln(self.lmath, score), n_used
2266  * 
2267  *     def prob(self, word, *args):             # <<<<<<<<<<<<<<
2268  *         """
2269  *         Get the log-probability for an N-Gram.
2270  */
2271
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;
2285   char *__pyx_t_1;
2286   Py_ssize_t __pyx_t_2;
2287   __pyx_t_10sphinxbase_int32 __pyx_t_3;
2288   long __pyx_t_4;
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;
2297   } else {
2298     __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2299   }
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)) {
2304       default:
2305       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2306       case  0: break;
2307     }
2308     switch (PyTuple_GET_SIZE(__pyx_args)) {
2309       case  0:
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;
2313     }
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;}
2317     }
2318     __pyx_v_word = values[0];
2319   } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
2320     goto __pyx_L5_argtuple_error;
2321   } else {
2322     __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2323   }
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;}
2327   __pyx_L3_error:;
2328   __Pyx_DECREF(__pyx_v_args);
2329   __Pyx_AddTraceback("sphinxbase.NGramModel.prob");
2330   return NULL;
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);
2336
2337   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":312
2338  *         cdef int32 n_used
2339  *         cdef int32 score
2340  *         wid = ngram_wid(self.lm, word)             # <<<<<<<<<<<<<<
2341  *         n_hist = len(args)
2342  *         hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2343  */
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);
2346
2347   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":313
2348  *         cdef int32 score
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:
2353  */
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;
2356
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:
2362  *             spam = args[i]
2363  */
2364   __pyx_v_hist = ((__pyx_t_10sphinxbase_int32 *)ckd_calloc(__pyx_v_n_hist, (sizeof(__pyx_t_10sphinxbase_int32))));
2365
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:             # <<<<<<<<<<<<<<
2370  *             spam = args[i]
2371  *             hist[i] = ngram_wid(self.lm, spam)
2372  */
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;
2379     __pyx_t_5 = 0;
2380
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)
2387  */
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;
2392     __pyx_t_5 = 0;
2393
2394     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":317
2395  *         for i from 0 <= i < n_hist:
2396  *             spam = args[i]
2397  *             hist[i] = ngram_wid(self.lm, spam)             # <<<<<<<<<<<<<<
2398  *         score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used)
2399  *         ckd_free(hist)
2400  */
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;}
2405   }
2406
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:             # <<<<<<<<<<<<<<
2411  *             spam = args[i]
2412  *             hist[i] = ngram_wid(self.lm, spam)
2413  */
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;
2418   __pyx_t_5 = 0;
2419
2420   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":318
2421  *             spam = args[i]
2422  *             hist[i] = ngram_wid(self.lm, spam)
2423  *         score = ngram_ng_prob(self.lm, wid, hist, n_hist, &n_used)             # <<<<<<<<<<<<<<
2424  *         ckd_free(hist)
2425  *         return logmath_log_to_ln(self.lmath, score), n_used
2426  */
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));
2428
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
2434  * 
2435  */
2436   ckd_free(__pyx_v_hist);
2437
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)
2440  *         ckd_free(hist)
2441  *         return logmath_log_to_ln(self.lmath, score), n_used             # <<<<<<<<<<<<<<
2442  * 
2443  *     def mgrams(self, m):
2444  */
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);
2456   __pyx_t_5 = 0;
2457   __pyx_t_6 = 0;
2458   __pyx_r = __pyx_t_7;
2459   __pyx_t_7 = 0;
2460   goto __pyx_L0;
2461
2462   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2463   goto __pyx_L0;
2464   __pyx_L1_error:;
2465   __Pyx_XDECREF(__pyx_t_5);
2466   __Pyx_XDECREF(__pyx_t_6);
2467   __Pyx_XDECREF(__pyx_t_7);
2468   __Pyx_AddTraceback("sphinxbase.NGramModel.prob");
2469   __pyx_r = NULL;
2470   __pyx_L0:;
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();
2478   return __pyx_r;
2479 }
2480
2481 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":322
2482  *         return logmath_log_to_ln(self.lmath, score), n_used
2483  * 
2484  *     def mgrams(self, m):             # <<<<<<<<<<<<<<
2485  *         """
2486  *         Return an iterator over each N-gram of order m+1.
2487  */
2488
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;
2496   int __pyx_t_3;
2497   __Pyx_RefNannySetupContext("mgrams");
2498   __pyx_v_itor = ((struct __pyx_obj_10sphinxbase_NGramIter *)Py_None); __Pyx_INCREF(Py_None);
2499
2500   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":335
2501  *         """
2502  *         cdef NGramIter itor
2503  *         itor = NGramIter(self, m)             # <<<<<<<<<<<<<<
2504  *         itor.itor = ngram_model_mgrams(self.lm, m)
2505  *         return itor
2506  */
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);
2520   __pyx_t_2 = 0;
2521
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)             # <<<<<<<<<<<<<<
2526  *         return itor
2527  * 
2528  */
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);
2531
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             # <<<<<<<<<<<<<<
2536  * 
2537  *     def ngram(self, word, *args):
2538  */
2539   __Pyx_XDECREF(__pyx_r);
2540   __Pyx_INCREF(((PyObject *)__pyx_v_itor));
2541   __pyx_r = ((PyObject *)__pyx_v_itor);
2542   goto __pyx_L0;
2543
2544   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2545   goto __pyx_L0;
2546   __pyx_L1_error:;
2547   __Pyx_XDECREF(__pyx_t_1);
2548   __Pyx_XDECREF(__pyx_t_2);
2549   __Pyx_AddTraceback("sphinxbase.NGramModel.mgrams");
2550   __pyx_r = NULL;
2551   __pyx_L0:;
2552   __Pyx_DECREF((PyObject *)__pyx_v_itor);
2553   __Pyx_XGIVEREF(__pyx_r);
2554   __Pyx_RefNannyFinishContext();
2555   return __pyx_r;
2556 }
2557
2558 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":339
2559  *         return itor
2560  * 
2561  *     def ngram(self, word, *args):             # <<<<<<<<<<<<<<
2562  *         """
2563  *         Return an N-Gram iterator pointing to a given N-gram.
2564  */
2565
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;
2578   char *__pyx_t_1;
2579   Py_ssize_t __pyx_t_2;
2580   __pyx_t_10sphinxbase_int32 __pyx_t_3;
2581   long __pyx_t_4;
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;
2589   } else {
2590     __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
2591   }
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)) {
2596       default:
2597       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2598       case  0: break;
2599     }
2600     switch (PyTuple_GET_SIZE(__pyx_args)) {
2601       case  0:
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;
2605     }
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;}
2609     }
2610     __pyx_v_word = values[0];
2611   } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
2612     goto __pyx_L5_argtuple_error;
2613   } else {
2614     __pyx_v_word = PyTuple_GET_ITEM(__pyx_args, 0);
2615   }
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;}
2619   __pyx_L3_error:;
2620   __Pyx_DECREF(__pyx_v_args);
2621   __Pyx_AddTraceback("sphinxbase.NGramModel.ngram");
2622   return NULL;
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);
2629
2630   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":356
2631  *         cdef int32 *hist
2632  *         cdef int32 n_hist
2633  *         wid = ngram_wid(self.lm, word)             # <<<<<<<<<<<<<<
2634  *         n_hist = len(args)
2635  *         hist = <int32 *>ckd_calloc(n_hist, sizeof(int32))
2636  */
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);
2639
2640   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":357
2641  *         cdef int32 n_hist
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:
2646  */
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;
2649
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:
2655  *             spam = args[i]
2656  */
2657   __pyx_v_hist = ((__pyx_t_10sphinxbase_int32 *)ckd_calloc(__pyx_v_n_hist, (sizeof(__pyx_t_10sphinxbase_int32))));
2658
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:             # <<<<<<<<<<<<<<
2663  *             spam = args[i]
2664  *             hist[i] = ngram_wid(self.lm, spam)
2665  */
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;
2672     __pyx_t_5 = 0;
2673
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)
2680  */
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;
2685     __pyx_t_5 = 0;
2686
2687     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":361
2688  *         for i from 0 <= i < n_hist:
2689  *             spam = args[i]
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
2693  */
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;}
2698   }
2699
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:             # <<<<<<<<<<<<<<
2704  *             spam = args[i]
2705  *             hist[i] = ngram_wid(self.lm, spam)
2706  */
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;
2711   __pyx_t_5 = 0;
2712
2713   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":362
2714  *             spam = args[i]
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.
2719  */
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);
2729   __pyx_t_5 = 0;
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);
2735   __pyx_t_5 = 0;
2736
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))             # <<<<<<<<<<<<<<
2741  *         ckd_free(hist)
2742  *         return itor
2743  */
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;
2747
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)             # <<<<<<<<<<<<<<
2752  *         return itor
2753  * 
2754  */
2755   ckd_free(__pyx_v_hist);
2756
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))
2759  *         ckd_free(hist)
2760  *         return itor             # <<<<<<<<<<<<<<
2761  * 
2762  *     def add_word(self, word, weight=1.0):
2763  */
2764   __Pyx_XDECREF(__pyx_r);
2765   __Pyx_INCREF(((PyObject *)__pyx_v_itor));
2766   __pyx_r = ((PyObject *)__pyx_v_itor);
2767   goto __pyx_L0;
2768
2769   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2770   goto __pyx_L0;
2771   __pyx_L1_error:;
2772   __Pyx_XDECREF(__pyx_t_5);
2773   __Pyx_XDECREF(__pyx_t_6);
2774   __Pyx_AddTraceback("sphinxbase.NGramModel.ngram");
2775   __pyx_r = NULL;
2776   __pyx_L0:;
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();
2785   return __pyx_r;
2786 }
2787
2788 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":369
2789  *         return itor
2790  * 
2791  *     def add_word(self, word, weight=1.0):             # <<<<<<<<<<<<<<
2792  *         return ngram_model_add_word(self.lm, word, weight)
2793  * 
2794  */
2795
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;
2801   char *__pyx_t_1;
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);
2813       case  0: break;
2814       default: goto __pyx_L5_argtuple_error;
2815     }
2816     switch (PyTuple_GET_SIZE(__pyx_args)) {
2817       case  0:
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;
2821       case  1:
2822       if (kw_args > 1) {
2823         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__weight);
2824         if (unlikely(value)) { values[1] = value; kw_args--; }
2825       }
2826     }
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;}
2829     }
2830     __pyx_v_word = values[0];
2831     __pyx_v_weight = values[1];
2832   } else {
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);
2837       break;
2838       default: goto __pyx_L5_argtuple_error;
2839     }
2840   }
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;}
2844   __pyx_L3_error:;
2845   __Pyx_AddTraceback("sphinxbase.NGramModel.add_word");
2846   return NULL;
2847   __pyx_L4_argument_unpacking_done:;
2848
2849   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":370
2850  * 
2851  *     def add_word(self, word, weight=1.0):
2852  *         return ngram_model_add_word(self.lm, word, weight)             # <<<<<<<<<<<<<<
2853  * 
2854  *     def recode(self, frum, too):
2855  */
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;
2862   __pyx_t_3 = 0;
2863   goto __pyx_L0;
2864
2865   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2866   goto __pyx_L0;
2867   __pyx_L1_error:;
2868   __Pyx_XDECREF(__pyx_t_3);
2869   __Pyx_AddTraceback("sphinxbase.NGramModel.add_word");
2870   __pyx_r = NULL;
2871   __pyx_L0:;
2872   __Pyx_XGIVEREF(__pyx_r);
2873   __Pyx_RefNannyFinishContext();
2874   return __pyx_r;
2875 }
2876
2877 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":372
2878  *         return ngram_model_add_word(self.lm, word, weight)
2879  * 
2880  *     def recode(self, frum, too):             # <<<<<<<<<<<<<<
2881  *         cdef int rv
2882  *         rv = ngram_model_recode(self.lm, frum, too)
2883  */
2884
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;
2889   int __pyx_v_rv;
2890   PyObject *__pyx_r = NULL;
2891   char *__pyx_t_1;
2892   char *__pyx_t_2;
2893   int __pyx_t_3;
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);
2904       case  0: break;
2905       default: goto __pyx_L5_argtuple_error;
2906     }
2907     switch (PyTuple_GET_SIZE(__pyx_args)) {
2908       case  0:
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;
2912       case  1:
2913       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__too);
2914       if (likely(values[1])) kw_args--;
2915       else {
2916         __Pyx_RaiseArgtupleInvalid("recode", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2917       }
2918     }
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;}
2921     }
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;
2926   } else {
2927     __pyx_v_frum = PyTuple_GET_ITEM(__pyx_args, 0);
2928     __pyx_v_too = PyTuple_GET_ITEM(__pyx_args, 1);
2929   }
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;}
2933   __pyx_L3_error:;
2934   __Pyx_AddTraceback("sphinxbase.NGramModel.recode");
2935   return NULL;
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);
2940
2941   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":374
2942  *     def recode(self, frum, too):
2943  *         cdef int rv
2944  *         rv = ngram_model_recode(self.lm, frum, too)             # <<<<<<<<<<<<<<
2945  *         if rv == -1:
2946  *             raise ValueError, "Recode from %s to %s failed" % (frum, too)
2947  */
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);
2951
2952   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":375
2953  *         cdef int rv
2954  *         rv = ngram_model_recode(self.lm, frum, too)
2955  *         if rv == -1:             # <<<<<<<<<<<<<<
2956  *             raise ValueError, "Recode from %s to %s failed" % (frum, too)
2957  * 
2958  */
2959   __pyx_t_3 = (__pyx_v_rv == -1);
2960   if (__pyx_t_3) {
2961
2962     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":376
2963  *         rv = ngram_model_recode(self.lm, frum, too)
2964  *         if rv == -1:
2965  *             raise ValueError, "Recode from %s to %s failed" % (frum, too)             # <<<<<<<<<<<<<<
2966  * 
2967  *     def casefold(self, kase):
2968  */
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;}
2983     goto __pyx_L6;
2984   }
2985   __pyx_L6:;
2986
2987   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2988   goto __pyx_L0;
2989   __pyx_L1_error:;
2990   __Pyx_XDECREF(__pyx_t_4);
2991   __Pyx_XDECREF(__pyx_t_5);
2992   __Pyx_AddTraceback("sphinxbase.NGramModel.recode");
2993   __pyx_r = NULL;
2994   __pyx_L0:;
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();
3000   return __pyx_r;
3001 }
3002
3003 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":378
3004  *             raise ValueError, "Recode from %s to %s failed" % (frum, too)
3005  * 
3006  *     def casefold(self, kase):             # <<<<<<<<<<<<<<
3007  *         cdef int rv
3008  *         rv = ngram_model_casefold(self.lm, kase)
3009  */
3010
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) {
3013   int __pyx_v_rv;
3014   PyObject *__pyx_r = NULL;
3015   ngram_case_t __pyx_t_1;
3016   int __pyx_t_2;
3017   __Pyx_RefNannySetupContext("casefold");
3018   __Pyx_INCREF((PyObject *)__pyx_v_self);
3019   __Pyx_INCREF(__pyx_v_kase);
3020
3021   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":380
3022  *     def casefold(self, kase):
3023  *         cdef int rv
3024  *         rv = ngram_model_casefold(self.lm, kase)             # <<<<<<<<<<<<<<
3025  *         if rv == -1:
3026  *             raise ValueError, "Casefolding failed"
3027  */
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);
3030
3031   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":381
3032  *         cdef int rv
3033  *         rv = ngram_model_casefold(self.lm, kase)
3034  *         if rv == -1:             # <<<<<<<<<<<<<<
3035  *             raise ValueError, "Casefolding failed"
3036  * 
3037  */
3038   __pyx_t_2 = (__pyx_v_rv == -1);
3039   if (__pyx_t_2) {
3040
3041     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":382
3042  *         rv = ngram_model_casefold(self.lm, kase)
3043  *         if rv == -1:
3044  *             raise ValueError, "Casefolding failed"             # <<<<<<<<<<<<<<
3045  * 
3046  *     def write(self, file_name, format=NGRAM_AUTO):
3047  */
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;}
3050     goto __pyx_L5;
3051   }
3052   __pyx_L5:;
3053
3054   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3055   goto __pyx_L0;
3056   __pyx_L1_error:;
3057   __Pyx_AddTraceback("sphinxbase.NGramModel.casefold");
3058   __pyx_r = NULL;
3059   __pyx_L0:;
3060   __Pyx_DECREF((PyObject *)__pyx_v_self);
3061   __Pyx_DECREF(__pyx_v_kase);
3062   __Pyx_XGIVEREF(__pyx_r);
3063   __Pyx_RefNannyFinishContext();
3064   return __pyx_r;
3065 }
3066
3067 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":384
3068  *             raise ValueError, "Casefolding failed"
3069  * 
3070  *     def write(self, file_name, format=NGRAM_AUTO):             # <<<<<<<<<<<<<<
3071  *         cdef int rv
3072  *         rv = ngram_model_write(self.lm, file_name, format)
3073  */
3074
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;
3079   int __pyx_v_rv;
3080   PyObject *__pyx_r = NULL;
3081   char *__pyx_t_1;
3082   ngram_file_type_t __pyx_t_2;
3083   int __pyx_t_3;
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);
3094       case  0: break;
3095       default: goto __pyx_L5_argtuple_error;
3096     }
3097     switch (PyTuple_GET_SIZE(__pyx_args)) {
3098       case  0:
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;
3102       case  1:
3103       if (kw_args > 1) {
3104         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__format);
3105         if (unlikely(value)) { values[1] = value; kw_args--; }
3106       }
3107     }
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;}
3110     }
3111     __pyx_v_file_name = values[0];
3112     __pyx_v_format = values[1];
3113   } else {
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);
3118       break;
3119       default: goto __pyx_L5_argtuple_error;
3120     }
3121   }
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;}
3125   __pyx_L3_error:;
3126   __Pyx_AddTraceback("sphinxbase.NGramModel.write");
3127   return NULL;
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);
3132
3133   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":386
3134  *     def write(self, file_name, format=NGRAM_AUTO):
3135  *         cdef int rv
3136  *         rv = ngram_model_write(self.lm, file_name, format)             # <<<<<<<<<<<<<<
3137  *         if rv == -1:
3138  *             raise ValueError, "Write %s to file failed" % file_name
3139  */
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);
3143
3144   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":387
3145  *         cdef int rv
3146  *         rv = ngram_model_write(self.lm, file_name, format)
3147  *         if rv == -1:             # <<<<<<<<<<<<<<
3148  *             raise ValueError, "Write %s to file failed" % file_name
3149  * 
3150  */
3151   __pyx_t_3 = (__pyx_v_rv == -1);
3152   if (__pyx_t_3) {
3153
3154     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":388
3155  *         rv = ngram_model_write(self.lm, file_name, format)
3156  *         if rv == -1:
3157  *             raise ValueError, "Write %s to file failed" % file_name             # <<<<<<<<<<<<<<
3158  * 
3159  * cdef class NGramIter:
3160  */
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;}
3166     goto __pyx_L6;
3167   }
3168   __pyx_L6:;
3169
3170   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3171   goto __pyx_L0;
3172   __pyx_L1_error:;
3173   __Pyx_XDECREF(__pyx_t_4);
3174   __Pyx_AddTraceback("sphinxbase.NGramModel.write");
3175   __pyx_r = NULL;
3176   __pyx_L0:;
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();
3182   return __pyx_r;
3183 }
3184
3185 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":397
3186  *     language model.
3187  *     """
3188  *     def __cinit__(self, NGramModel lm, int m):             # <<<<<<<<<<<<<<
3189  *         self.itor = NULL
3190  *         self.lm = lm
3191  */
3192
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;
3196   int __pyx_v_m;
3197   int __pyx_r;
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);
3206       case  0: break;
3207       default: goto __pyx_L5_argtuple_error;
3208     }
3209     switch (PyTuple_GET_SIZE(__pyx_args)) {
3210       case  0:
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;
3214       case  1:
3215       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__m);
3216       if (likely(values[1])) kw_args--;
3217       else {
3218         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3219       }
3220     }
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;}
3223     }
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;
3228   } else {
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;}
3231   }
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;}
3235   __pyx_L3_error:;
3236   __Pyx_AddTraceback("sphinxbase.NGramIter.__cinit__");
3237   return -1;
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;}
3240
3241   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":398
3242  *     """
3243  *     def __cinit__(self, NGramModel lm, int m):
3244  *         self.itor = NULL             # <<<<<<<<<<<<<<
3245  *         self.lm = lm
3246  *         self.m = m
3247  */
3248   ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->itor = NULL;
3249
3250   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":399
3251  *     def __cinit__(self, NGramModel lm, int m):
3252  *         self.itor = NULL
3253  *         self.lm = lm             # <<<<<<<<<<<<<<
3254  *         self.m = m
3255  *         self.first_item = True
3256  */
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;
3262
3263   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":400
3264  *         self.itor = NULL
3265  *         self.lm = lm
3266  *         self.m = m             # <<<<<<<<<<<<<<
3267  *         self.first_item = True
3268  * 
3269  */
3270   ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->m = __pyx_v_m;
3271
3272   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":401
3273  *         self.lm = lm
3274  *         self.m = m
3275  *         self.first_item = True             # <<<<<<<<<<<<<<
3276  * 
3277  *     def __iter__(self):
3278  */
3279   ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->first_item = 1;
3280
3281   __pyx_r = 0;
3282   goto __pyx_L0;
3283   __pyx_L1_error:;
3284   __Pyx_AddTraceback("sphinxbase.NGramIter.__cinit__");
3285   __pyx_r = -1;
3286   __pyx_L0:;
3287   __Pyx_RefNannyFinishContext();
3288   return __pyx_r;
3289 }
3290
3291 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":403
3292  *         self.first_item = True
3293  * 
3294  *     def __iter__(self):             # <<<<<<<<<<<<<<
3295  *         self.first_item = True
3296  *         return self
3297  */
3298
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__");
3303
3304   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":404
3305  * 
3306  *     def __iter__(self):
3307  *         self.first_item = True             # <<<<<<<<<<<<<<
3308  *         return self
3309  * 
3310  */
3311   ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->first_item = 1;
3312
3313   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":405
3314  *     def __iter__(self):
3315  *         self.first_item = True
3316  *         return self             # <<<<<<<<<<<<<<
3317  * 
3318  *     cdef set_iter(NGramIter self, ngram_iter_t *itor):
3319  */
3320   __Pyx_XDECREF(__pyx_r);
3321   __Pyx_INCREF(__pyx_v_self);
3322   __pyx_r = __pyx_v_self;
3323   goto __pyx_L0;
3324
3325   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3326   __pyx_L0:;
3327   __Pyx_XGIVEREF(__pyx_r);
3328   __Pyx_RefNannyFinishContext();
3329   return __pyx_r;
3330 }
3331
3332 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":407
3333  *         return self
3334  * 
3335  *     cdef set_iter(NGramIter self, ngram_iter_t *itor):             # <<<<<<<<<<<<<<
3336  *         cdef int32 prob, bowt
3337  *         cdef int32 *wids
3338  */
3339
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;
3346   int __pyx_t_1;
3347   int __pyx_t_2;
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);
3356
3357   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":411
3358  *         cdef int32 *wids
3359  * 
3360  *         if itor == NULL:             # <<<<<<<<<<<<<<
3361  *             raise StopIteration
3362  *         self.itor = itor
3363  */
3364   __pyx_t_1 = (__pyx_v_itor == NULL);
3365   if (__pyx_t_1) {
3366
3367     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":412
3368  * 
3369  *         if itor == NULL:
3370  *             raise StopIteration             # <<<<<<<<<<<<<<
3371  *         self.itor = itor
3372  *         if self.first_item:
3373  */
3374     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
3375     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3376     goto __pyx_L3;
3377   }
3378   __pyx_L3:;
3379
3380   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":413
3381  *         if itor == NULL:
3382  *             raise StopIteration
3383  *         self.itor = itor             # <<<<<<<<<<<<<<
3384  *         if self.first_item:
3385  *             self.first_item = False
3386  */
3387   __pyx_v_self->itor = __pyx_v_itor;
3388
3389   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":414
3390  *             raise StopIteration
3391  *         self.itor = itor
3392  *         if self.first_item:             # <<<<<<<<<<<<<<
3393  *             self.first_item = False
3394  *         wids = ngram_iter_get(itor, &prob, &bowt)
3395  */
3396   __pyx_t_2 = __pyx_v_self->first_item;
3397   if (__pyx_t_2) {
3398
3399     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":415
3400  *         self.itor = itor
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)
3405  */
3406     __pyx_v_self->first_item = 0;
3407     goto __pyx_L4;
3408   }
3409   __pyx_L4:;
3410
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)
3417  */
3418   __pyx_v_wids = ngram_iter_get(__pyx_v_itor, (&__pyx_v_prob), (&__pyx_v_bowt));
3419
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)
3425  *         self.words = []
3426  */
3427   __pyx_v_self->log_prob = logmath_log_to_ln(__pyx_v_self->lm->lmath, __pyx_v_prob);
3428
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)             # <<<<<<<<<<<<<<
3433  *         self.words = []
3434  *         for i in range(0, self.m+1):
3435  */
3436   __pyx_v_self->log_bowt = logmath_log_to_ln(__pyx_v_self->lm->lmath, __pyx_v_bowt);
3437
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]))
3444  */
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);
3451   __pyx_t_3 = 0;
3452
3453   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":420
3454  *         self.log_bowt = logmath_log_to_ln(self.lm.lmath, bowt)
3455  *         self.words = []
3456  *         for i in range(0, self.m+1):             # <<<<<<<<<<<<<<
3457  *             self.words.append(ngram_word(self.lm.lm, wids[i]))
3458  * 
3459  */
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);
3469   __pyx_t_3 = 0;
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);
3475   } else {
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);
3478   }
3479   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3480   for (;;) {
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++;
3487     } else {
3488       __pyx_t_3 = PyIter_Next(__pyx_t_5);
3489       if (!__pyx_t_3) {
3490         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3491         break;
3492       }
3493       __Pyx_GOTREF(__pyx_t_3);
3494     }
3495     __Pyx_DECREF(__pyx_v_i);
3496     __pyx_v_i = __pyx_t_3;
3497     __pyx_t_3 = 0;
3498
3499     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":421
3500  *         self.words = []
3501  *         for i in range(0, self.m+1):
3502  *             self.words.append(ngram_word(self.lm.lm, wids[i]))             # <<<<<<<<<<<<<<
3503  * 
3504  *     def __next__(self):
3505  */
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;
3513   }
3514   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3515
3516   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3517   goto __pyx_L0;
3518   __pyx_L1_error:;
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");
3523   __pyx_r = 0;
3524   __pyx_L0:;
3525   __Pyx_DECREF(__pyx_v_i);
3526   __Pyx_DECREF((PyObject *)__pyx_v_self);
3527   __Pyx_XGIVEREF(__pyx_r);
3528   __Pyx_RefNannyFinishContext();
3529   return __pyx_r;
3530 }
3531
3532 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":423
3533  *             self.words.append(ngram_word(self.lm.lm, wids[i]))
3534  * 
3535  *     def __next__(self):             # <<<<<<<<<<<<<<
3536  *         if self.first_item:
3537  *             self.set_iter(self.itor)
3538  */
3539
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;
3543   int __pyx_t_1;
3544   PyObject *__pyx_t_2 = NULL;
3545   __Pyx_RefNannySetupContext("__next__");
3546   __Pyx_INCREF((PyObject *)__pyx_v_self);
3547
3548   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":424
3549  * 
3550  *     def __next__(self):
3551  *         if self.first_item:             # <<<<<<<<<<<<<<
3552  *             self.set_iter(self.itor)
3553  *         else:
3554  */
3555   __pyx_t_1 = ((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->first_item;
3556   if (__pyx_t_1) {
3557
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)             # <<<<<<<<<<<<<<
3562  *         else:
3563  *             self.set_iter(ngram_iter_next(self.itor))
3564  */
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;
3568     goto __pyx_L5;
3569   }
3570   /*else*/ {
3571
3572     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":427
3573  *             self.set_iter(self.itor)
3574  *         else:
3575  *             self.set_iter(ngram_iter_next(self.itor))             # <<<<<<<<<<<<<<
3576  *         return self
3577  * 
3578  */
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;
3582   }
3583   __pyx_L5:;
3584
3585   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":428
3586  *         else:
3587  *             self.set_iter(ngram_iter_next(self.itor))
3588  *         return self             # <<<<<<<<<<<<<<
3589  * 
3590  *     def successors(self):
3591  */
3592   __Pyx_XDECREF(__pyx_r);
3593   __Pyx_INCREF(__pyx_v_self);
3594   __pyx_r = __pyx_v_self;
3595   goto __pyx_L0;
3596
3597   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3598   goto __pyx_L0;
3599   __pyx_L1_error:;
3600   __Pyx_XDECREF(__pyx_t_2);
3601   __Pyx_AddTraceback("sphinxbase.NGramIter.__next__");
3602   __pyx_r = NULL;
3603   __pyx_L0:;
3604   __Pyx_DECREF((PyObject *)__pyx_v_self);
3605   __Pyx_XGIVEREF(__pyx_r);
3606   __Pyx_RefNannyFinishContext();
3607   return __pyx_r;
3608 }
3609
3610 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":430
3611  *         return self
3612  * 
3613  *     def successors(self):             # <<<<<<<<<<<<<<
3614  *         """
3615  *         Get an iterator over N+1-gram successors of an N-gram.
3616  */
3617
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);
3627
3628   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":435
3629  *         """
3630  *         cdef NGramIter itor
3631  *         itor = NGramIter(self.lm, self.m + 1)             # <<<<<<<<<<<<<<
3632  *         itor.itor = ngram_iter_successors(self.itor)
3633  *         return itor
3634  */
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);
3644   __pyx_t_1 = 0;
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);
3650   __pyx_t_1 = 0;
3651
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)             # <<<<<<<<<<<<<<
3656  *         return itor
3657  * 
3658  */
3659   __pyx_v_itor->itor = ngram_iter_successors(((struct __pyx_obj_10sphinxbase_NGramIter *)__pyx_v_self)->itor);
3660
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             # <<<<<<<<<<<<<<
3665  * 
3666  * def binstr(str val, int nbits):
3667  */
3668   __Pyx_XDECREF(__pyx_r);
3669   __Pyx_INCREF(((PyObject *)__pyx_v_itor));
3670   __pyx_r = ((PyObject *)__pyx_v_itor);
3671   goto __pyx_L0;
3672
3673   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3674   goto __pyx_L0;
3675   __pyx_L1_error:;
3676   __Pyx_XDECREF(__pyx_t_1);
3677   __Pyx_XDECREF(__pyx_t_2);
3678   __Pyx_AddTraceback("sphinxbase.NGramIter.successors");
3679   __pyx_r = NULL;
3680   __pyx_L0:;
3681   __Pyx_DECREF((PyObject *)__pyx_v_itor);
3682   __Pyx_XGIVEREF(__pyx_r);
3683   __Pyx_RefNannyFinishContext();
3684   return __pyx_r;
3685 }
3686
3687 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":439
3688  *         return itor
3689  * 
3690  * def binstr(str val, int nbits):             # <<<<<<<<<<<<<<
3691  *     """
3692  *     Silly function to format a string as a binary string
3693  */
3694
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;
3699   int __pyx_v_nbits;
3700   int __pyx_v_i;
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;
3710   long __pyx_t_5;
3711   int __pyx_t_6;
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);
3721       case  0: break;
3722       default: goto __pyx_L5_argtuple_error;
3723     }
3724     switch (PyTuple_GET_SIZE(__pyx_args)) {
3725       case  0:
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;
3729       case  1:
3730       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbits);
3731       if (likely(values[1])) kw_args--;
3732       else {
3733         __Pyx_RaiseArgtupleInvalid("binstr", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3734       }
3735     }
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;}
3738     }
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;
3743   } else {
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;}
3746   }
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;}
3750   __pyx_L3_error:;
3751   __Pyx_AddTraceback("sphinxbase.binstr");
3752   return NULL;
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;}
3760
3761   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":444
3762  *     """
3763  *     cdef int i
3764  *     outstr = ""             # <<<<<<<<<<<<<<
3765  *     for c in val:
3766  *         cval = ord(c)
3767  */
3768   __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
3769   __Pyx_DECREF(__pyx_v_outstr);
3770   __pyx_v_outstr = ((PyObject *)__pyx_kp_s_13);
3771
3772   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":445
3773  *     cdef int i
3774  *     outstr = ""
3775  *     for c in val:             # <<<<<<<<<<<<<<
3776  *         cval = ord(c)
3777  *         cnb = min(8, nbits)
3778  */
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);
3781   for (;;) {
3782     {
3783       __pyx_t_3 = PyIter_Next(__pyx_t_2);
3784       if (!__pyx_t_3) {
3785         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3786         break;
3787       }
3788       __Pyx_GOTREF(__pyx_t_3);
3789     }
3790     __Pyx_DECREF(__pyx_v_c);
3791     __pyx_v_c = __pyx_t_3;
3792     __pyx_t_3 = 0;
3793
3794     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":446
3795  *     outstr = ""
3796  *     for c in val:
3797  *         cval = ord(c)             # <<<<<<<<<<<<<<
3798  *         cnb = min(8, nbits)
3799  *         for i in range(0,cnb):
3800  */
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;
3811     __pyx_t_4 = 0;
3812
3813     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":447
3814  *     for c in val:
3815  *         cval = ord(c)
3816  *         cnb = min(8, nbits)             # <<<<<<<<<<<<<<
3817  *         for i in range(0,cnb):
3818  *             outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3819  */
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);
3829     __pyx_t_4 = 0;
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;
3835     __pyx_t_4 = 0;
3836
3837     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":448
3838  *         cval = ord(c)
3839  *         cnb = min(8, nbits)
3840  *         for i in range(0,cnb):             # <<<<<<<<<<<<<<
3841  *             outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3842  *         nbits -= 8
3843  */
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;
3847
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)             # <<<<<<<<<<<<<<
3852  *         nbits -= 8
3853  *     return outstr
3854  */
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;
3871       __pyx_t_4 = 0;
3872     }
3873
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             # <<<<<<<<<<<<<<
3878  *     return outstr
3879  * 
3880  */
3881     __pyx_v_nbits -= 8;
3882   }
3883   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3884
3885   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":451
3886  *             outstr += "%d" % ((cval & (1 << 7-i)) != 0)
3887  *         nbits -= 8
3888  *     return outstr             # <<<<<<<<<<<<<<
3889  * 
3890  * def bincw(int cw, int nbits):
3891  */
3892   __Pyx_XDECREF(__pyx_r);
3893   __Pyx_INCREF(__pyx_v_outstr);
3894   __pyx_r = __pyx_v_outstr;
3895   goto __pyx_L0;
3896
3897   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3898   goto __pyx_L0;
3899   __pyx_L1_error:;
3900   __Pyx_XDECREF(__pyx_t_2);
3901   __Pyx_XDECREF(__pyx_t_3);
3902   __Pyx_XDECREF(__pyx_t_4);
3903   __Pyx_AddTraceback("sphinxbase.binstr");
3904   __pyx_r = NULL;
3905   __pyx_L0:;
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();
3913   return __pyx_r;
3914 }
3915
3916 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":453
3917  *     return outstr
3918  * 
3919  * def bincw(int cw, int nbits):             # <<<<<<<<<<<<<<
3920  *     """
3921  *     Silly function to format an int as a binary string
3922  */
3923
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) {
3927   int __pyx_v_cw;
3928   int __pyx_v_nbits;
3929   int __pyx_v_i;
3930   PyObject *__pyx_v_outstr;
3931   PyObject *__pyx_r = NULL;
3932   int __pyx_t_1;
3933   int __pyx_t_2;
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);
3945       case  0: break;
3946       default: goto __pyx_L5_argtuple_error;
3947     }
3948     switch (PyTuple_GET_SIZE(__pyx_args)) {
3949       case  0:
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;
3953       case  1:
3954       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__nbits);
3955       if (likely(values[1])) kw_args--;
3956       else {
3957         __Pyx_RaiseArgtupleInvalid("bincw", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3958       }
3959     }
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;}
3962     }
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;
3967   } else {
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;}
3970   }
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;}
3974   __pyx_L3_error:;
3975   __Pyx_AddTraceback("sphinxbase.bincw");
3976   return NULL;
3977   __pyx_L4_argument_unpacking_done:;
3978   __pyx_v_outstr = Py_None; __Pyx_INCREF(Py_None);
3979
3980   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":458
3981  *     """
3982  *     cdef int i
3983  *     outstr = ""             # <<<<<<<<<<<<<<
3984  *     for i in range(0,nbits):
3985  *         outstr = "%s" % (cw & 1) + outstr
3986  */
3987   __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
3988   __Pyx_DECREF(__pyx_v_outstr);
3989   __pyx_v_outstr = ((PyObject *)__pyx_kp_s_13);
3990
3991   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":459
3992  *     cdef int i
3993  *     outstr = ""
3994  *     for i in range(0,nbits):             # <<<<<<<<<<<<<<
3995  *         outstr = "%s" % (cw & 1) + outstr
3996  *         cw >>= 1
3997  */
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;
4001
4002     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":460
4003  *     outstr = ""
4004  *     for i in range(0,nbits):
4005  *         outstr = "%s" % (cw & 1) + outstr             # <<<<<<<<<<<<<<
4006  *         cw >>= 1
4007  *     return outstr
4008  */
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;
4019     __pyx_t_3 = 0;
4020
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             # <<<<<<<<<<<<<<
4025  *     return outstr
4026  * 
4027  */
4028     __pyx_v_cw >>= 1;
4029   }
4030
4031   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":462
4032  *         outstr = "%s" % (cw & 1) + outstr
4033  *         cw >>= 1
4034  *     return outstr             # <<<<<<<<<<<<<<
4035  * 
4036  * # FIXME: Due to the style of IO in huff_code API this part of the code
4037  */
4038   __Pyx_XDECREF(__pyx_r);
4039   __Pyx_INCREF(__pyx_v_outstr);
4040   __pyx_r = __pyx_v_outstr;
4041   goto __pyx_L0;
4042
4043   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4044   goto __pyx_L0;
4045   __pyx_L1_error:;
4046   __Pyx_XDECREF(__pyx_t_3);
4047   __Pyx_XDECREF(__pyx_t_4);
4048   __Pyx_AddTraceback("sphinxbase.bincw");
4049   __pyx_r = NULL;
4050   __pyx_L0:;
4051   __Pyx_DECREF(__pyx_v_outstr);
4052   __Pyx_XGIVEREF(__pyx_r);
4053   __Pyx_RefNannyFinishContext();
4054   return __pyx_r;
4055 }
4056
4057 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":482
4058  *     @type infile: file | str
4059  *     """
4060  *     def __init__(self, alphabet=None, infile=None):             # <<<<<<<<<<<<<<
4061  *         cdef char **symbols
4062  *         cdef int *frequencies
4063  */
4064
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;
4071   int __pyx_v_nsym;
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;
4077   int __pyx_r;
4078   PyObject *__pyx_t_1 = NULL;
4079   int __pyx_t_2;
4080   int __pyx_t_3;
4081   int __pyx_t_4;
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;
4087   int __pyx_t_10;
4088   Py_ssize_t __pyx_t_11;
4089   char *__pyx_t_12;
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);
4100       case  0: break;
4101       default: goto __pyx_L5_argtuple_error;
4102     }
4103     switch (PyTuple_GET_SIZE(__pyx_args)) {
4104       case  0:
4105       if (kw_args > 1) {
4106         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__alphabet);
4107         if (unlikely(value)) { values[0] = value; kw_args--; }
4108       }
4109       case  1:
4110       if (kw_args > 1) {
4111         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__infile);
4112         if (unlikely(value)) { values[1] = value; kw_args--; }
4113       }
4114     }
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;}
4117     }
4118     __pyx_v_alphabet = values[0];
4119     __pyx_v_infile = values[1];
4120   } else {
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);
4126       case  0: break;
4127       default: goto __pyx_L5_argtuple_error;
4128     }
4129   }
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;}
4133   __pyx_L3_error:;
4134   __Pyx_AddTraceback("sphinxbase.HuffCode.__init__");
4135   return -1;
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);
4145
4146   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":487
4147  *         cdef int nsym
4148  * 
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:
4152  */
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;
4157   if (__pyx_t_2) {
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;
4163   } else {
4164     __pyx_t_4 = __pyx_t_2;
4165   }
4166   if (__pyx_t_4) {
4167
4168     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":488
4169  * 
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"
4174  */
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;}
4177     goto __pyx_L6;
4178   }
4179   __pyx_L6:;
4180
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"
4186  * 
4187  */
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;
4192   if (__pyx_t_4) {
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;
4198   } else {
4199     __pyx_t_3 = __pyx_t_4;
4200   }
4201   if (__pyx_t_3) {
4202
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"             # <<<<<<<<<<<<<<
4207  * 
4208  *         self.fh = None
4209  */
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;}
4212     goto __pyx_L7;
4213   }
4214   __pyx_L7:;
4215
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"
4218  * 
4219  *         self.fh = None             # <<<<<<<<<<<<<<
4220  *         if infile:
4221  *             self.read(infile)
4222  */
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;
4228
4229   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":493
4230  * 
4231  *         self.fh = None
4232  *         if infile:             # <<<<<<<<<<<<<<
4233  *             self.read(infile)
4234  *             return
4235  */
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;}
4237   if (__pyx_t_3) {
4238
4239     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":494
4240  *         self.fh = None
4241  *         if infile:
4242  *             self.read(infile)             # <<<<<<<<<<<<<<
4243  *             return
4244  * 
4245  */
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;
4258
4259     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":495
4260  *         if infile:
4261  *             self.read(infile)
4262  *             return             # <<<<<<<<<<<<<<
4263  * 
4264  *         nsym = len(alphabet)
4265  */
4266     __pyx_r = 0;
4267     goto __pyx_L0;
4268     goto __pyx_L8;
4269   }
4270   __pyx_L8:;
4271
4272   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":497
4273  *             return
4274  * 
4275  *         nsym = len(alphabet)             # <<<<<<<<<<<<<<
4276  *         frequencies = <int *>ckd_calloc(nsym, sizeof(int))
4277  *         symbols = <char **>ckd_calloc(nsym, sizeof(char *))
4278  */
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;
4281
4282   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":498
4283  * 
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,
4288  */
4289   __pyx_v_frequencies = ((int *)ckd_calloc(__pyx_v_nsym, (sizeof(int))));
4290
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...
4297  */
4298   __pyx_v_symbols = ((char **)ckd_calloc(__pyx_v_nsym, (sizeof(char *))));
4299
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):
4305  *             sym, freq = spam
4306  */
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);
4311   __pyx_t_6 = 0;
4312
4313   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":503
4314  *         # otherwise we get random duplicates of the codewords...
4315  *         bogus = []
4316  *         for i, spam in enumerate(alphabet):             # <<<<<<<<<<<<<<
4317  *             sym, freq = spam
4318  *             bogus.append(repr(sym))
4319  */
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);
4324   } else {
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);
4327   }
4328   for (;;) {
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++;
4335     } else {
4336       __pyx_t_1 = PyIter_Next(__pyx_t_5);
4337       if (!__pyx_t_1) {
4338         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4339         break;
4340       }
4341       __Pyx_GOTREF(__pyx_t_1);
4342     }
4343     __Pyx_DECREF(__pyx_v_spam);
4344     __pyx_v_spam = __pyx_t_1;
4345     __pyx_t_1 = 0;
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;
4353     __pyx_t_1 = 0;
4354
4355     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":504
4356  *         bogus = []
4357  *         for i, spam in enumerate(alphabet):
4358  *             sym, freq = spam             # <<<<<<<<<<<<<<
4359  *             bogus.append(repr(sym))
4360  *             frequencies[i] = freq
4361  */
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;
4368       __pyx_t_1 = 0;
4369       __Pyx_DECREF(__pyx_v_freq);
4370       __pyx_v_freq = __pyx_t_8;
4371       __pyx_t_8 = 0;
4372     } else {
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;
4383       __pyx_t_1 = 0;
4384       __Pyx_DECREF(__pyx_v_freq);
4385       __pyx_v_freq = __pyx_t_8;
4386       __pyx_t_8 = 0;
4387     }
4388
4389     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":505
4390  *         for i, spam in enumerate(alphabet):
4391  *             sym, freq = spam
4392  *             bogus.append(repr(sym))             # <<<<<<<<<<<<<<
4393  *             frequencies[i] = freq
4394  *             symbols[i] = bogus[-1]
4395  */
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;
4402
4403     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":506
4404  *             sym, freq = spam
4405  *             bogus.append(repr(sym))
4406  *             frequencies[i] = freq             # <<<<<<<<<<<<<<
4407  *             symbols[i] = bogus[-1]
4408  *         self.hc = huff_code_build_str(symbols, frequencies, nsym)
4409  */
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;
4413
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)
4420  */
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;
4427   }
4428   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4429   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4430
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)
4436  *         ckd_free(symbols)
4437  */
4438   ((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc = huff_code_build_str(__pyx_v_symbols, __pyx_v_frequencies, __pyx_v_nsym);
4439
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)             # <<<<<<<<<<<<<<
4444  *         ckd_free(symbols)
4445  * 
4446  */
4447   ckd_free(__pyx_v_frequencies);
4448
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)             # <<<<<<<<<<<<<<
4453  * 
4454  *     def read(self, infile):
4455  */
4456   ckd_free(__pyx_v_symbols);
4457
4458   __pyx_r = 0;
4459   goto __pyx_L0;
4460   __pyx_L1_error:;
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__");
4467   __pyx_r = -1;
4468   __pyx_L0:;
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();
4478   return __pyx_r;
4479 }
4480
4481 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":512
4482  *         ckd_free(symbols)
4483  * 
4484  *     def read(self, infile):             # <<<<<<<<<<<<<<
4485  *         if not isinstance(infile, file):
4486  *             infile = file(infile, "rb")
4487  */
4488
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;
4492   int __pyx_t_1;
4493   int __pyx_t_2;
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);
4500
4501   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":513
4502  * 
4503  *     def read(self, infile):
4504  *         if not isinstance(infile, file):             # <<<<<<<<<<<<<<
4505  *             infile = file(infile, "rb")
4506  *         huff_code_free(self.hc)
4507  */
4508   __pyx_t_1 = PyObject_TypeCheck(__pyx_v_infile, ((PyTypeObject *)((PyObject*)&PyFile_Type))); 
4509   __pyx_t_2 = (!__pyx_t_1);
4510   if (__pyx_t_2) {
4511
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))
4518  */
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;
4532     __pyx_t_4 = 0;
4533     goto __pyx_L5;
4534   }
4535   __pyx_L5:;
4536
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))
4542  * 
4543  */
4544   huff_code_free(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc);
4545
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))             # <<<<<<<<<<<<<<
4550  * 
4551  *     def write(self, outfile):
4552  */
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;
4555
4556   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4557   goto __pyx_L0;
4558   __pyx_L1_error:;
4559   __Pyx_XDECREF(__pyx_t_3);
4560   __Pyx_XDECREF(__pyx_t_4);
4561   __Pyx_AddTraceback("sphinxbase.HuffCode.read");
4562   __pyx_r = NULL;
4563   __pyx_L0:;
4564   __Pyx_DECREF((PyObject *)__pyx_v_self);
4565   __Pyx_DECREF(__pyx_v_infile);
4566   __Pyx_XGIVEREF(__pyx_r);
4567   __Pyx_RefNannyFinishContext();
4568   return __pyx_r;
4569 }
4570
4571 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":518
4572  *         self.hc = huff_code_read(PyFile_AsFile(infile))
4573  * 
4574  *     def write(self, outfile):             # <<<<<<<<<<<<<<
4575  *         if not isinstance(outfile, file):
4576  *             outfile = file(outfile, "wb")
4577  */
4578
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;
4582   int __pyx_t_1;
4583   int __pyx_t_2;
4584   PyObject *__pyx_t_3 = NULL;
4585   PyObject *__pyx_t_4 = NULL;
4586   int __pyx_t_5;
4587   __Pyx_RefNannySetupContext("write");
4588   __Pyx_INCREF((PyObject *)__pyx_v_self);
4589   __Pyx_INCREF(__pyx_v_outfile);
4590
4591   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":519
4592  * 
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))
4597  */
4598   __pyx_t_1 = PyObject_TypeCheck(__pyx_v_outfile, ((PyTypeObject *)((PyObject*)&PyFile_Type))); 
4599   __pyx_t_2 = (!__pyx_t_1);
4600   if (__pyx_t_2) {
4601
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))
4607  * 
4608  */
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;
4622     __pyx_t_4 = 0;
4623     goto __pyx_L5;
4624   }
4625   __pyx_L5:;
4626
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))             # <<<<<<<<<<<<<<
4631  * 
4632  *     def dump(self, outfile):
4633  */
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;}
4635
4636   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4637   goto __pyx_L0;
4638   __pyx_L1_error:;
4639   __Pyx_XDECREF(__pyx_t_3);
4640   __Pyx_XDECREF(__pyx_t_4);
4641   __Pyx_AddTraceback("sphinxbase.HuffCode.write");
4642   __pyx_r = NULL;
4643   __pyx_L0:;
4644   __Pyx_DECREF((PyObject *)__pyx_v_self);
4645   __Pyx_DECREF(__pyx_v_outfile);
4646   __Pyx_XGIVEREF(__pyx_r);
4647   __Pyx_RefNannyFinishContext();
4648   return __pyx_r;
4649 }
4650
4651 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":523
4652  *         huff_code_write(self.hc, PyFile_AsFile(outfile))
4653  * 
4654  *     def dump(self, outfile):             # <<<<<<<<<<<<<<
4655  *         if not isinstance(outfile, file):
4656  *             outfile = file(outfile, "w")
4657  */
4658
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;
4662   int __pyx_t_1;
4663   int __pyx_t_2;
4664   PyObject *__pyx_t_3 = NULL;
4665   PyObject *__pyx_t_4 = NULL;
4666   int __pyx_t_5;
4667   __Pyx_RefNannySetupContext("dump");
4668   __Pyx_INCREF((PyObject *)__pyx_v_self);
4669   __Pyx_INCREF(__pyx_v_outfile);
4670
4671   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":524
4672  * 
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))
4677  */
4678   __pyx_t_1 = PyObject_TypeCheck(__pyx_v_outfile, ((PyTypeObject *)((PyObject*)&PyFile_Type))); 
4679   __pyx_t_2 = (!__pyx_t_1);
4680   if (__pyx_t_2) {
4681
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))
4687  * 
4688  */
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;
4702     __pyx_t_4 = 0;
4703     goto __pyx_L5;
4704   }
4705   __pyx_L5:;
4706
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))             # <<<<<<<<<<<<<<
4711  * 
4712  *     def encode(self, seq):
4713  */
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;}
4715
4716   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4717   goto __pyx_L0;
4718   __pyx_L1_error:;
4719   __Pyx_XDECREF(__pyx_t_3);
4720   __Pyx_XDECREF(__pyx_t_4);
4721   __Pyx_AddTraceback("sphinxbase.HuffCode.dump");
4722   __pyx_r = NULL;
4723   __pyx_L0:;
4724   __Pyx_DECREF((PyObject *)__pyx_v_self);
4725   __Pyx_DECREF(__pyx_v_outfile);
4726   __Pyx_XGIVEREF(__pyx_r);
4727   __Pyx_RefNannyFinishContext();
4728   return __pyx_r;
4729 }
4730
4731 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":528
4732  *         huff_code_dump(self.hc, PyFile_AsFile(outfile))
4733  * 
4734  *     def encode(self, seq):             # <<<<<<<<<<<<<<
4735  *         """
4736  *         Encode a sequence of symbols to a byte array, returning that
4737  */
4738
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;
4743   int __pyx_v_cwlen;
4744   int __pyx_v_nbits;
4745   int __pyx_v_nbytes;
4746   int __pyx_v_offset;
4747   int __pyx_v_i;
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;
4757   char *__pyx_t_4;
4758   int __pyx_t_5;
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);
4765
4766   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":535
4767  *         """
4768  *         cdef unsigned int cw
4769  *         cdef int cwlen, nbits = 0, nbytes, offset, i             # <<<<<<<<<<<<<<
4770  *         cdef unsigned char buf = 0
4771  *         cdef char *output
4772  */
4773   __pyx_v_nbits = 0;
4774
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             # <<<<<<<<<<<<<<
4779  *         cdef char *output
4780  * 
4781  */
4782   __pyx_v_buf = 0;
4783
4784   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":539
4785  *         cdef char *output
4786  * 
4787  *         for sym in seq:             # <<<<<<<<<<<<<<
4788  *             sss = repr(sym)
4789  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)
4790  */
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);
4793   } else {
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);
4796   }
4797   for (;;) {
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++;
4804     } else {
4805       __pyx_t_3 = PyIter_Next(__pyx_t_2);
4806       if (!__pyx_t_3) {
4807         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4808         break;
4809       }
4810       __Pyx_GOTREF(__pyx_t_3);
4811     }
4812     __Pyx_DECREF(__pyx_v_sym);
4813     __pyx_v_sym = __pyx_t_3;
4814     __pyx_t_3 = 0;
4815
4816     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":540
4817  * 
4818  *         for sym in seq:
4819  *             sss = repr(sym)             # <<<<<<<<<<<<<<
4820  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)
4821  *             nbits += cwlen
4822  */
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;
4827     __pyx_t_3 = 0;
4828
4829     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":541
4830  *         for sym in seq:
4831  *             sss = repr(sym)
4832  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)             # <<<<<<<<<<<<<<
4833  *             nbits += cwlen
4834  *         nbytes = int((nbits + 7) / 8)
4835  */
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));
4838
4839     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":542
4840  *             sss = repr(sym)
4841  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)
4842  *             nbits += cwlen             # <<<<<<<<<<<<<<
4843  *         nbytes = int((nbits + 7) / 8)
4844  *         offset = 0
4845  */
4846     __pyx_v_nbits += __pyx_v_cwlen;
4847   }
4848   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4849
4850   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":543
4851  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)
4852  *             nbits += cwlen
4853  *         nbytes = int((nbits + 7) / 8)             # <<<<<<<<<<<<<<
4854  *         offset = 0
4855  *         output = <char *>PyMem_Malloc(nbytes + 1)
4856  */
4857   __pyx_v_nbytes = ((int)__Pyx_div_long((__pyx_v_nbits + 7), 8));
4858
4859   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":544
4860  *             nbits += cwlen
4861  *         nbytes = int((nbits + 7) / 8)
4862  *         offset = 0             # <<<<<<<<<<<<<<
4863  *         output = <char *>PyMem_Malloc(nbytes + 1)
4864  *         output[nbytes] = 0
4865  */
4866   __pyx_v_offset = 0;
4867
4868   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":545
4869  *         nbytes = int((nbits + 7) / 8)
4870  *         offset = 0
4871  *         output = <char *>PyMem_Malloc(nbytes + 1)             # <<<<<<<<<<<<<<
4872  *         output[nbytes] = 0
4873  *         i = 0
4874  */
4875   __pyx_v_output = ((char *)PyMem_Malloc((__pyx_v_nbytes + 1)));
4876
4877   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":546
4878  *         offset = 0
4879  *         output = <char *>PyMem_Malloc(nbytes + 1)
4880  *         output[nbytes] = 0             # <<<<<<<<<<<<<<
4881  *         i = 0
4882  *         nbits = 0
4883  */
4884   (__pyx_v_output[__pyx_v_nbytes]) = 0;
4885
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             # <<<<<<<<<<<<<<
4890  *         nbits = 0
4891  *         for sym in seq:
4892  */
4893   __pyx_v_i = 0;
4894
4895   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":548
4896  *         output[nbytes] = 0
4897  *         i = 0
4898  *         nbits = 0             # <<<<<<<<<<<<<<
4899  *         for sym in seq:
4900  *             sss = repr(sym)
4901  */
4902   __pyx_v_nbits = 0;
4903
4904   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":549
4905  *         i = 0
4906  *         nbits = 0
4907  *         for sym in seq:             # <<<<<<<<<<<<<<
4908  *             sss = repr(sym)
4909  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)
4910  */
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);
4913   } else {
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);
4916   }
4917   for (;;) {
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++;
4924     } else {
4925       __pyx_t_3 = PyIter_Next(__pyx_t_2);
4926       if (!__pyx_t_3) {
4927         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4928         break;
4929       }
4930       __Pyx_GOTREF(__pyx_t_3);
4931     }
4932     __Pyx_DECREF(__pyx_v_sym);
4933     __pyx_v_sym = __pyx_t_3;
4934     __pyx_t_3 = 0;
4935
4936     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":550
4937  *         nbits = 0
4938  *         for sym in seq:
4939  *             sss = repr(sym)             # <<<<<<<<<<<<<<
4940  *             cwlen = huff_code_encode_str(self.hc, sss, &cw)
4941  *             #print "sym: %s cw: %s buf: %s output: %s" \
4942  */
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;
4947     __pyx_t_3 = 0;
4948
4949     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":551
4950  *         for sym in seq:
4951  *             sss = repr(sym)
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),
4955  */
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));
4958
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)
4965  */
4966     while (1) {
4967       __pyx_t_5 = (__pyx_v_cwlen >= 8);
4968       if (!__pyx_t_5) break;
4969
4970       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":559
4971  *             while cwlen >= 8:
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
4975  *                 output[i] = buf
4976  */
4977       __pyx_v_buf |= ((__pyx_v_cw >> (__pyx_v_cwlen - (8 - __pyx_v_offset))) & ((1 << (8 - __pyx_v_offset)) - 1));
4978
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             # <<<<<<<<<<<<<<
4983  *                 i += 1
4984  *                 nbits += 8
4985  */
4986       (__pyx_v_output[__pyx_v_i]) = __pyx_v_buf;
4987
4988       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":562
4989  *                 # Append buf to output
4990  *                 output[i] = buf
4991  *                 i += 1             # <<<<<<<<<<<<<<
4992  *                 nbits += 8
4993  *                 # Fill high bits of buf with low bits of this byte
4994  */
4995       __pyx_v_i += 1;
4996
4997       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":563
4998  *                 output[i] = buf
4999  *                 i += 1
5000  *                 nbits += 8             # <<<<<<<<<<<<<<
5001  *                 # Fill high bits of buf with low bits of this byte
5002  *                 cwlen -= 8
5003  */
5004       __pyx_v_nbits += 8;
5005
5006       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":565
5007  *                 nbits += 8
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)
5012  */
5013       __pyx_v_cwlen -= 8;
5014
5015       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":566
5016  *                 # Fill high bits of buf with low bits of this byte
5017  *                 cwlen -= 8
5018  *                 buf = (cw >> cwlen) & ((1 << offset) - 1)             # <<<<<<<<<<<<<<
5019  *                 buf <<= (8-offset)
5020  *                 #print "cwlen",cwlen
5021  */
5022       __pyx_v_buf = ((__pyx_v_cw >> __pyx_v_cwlen) & ((1 << __pyx_v_offset) - 1));
5023
5024       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":567
5025  *                 cwlen -= 8
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
5030  */
5031       __pyx_v_buf <<= (8 - __pyx_v_offset);
5032     }
5033
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)
5040  */
5041     __pyx_t_5 = (__pyx_v_cwlen >= (8 - __pyx_v_offset));
5042     if (__pyx_t_5) {
5043
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
5049  *                 output[i] = buf
5050  */
5051       __pyx_v_buf |= ((__pyx_v_cw >> (__pyx_v_cwlen - (8 - __pyx_v_offset))) & ((1 << (8 - __pyx_v_offset)) - 1));
5052
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             # <<<<<<<<<<<<<<
5057  *                 i += 1
5058  *                 nbits += 8
5059  */
5060       (__pyx_v_output[__pyx_v_i]) = __pyx_v_buf;
5061
5062       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":576
5063  *                 # Append buf to output
5064  *                 output[i] = buf
5065  *                 i += 1             # <<<<<<<<<<<<<<
5066  *                 nbits += 8
5067  *                 # cwlen is down to the remaining bits
5068  */
5069       __pyx_v_i += 1;
5070
5071       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":577
5072  *                 output[i] = buf
5073  *                 i += 1
5074  *                 nbits += 8             # <<<<<<<<<<<<<<
5075  *                 # cwlen is down to the remaining bits
5076  *                 cwlen -= (8 - offset)
5077  */
5078       __pyx_v_nbits += 8;
5079
5080       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":579
5081  *                 nbits += 8
5082  *                 # cwlen is down to the remaining bits
5083  *                 cwlen -= (8 - offset)             # <<<<<<<<<<<<<<
5084  *                 # Offset is now zero since we just completed and emptied buf
5085  *                 offset = 0
5086  */
5087       __pyx_v_cwlen -= (8 - __pyx_v_offset);
5088
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
5094  *                 buf = 0
5095  */
5096       __pyx_v_offset = 0;
5097
5098       /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":583
5099  *                 offset = 0
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)
5104  */
5105       __pyx_v_buf = 0;
5106       goto __pyx_L11;
5107     }
5108     __pyx_L11:;
5109
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))             # <<<<<<<<<<<<<<
5114  *             offset += cwlen
5115  *             #print "after buf: %s output: %s" \
5116  */
5117     __pyx_v_buf |= ((__pyx_v_cw & ((1 << __pyx_v_cwlen) - 1)) << ((8 - __pyx_v_offset) - __pyx_v_cwlen));
5118
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))
5125  */
5126     __pyx_v_offset += __pyx_v_cwlen;
5127   }
5128   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5129
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
5135  *             output[i] = buf
5136  */
5137   __pyx_t_5 = (__pyx_v_offset > 0);
5138   if (__pyx_t_5) {
5139
5140     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":594
5141  *         if offset > 0:
5142  *             # Append buf to output
5143  *             output[i] = buf             # <<<<<<<<<<<<<<
5144  *             nbits += offset
5145  *             i += 1
5146  */
5147     (__pyx_v_output[__pyx_v_i]) = __pyx_v_buf;
5148
5149     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":595
5150  *             # Append buf to output
5151  *             output[i] = buf
5152  *             nbits += offset             # <<<<<<<<<<<<<<
5153  *             i += 1
5154  *         #print "output:", binstr(output, nbits)
5155  */
5156     __pyx_v_nbits += __pyx_v_offset;
5157
5158     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":596
5159  *             output[i] = buf
5160  *             nbits += offset
5161  *             i += 1             # <<<<<<<<<<<<<<
5162  *         #print "output:", binstr(output, nbits)
5163  *         outstr = PyString_FromStringAndSize(output, nbytes)
5164  */
5165     __pyx_v_i += 1;
5166     goto __pyx_L12;
5167   }
5168   __pyx_L12:;
5169
5170   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":598
5171  *             i += 1
5172  *         #print "output:", binstr(output, nbits)
5173  *         outstr = PyString_FromStringAndSize(output, nbytes)             # <<<<<<<<<<<<<<
5174  *         PyMem_Free(output)
5175  *         return (outstr, offset)
5176  */
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;
5181   __pyx_t_2 = 0;
5182
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)
5188  * 
5189  */
5190   PyMem_Free(__pyx_v_output);
5191
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)             # <<<<<<<<<<<<<<
5196  * 
5197  *     def decode(self, data):
5198  */
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);
5209   __pyx_t_2 = 0;
5210   __pyx_r = __pyx_t_3;
5211   __pyx_t_3 = 0;
5212   goto __pyx_L0;
5213
5214   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5215   goto __pyx_L0;
5216   __pyx_L1_error:;
5217   __Pyx_XDECREF(__pyx_t_2);
5218   __Pyx_XDECREF(__pyx_t_3);
5219   __Pyx_AddTraceback("sphinxbase.HuffCode.encode");
5220   __pyx_r = NULL;
5221   __pyx_L0:;
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();
5229   return __pyx_r;
5230 }
5231
5232 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":602
5233  *         return (outstr, offset)
5234  * 
5235  *     def decode(self, data):             # <<<<<<<<<<<<<<
5236  *         """
5237  *         Decode a sequence of symbols from a string, returning the
5238  */
5239
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) {
5243   int __pyx_v_offset;
5244   char *__pyx_v_dptr;
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;
5250   char *__pyx_t_2;
5251   PyObject *__pyx_t_3 = NULL;
5252   int __pyx_t_4;
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);
5258
5259   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":613
5260  *         cdef size_t dlen
5261  * 
5262  *         dlen = len(data)             # <<<<<<<<<<<<<<
5263  *         offset = 0
5264  *         dptr = data
5265  */
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;
5268
5269   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":614
5270  * 
5271  *         dlen = len(data)
5272  *         offset = 0             # <<<<<<<<<<<<<<
5273  *         dptr = data
5274  *         output = []
5275  */
5276   __pyx_v_offset = 0;
5277
5278   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":615
5279  *         dlen = len(data)
5280  *         offset = 0
5281  *         dptr = data             # <<<<<<<<<<<<<<
5282  *         output = []
5283  *         while True:
5284  */
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;
5287
5288   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":616
5289  *         offset = 0
5290  *         dptr = data
5291  *         output = []             # <<<<<<<<<<<<<<
5292  *         while True:
5293  *             strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5294  */
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);
5299   __pyx_t_3 = 0;
5300
5301   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":617
5302  *         dptr = data
5303  *         output = []
5304  *         while True:             # <<<<<<<<<<<<<<
5305  *             strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5306  *             if strval == NULL:
5307  */
5308   while (1) {
5309     __pyx_t_4 = 1;
5310     if (!__pyx_t_4) break;
5311
5312     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":618
5313  *         output = []
5314  *         while True:
5315  *             strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)             # <<<<<<<<<<<<<<
5316  *             if strval == NULL:
5317  *                 break
5318  */
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));
5320
5321     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":619
5322  *         while True:
5323  *             strval = huff_code_decode_str(self.hc, &dptr, &dlen, &offset)
5324  *             if strval == NULL:             # <<<<<<<<<<<<<<
5325  *                 break
5326  *             output.append(strval)
5327  */
5328     __pyx_t_4 = (__pyx_v_strval == NULL);
5329     if (__pyx_t_4) {
5330
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)
5336  *         if dlen > 1:
5337  */
5338       goto __pyx_L6_break;
5339       goto __pyx_L7;
5340     }
5341     __pyx_L7:;
5342
5343     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":621
5344  *             if strval == NULL:
5345  *                 break
5346  *             output.append(strval)             # <<<<<<<<<<<<<<
5347  *         if dlen > 1:
5348  *             raise ValueError, "Invalid data at position %d" % (len(data) - dlen)
5349  */
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;
5356   }
5357   __pyx_L6_break:;
5358
5359   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":622
5360  *                 break
5361  *             output.append(strval)
5362  *         if dlen > 1:             # <<<<<<<<<<<<<<
5363  *             raise ValueError, "Invalid data at position %d" % (len(data) - dlen)
5364  *         return (output, offset)
5365  */
5366   __pyx_t_4 = (__pyx_v_dlen > 1);
5367   if (__pyx_t_4) {
5368
5369     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":623
5370  *             output.append(strval)
5371  *         if dlen > 1:
5372  *             raise ValueError, "Invalid data at position %d" % (len(data) - dlen)             # <<<<<<<<<<<<<<
5373  *         return (output, offset)
5374  * 
5375  */
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;}
5385     goto __pyx_L8;
5386   }
5387   __pyx_L8:;
5388
5389   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":624
5390  *         if dlen > 1:
5391  *             raise ValueError, "Invalid data at position %d" % (len(data) - dlen)
5392  *         return (output, offset)             # <<<<<<<<<<<<<<
5393  * 
5394  *     def attach(self, fh, char *mode):
5395  */
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);
5406   __pyx_t_3 = 0;
5407   __pyx_r = __pyx_t_5;
5408   __pyx_t_5 = 0;
5409   goto __pyx_L0;
5410
5411   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5412   goto __pyx_L0;
5413   __pyx_L1_error:;
5414   __Pyx_XDECREF(__pyx_t_3);
5415   __Pyx_XDECREF(__pyx_t_5);
5416   __Pyx_AddTraceback("sphinxbase.HuffCode.decode");
5417   __pyx_r = NULL;
5418   __pyx_L0:;
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();
5424   return __pyx_r;
5425 }
5426
5427 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":626
5428  *         return (output, offset)
5429  * 
5430  *     def attach(self, fh, char *mode):             # <<<<<<<<<<<<<<
5431  *         if not isinstance(fh, file):
5432  *             fh = file(fh, mode)
5433  */
5434
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;
5438   char *__pyx_v_mode;
5439   PyObject *__pyx_r = NULL;
5440   int __pyx_t_1;
5441   int __pyx_t_2;
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);
5452       case  0: break;
5453       default: goto __pyx_L5_argtuple_error;
5454     }
5455     switch (PyTuple_GET_SIZE(__pyx_args)) {
5456       case  0:
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;
5460       case  1:
5461       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode);
5462       if (likely(values[1])) kw_args--;
5463       else {
5464         __Pyx_RaiseArgtupleInvalid("attach", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
5465       }
5466     }
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;}
5469     }
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;
5474   } else {
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;}
5477   }
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;}
5481   __pyx_L3_error:;
5482   __Pyx_AddTraceback("sphinxbase.HuffCode.attach");
5483   return NULL;
5484   __pyx_L4_argument_unpacking_done:;
5485   __Pyx_INCREF((PyObject *)__pyx_v_self);
5486   __Pyx_INCREF(__pyx_v_fh);
5487
5488   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":627
5489  * 
5490  *     def attach(self, fh, char *mode):
5491  *         if not isinstance(fh, file):             # <<<<<<<<<<<<<<
5492  *             fh = file(fh, mode)
5493  *         self.fh = fh
5494  */
5495   __pyx_t_1 = PyObject_TypeCheck(__pyx_v_fh, ((PyTypeObject *)((PyObject*)&PyFile_Type))); 
5496   __pyx_t_2 = (!__pyx_t_1);
5497   if (__pyx_t_2) {
5498
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)             # <<<<<<<<<<<<<<
5503  *         self.fh = fh
5504  *         huff_code_attach(self.hc, PyFile_AsFile(fh), mode)
5505  */
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));
5515     __pyx_t_3 = 0;
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;
5521     __pyx_t_3 = 0;
5522     goto __pyx_L6;
5523   }
5524   __pyx_L6:;
5525
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)
5531  * 
5532  */
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;
5538
5539   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":630
5540  *             fh = file(fh, mode)
5541  *         self.fh = fh
5542  *         huff_code_attach(self.hc, PyFile_AsFile(fh), mode)             # <<<<<<<<<<<<<<
5543  * 
5544  *     def detach(self):
5545  */
5546   huff_code_attach(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, PyFile_AsFile(__pyx_v_fh), __pyx_v_mode);
5547
5548   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5549   goto __pyx_L0;
5550   __pyx_L1_error:;
5551   __Pyx_XDECREF(__pyx_t_3);
5552   __Pyx_XDECREF(__pyx_t_4);
5553   __Pyx_AddTraceback("sphinxbase.HuffCode.attach");
5554   __pyx_r = NULL;
5555   __pyx_L0:;
5556   __Pyx_DECREF((PyObject *)__pyx_v_self);
5557   __Pyx_DECREF(__pyx_v_fh);
5558   __Pyx_XGIVEREF(__pyx_r);
5559   __Pyx_RefNannyFinishContext();
5560   return __pyx_r;
5561 }
5562
5563 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":632
5564  *         huff_code_attach(self.hc, PyFile_AsFile(fh), mode)
5565  * 
5566  *     def detach(self):             # <<<<<<<<<<<<<<
5567  *         huff_code_detach(self.hc)
5568  *         self.fh = None
5569  */
5570
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");
5575
5576   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":633
5577  * 
5578  *     def detach(self):
5579  *         huff_code_detach(self.hc)             # <<<<<<<<<<<<<<
5580  *         self.fh = None
5581  * 
5582  */
5583   huff_code_detach(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc);
5584
5585   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":634
5586  *     def detach(self):
5587  *         huff_code_detach(self.hc)
5588  *         self.fh = None             # <<<<<<<<<<<<<<
5589  * 
5590  *     def encode_to_file(self, seq):
5591  */
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;
5597
5598   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5599   __Pyx_XGIVEREF(__pyx_r);
5600   __Pyx_RefNannyFinishContext();
5601   return __pyx_r;
5602 }
5603
5604 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":636
5605  *         self.fh = None
5606  * 
5607  *     def encode_to_file(self, seq):             # <<<<<<<<<<<<<<
5608  *         if self.fh == None:
5609  *             raise RuntimeError, "No file is attached"
5610  */
5611
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;
5618   int __pyx_t_2;
5619   Py_ssize_t __pyx_t_3;
5620   PyObject *__pyx_t_4 = NULL;
5621   char *__pyx_t_5;
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);
5627
5628   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":637
5629  * 
5630  *     def encode_to_file(self, seq):
5631  *         if self.fh == None:             # <<<<<<<<<<<<<<
5632  *             raise RuntimeError, "No file is attached"
5633  *         for sym in seq:
5634  */
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;
5639   if (__pyx_t_2) {
5640
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"             # <<<<<<<<<<<<<<
5645  *         for sym in seq:
5646  *             strsym = repr(sym)
5647  */
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;}
5650     goto __pyx_L5;
5651   }
5652   __pyx_L5:;
5653
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)
5660  */
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);
5663   } else {
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);
5666   }
5667   for (;;) {
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++;
5674     } else {
5675       __pyx_t_4 = PyIter_Next(__pyx_t_1);
5676       if (!__pyx_t_4) {
5677         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5678         break;
5679       }
5680       __Pyx_GOTREF(__pyx_t_4);
5681     }
5682     __Pyx_DECREF(__pyx_v_sym);
5683     __pyx_v_sym = __pyx_t_4;
5684     __pyx_t_4 = 0;
5685
5686     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":640
5687  *             raise RuntimeError, "No file is attached"
5688  *         for sym in seq:
5689  *             strsym = repr(sym)             # <<<<<<<<<<<<<<
5690  *             huff_code_encode_str(self.hc, strsym, NULL)
5691  * 
5692  */
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;
5697     __pyx_t_4 = 0;
5698
5699     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":641
5700  *         for sym in seq:
5701  *             strsym = repr(sym)
5702  *             huff_code_encode_str(self.hc, strsym, NULL)             # <<<<<<<<<<<<<<
5703  * 
5704  *     def decode_from_file(self):
5705  */
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);
5708   }
5709   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5710
5711   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5712   goto __pyx_L0;
5713   __pyx_L1_error:;
5714   __Pyx_XDECREF(__pyx_t_1);
5715   __Pyx_XDECREF(__pyx_t_4);
5716   __Pyx_AddTraceback("sphinxbase.HuffCode.encode_to_file");
5717   __pyx_r = NULL;
5718   __pyx_L0:;
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();
5725   return __pyx_r;
5726 }
5727
5728 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":643
5729  *             huff_code_encode_str(self.hc, strsym, NULL)
5730  * 
5731  *     def decode_from_file(self):             # <<<<<<<<<<<<<<
5732  *         cdef char *sym
5733  *         if self.fh == None:
5734  */
5735
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) {
5738   char *__pyx_v_sym;
5739   PyObject *__pyx_r = NULL;
5740   PyObject *__pyx_t_1 = NULL;
5741   int __pyx_t_2;
5742   __Pyx_RefNannySetupContext("decode_from_file");
5743   __Pyx_INCREF((PyObject *)__pyx_v_self);
5744
5745   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":645
5746  *     def decode_from_file(self):
5747  *         cdef char *sym
5748  *         if self.fh == None:             # <<<<<<<<<<<<<<
5749  *             raise RuntimeError, "No file is attached"
5750  *         sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5751  */
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;
5756   if (__pyx_t_2) {
5757
5758     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":646
5759  *         cdef char *sym
5760  *         if self.fh == None:
5761  *             raise RuntimeError, "No file is attached"             # <<<<<<<<<<<<<<
5762  *         sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5763  *         if sym == NULL:
5764  */
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;}
5767     goto __pyx_L5;
5768   }
5769   __pyx_L5:;
5770
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)             # <<<<<<<<<<<<<<
5775  *         if sym == NULL:
5776  *             return None
5777  */
5778   __pyx_v_sym = huff_code_decode_str(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc, NULL, NULL, NULL);
5779
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:             # <<<<<<<<<<<<<<
5784  *             return None
5785  *         else:
5786  */
5787   __pyx_t_2 = (__pyx_v_sym == NULL);
5788   if (__pyx_t_2) {
5789
5790     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":649
5791  *         sym = huff_code_decode_str(self.hc, NULL, NULL, NULL)
5792  *         if sym == NULL:
5793  *             return None             # <<<<<<<<<<<<<<
5794  *         else:
5795  *             return sym
5796  */
5797     __Pyx_XDECREF(__pyx_r);
5798     __Pyx_INCREF(Py_None);
5799     __pyx_r = Py_None;
5800     goto __pyx_L0;
5801     goto __pyx_L6;
5802   }
5803   /*else*/ {
5804
5805     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":651
5806  *             return None
5807  *         else:
5808  *             return sym             # <<<<<<<<<<<<<<
5809  * 
5810  *     def __dealloc__(self):
5811  */
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);
5816     __pyx_t_1 = 0;
5817     goto __pyx_L0;
5818   }
5819   __pyx_L6:;
5820
5821   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5822   goto __pyx_L0;
5823   __pyx_L1_error:;
5824   __Pyx_XDECREF(__pyx_t_1);
5825   __Pyx_AddTraceback("sphinxbase.HuffCode.decode_from_file");
5826   __pyx_r = NULL;
5827   __pyx_L0:;
5828   __Pyx_DECREF((PyObject *)__pyx_v_self);
5829   __Pyx_XGIVEREF(__pyx_r);
5830   __Pyx_RefNannyFinishContext();
5831   return __pyx_r;
5832 }
5833
5834 /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":653
5835  *             return sym
5836  * 
5837  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
5838  *         if self.fh:
5839  *             self.detach()
5840  */
5841
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) {
5844   int __pyx_t_1;
5845   PyObject *__pyx_t_2 = NULL;
5846   PyObject *__pyx_t_3 = NULL;
5847   __Pyx_RefNannySetupContext("__dealloc__");
5848   __Pyx_INCREF((PyObject *)__pyx_v_self);
5849
5850   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":654
5851  * 
5852  *     def __dealloc__(self):
5853  *         if self.fh:             # <<<<<<<<<<<<<<
5854  *             self.detach()
5855  *         huff_code_free(self.hc)
5856  */
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;}
5858   if (__pyx_t_1) {
5859
5860     /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":655
5861  *     def __dealloc__(self):
5862  *         if self.fh:
5863  *             self.detach()             # <<<<<<<<<<<<<<
5864  *         huff_code_free(self.hc)
5865  */
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;
5872     goto __pyx_L5;
5873   }
5874   __pyx_L5:;
5875
5876   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":656
5877  *         if self.fh:
5878  *             self.detach()
5879  *         huff_code_free(self.hc)             # <<<<<<<<<<<<<<
5880  */
5881   huff_code_free(((struct __pyx_obj_10sphinxbase_HuffCode *)__pyx_v_self)->hc);
5882
5883   goto __pyx_L0;
5884   __pyx_L1_error:;
5885   __Pyx_XDECREF(__pyx_t_2);
5886   __Pyx_XDECREF(__pyx_t_3);
5887   __Pyx_AddTraceback("sphinxbase.HuffCode.__dealloc__");
5888   __pyx_L0:;
5889   __Pyx_DECREF((PyObject *)__pyx_v_self);
5890   __Pyx_RefNannyFinishContext();
5891 }
5892 static struct __pyx_vtabstruct_10sphinxbase_NGramModel __pyx_vtable_10sphinxbase_NGramModel;
5893
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);
5897   if (!o) return 0;
5898   p = ((struct __pyx_obj_10sphinxbase_NGramModel *)o);
5899   p->__pyx_vtab = __pyx_vtabptr_10sphinxbase_NGramModel;
5900   return o;
5901 }
5902
5903 static void __pyx_tp_dealloc_10sphinxbase_NGramModel(PyObject *o) {
5904   {
5905     PyObject *etype, *eval, *etb;
5906     PyErr_Fetch(&etype, &eval, &etb);
5907     ++Py_REFCNT(o);
5908     __pyx_pf_10sphinxbase_10NGramModel___dealloc__(o);
5909     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
5910     --Py_REFCNT(o);
5911     PyErr_Restore(etype, eval, etb);
5912   }
5913   (*Py_TYPE(o)->tp_free)(o);
5914 }
5915
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)},
5932   {0, 0, 0, 0}
5933 };
5934
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},
5939   {0, 0, 0, 0, 0}
5940 };
5941
5942 static PyNumberMethods __pyx_tp_as_number_NGramModel = {
5943   0, /*nb_add*/
5944   0, /*nb_subtract*/
5945   0, /*nb_multiply*/
5946   #if PY_MAJOR_VERSION < 3
5947   0, /*nb_divide*/
5948   #endif
5949   0, /*nb_remainder*/
5950   0, /*nb_divmod*/
5951   0, /*nb_power*/
5952   0, /*nb_negative*/
5953   0, /*nb_positive*/
5954   0, /*nb_absolute*/
5955   0, /*nb_nonzero*/
5956   0, /*nb_invert*/
5957   0, /*nb_lshift*/
5958   0, /*nb_rshift*/
5959   0, /*nb_and*/
5960   0, /*nb_xor*/
5961   0, /*nb_or*/
5962   #if PY_MAJOR_VERSION < 3
5963   0, /*nb_coerce*/
5964   #endif
5965   0, /*nb_int*/
5966   #if PY_MAJOR_VERSION >= 3
5967   0, /*reserved*/
5968   #else
5969   0, /*nb_long*/
5970   #endif
5971   0, /*nb_float*/
5972   #if PY_MAJOR_VERSION < 3
5973   0, /*nb_oct*/
5974   #endif
5975   #if PY_MAJOR_VERSION < 3
5976   0, /*nb_hex*/
5977   #endif
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*/
5983   #endif
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)
5996   0, /*nb_index*/
5997   #endif
5998 };
5999
6000 static PySequenceMethods __pyx_tp_as_sequence_NGramModel = {
6001   0, /*sq_length*/
6002   0, /*sq_concat*/
6003   0, /*sq_repeat*/
6004   0, /*sq_item*/
6005   0, /*sq_slice*/
6006   0, /*sq_ass_item*/
6007   0, /*sq_ass_slice*/
6008   0, /*sq_contains*/
6009   0, /*sq_inplace_concat*/
6010   0, /*sq_inplace_repeat*/
6011 };
6012
6013 static PyMappingMethods __pyx_tp_as_mapping_NGramModel = {
6014   0, /*mp_length*/
6015   0, /*mp_subscript*/
6016   0, /*mp_ass_subscript*/
6017 };
6018
6019 static PyBufferProcs __pyx_tp_as_buffer_NGramModel = {
6020   #if PY_MAJOR_VERSION < 3
6021   0, /*bf_getreadbuffer*/
6022   #endif
6023   #if PY_MAJOR_VERSION < 3
6024   0, /*bf_getwritebuffer*/
6025   #endif
6026   #if PY_MAJOR_VERSION < 3
6027   0, /*bf_getsegcount*/
6028   #endif
6029   #if PY_MAJOR_VERSION < 3
6030   0, /*bf_getcharbuffer*/
6031   #endif
6032   #if PY_VERSION_HEX >= 0x02060000
6033   0, /*bf_getbuffer*/
6034   #endif
6035   #if PY_VERSION_HEX >= 0x02060000
6036   0, /*bf_releasebuffer*/
6037   #endif
6038 };
6039
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*/
6044   0, /*tp_itemsize*/
6045   __pyx_tp_dealloc_10sphinxbase_NGramModel, /*tp_dealloc*/
6046   0, /*tp_print*/
6047   0, /*tp_getattr*/
6048   0, /*tp_setattr*/
6049   0, /*tp_compare*/
6050   0, /*tp_repr*/
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*/
6054   0, /*tp_hash*/
6055   0, /*tp_call*/
6056   0, /*tp_str*/
6057   0, /*tp_getattro*/
6058   0, /*tp_setattro*/
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*/
6062   0, /*tp_traverse*/
6063   0, /*tp_clear*/
6064   0, /*tp_richcompare*/
6065   0, /*tp_weaklistoffset*/
6066   0, /*tp_iter*/
6067   0, /*tp_iternext*/
6068   __pyx_methods_10sphinxbase_NGramModel, /*tp_methods*/
6069   __pyx_members_10sphinxbase_NGramModel, /*tp_members*/
6070   0, /*tp_getset*/
6071   0, /*tp_base*/
6072   0, /*tp_dict*/
6073   0, /*tp_descr_get*/
6074   0, /*tp_descr_set*/
6075   0, /*tp_dictoffset*/
6076   __pyx_pf_10sphinxbase_10NGramModel___init__, /*tp_init*/
6077   0, /*tp_alloc*/
6078   __pyx_tp_new_10sphinxbase_NGramModel, /*tp_new*/
6079   0, /*tp_free*/
6080   0, /*tp_is_gc*/
6081   0, /*tp_bases*/
6082   0, /*tp_mro*/
6083   0, /*tp_cache*/
6084   0, /*tp_subclasses*/
6085   0, /*tp_weaklist*/
6086   0, /*tp_del*/
6087   #if PY_VERSION_HEX >= 0x02060000
6088   0, /*tp_version_tag*/
6089   #endif
6090 };
6091
6092 static PyObject *__pyx_tp_new_10sphinxbase_LogMath(PyTypeObject *t, PyObject *a, PyObject *k) {
6093   PyObject *o = (*t->tp_alloc)(t, 0);
6094   if (!o) return 0;
6095   return o;
6096 }
6097
6098 static void __pyx_tp_dealloc_10sphinxbase_LogMath(PyObject *o) {
6099   {
6100     PyObject *etype, *eval, *etb;
6101     PyErr_Fetch(&etype, &eval, &etb);
6102     ++Py_REFCNT(o);
6103     __pyx_pf_10sphinxbase_7LogMath___dealloc__(o);
6104     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
6105     --Py_REFCNT(o);
6106     PyErr_Restore(etype, eval, etb);
6107   }
6108   (*Py_TYPE(o)->tp_free)(o);
6109 }
6110
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)},
6120   {0, 0, 0, 0}
6121 };
6122
6123 static PyNumberMethods __pyx_tp_as_number_LogMath = {
6124   0, /*nb_add*/
6125   0, /*nb_subtract*/
6126   0, /*nb_multiply*/
6127   #if PY_MAJOR_VERSION < 3
6128   0, /*nb_divide*/
6129   #endif
6130   0, /*nb_remainder*/
6131   0, /*nb_divmod*/
6132   0, /*nb_power*/
6133   0, /*nb_negative*/
6134   0, /*nb_positive*/
6135   0, /*nb_absolute*/
6136   0, /*nb_nonzero*/
6137   0, /*nb_invert*/
6138   0, /*nb_lshift*/
6139   0, /*nb_rshift*/
6140   0, /*nb_and*/
6141   0, /*nb_xor*/
6142   0, /*nb_or*/
6143   #if PY_MAJOR_VERSION < 3
6144   0, /*nb_coerce*/
6145   #endif
6146   0, /*nb_int*/
6147   #if PY_MAJOR_VERSION >= 3
6148   0, /*reserved*/
6149   #else
6150   0, /*nb_long*/
6151   #endif
6152   0, /*nb_float*/
6153   #if PY_MAJOR_VERSION < 3
6154   0, /*nb_oct*/
6155   #endif
6156   #if PY_MAJOR_VERSION < 3
6157   0, /*nb_hex*/
6158   #endif
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*/
6164   #endif
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)
6177   0, /*nb_index*/
6178   #endif
6179 };
6180
6181 static PySequenceMethods __pyx_tp_as_sequence_LogMath = {
6182   0, /*sq_length*/
6183   0, /*sq_concat*/
6184   0, /*sq_repeat*/
6185   0, /*sq_item*/
6186   0, /*sq_slice*/
6187   0, /*sq_ass_item*/
6188   0, /*sq_ass_slice*/
6189   0, /*sq_contains*/
6190   0, /*sq_inplace_concat*/
6191   0, /*sq_inplace_repeat*/
6192 };
6193
6194 static PyMappingMethods __pyx_tp_as_mapping_LogMath = {
6195   0, /*mp_length*/
6196   0, /*mp_subscript*/
6197   0, /*mp_ass_subscript*/
6198 };
6199
6200 static PyBufferProcs __pyx_tp_as_buffer_LogMath = {
6201   #if PY_MAJOR_VERSION < 3
6202   0, /*bf_getreadbuffer*/
6203   #endif
6204   #if PY_MAJOR_VERSION < 3
6205   0, /*bf_getwritebuffer*/
6206   #endif
6207   #if PY_MAJOR_VERSION < 3
6208   0, /*bf_getsegcount*/
6209   #endif
6210   #if PY_MAJOR_VERSION < 3
6211   0, /*bf_getcharbuffer*/
6212   #endif
6213   #if PY_VERSION_HEX >= 0x02060000
6214   0, /*bf_getbuffer*/
6215   #endif
6216   #if PY_VERSION_HEX >= 0x02060000
6217   0, /*bf_releasebuffer*/
6218   #endif
6219 };
6220
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*/
6225   0, /*tp_itemsize*/
6226   __pyx_tp_dealloc_10sphinxbase_LogMath, /*tp_dealloc*/
6227   0, /*tp_print*/
6228   0, /*tp_getattr*/
6229   0, /*tp_setattr*/
6230   0, /*tp_compare*/
6231   0, /*tp_repr*/
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*/
6235   0, /*tp_hash*/
6236   0, /*tp_call*/
6237   0, /*tp_str*/
6238   0, /*tp_getattro*/
6239   0, /*tp_setattro*/
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*/
6243   0, /*tp_traverse*/
6244   0, /*tp_clear*/
6245   0, /*tp_richcompare*/
6246   0, /*tp_weaklistoffset*/
6247   0, /*tp_iter*/
6248   0, /*tp_iternext*/
6249   __pyx_methods_10sphinxbase_LogMath, /*tp_methods*/
6250   0, /*tp_members*/
6251   0, /*tp_getset*/
6252   0, /*tp_base*/
6253   0, /*tp_dict*/
6254   0, /*tp_descr_get*/
6255   0, /*tp_descr_set*/
6256   0, /*tp_dictoffset*/
6257   __pyx_pf_10sphinxbase_7LogMath___init__, /*tp_init*/
6258   0, /*tp_alloc*/
6259   __pyx_tp_new_10sphinxbase_LogMath, /*tp_new*/
6260   0, /*tp_free*/
6261   0, /*tp_is_gc*/
6262   0, /*tp_bases*/
6263   0, /*tp_mro*/
6264   0, /*tp_cache*/
6265   0, /*tp_subclasses*/
6266   0, /*tp_weaklist*/
6267   0, /*tp_del*/
6268   #if PY_VERSION_HEX >= 0x02060000
6269   0, /*tp_version_tag*/
6270   #endif
6271 };
6272 static struct __pyx_vtabstruct_10sphinxbase_NGramIter __pyx_vtable_10sphinxbase_NGramIter;
6273
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);
6277   if (!o) return 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;
6284   }
6285   return o;
6286 }
6287
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);
6293 }
6294
6295 static int __pyx_tp_traverse_10sphinxbase_NGramIter(PyObject *o, visitproc v, void *a) {
6296   int e;
6297   struct __pyx_obj_10sphinxbase_NGramIter *p = (struct __pyx_obj_10sphinxbase_NGramIter *)o;
6298   if (p->lm) {
6299     e = (*v)(((PyObject*)p->lm), a); if (e) return e;
6300   }
6301   if (p->words) {
6302     e = (*v)(p->words, a); if (e) return e;
6303   }
6304   return 0;
6305 }
6306
6307 static int __pyx_tp_clear_10sphinxbase_NGramIter(PyObject *o) {
6308   struct __pyx_obj_10sphinxbase_NGramIter *p = (struct __pyx_obj_10sphinxbase_NGramIter *)o;
6309   PyObject* tmp;
6310   tmp = ((PyObject*)p->lm);
6311   p->lm = ((struct __pyx_obj_10sphinxbase_NGramModel *)Py_None); Py_INCREF(Py_None);
6312   Py_XDECREF(tmp);
6313   tmp = ((PyObject*)p->words);
6314   p->words = Py_None; Py_INCREF(Py_None);
6315   Py_XDECREF(tmp);
6316   return 0;
6317 }
6318
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)},
6323   {0, 0, 0, 0}
6324 };
6325
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},
6330   {0, 0, 0, 0, 0}
6331 };
6332
6333 static PyNumberMethods __pyx_tp_as_number_NGramIter = {
6334   0, /*nb_add*/
6335   0, /*nb_subtract*/
6336   0, /*nb_multiply*/
6337   #if PY_MAJOR_VERSION < 3
6338   0, /*nb_divide*/
6339   #endif
6340   0, /*nb_remainder*/
6341   0, /*nb_divmod*/
6342   0, /*nb_power*/
6343   0, /*nb_negative*/
6344   0, /*nb_positive*/
6345   0, /*nb_absolute*/
6346   0, /*nb_nonzero*/
6347   0, /*nb_invert*/
6348   0, /*nb_lshift*/
6349   0, /*nb_rshift*/
6350   0, /*nb_and*/
6351   0, /*nb_xor*/
6352   0, /*nb_or*/
6353   #if PY_MAJOR_VERSION < 3
6354   0, /*nb_coerce*/
6355   #endif
6356   0, /*nb_int*/
6357   #if PY_MAJOR_VERSION >= 3
6358   0, /*reserved*/
6359   #else
6360   0, /*nb_long*/
6361   #endif
6362   0, /*nb_float*/
6363   #if PY_MAJOR_VERSION < 3
6364   0, /*nb_oct*/
6365   #endif
6366   #if PY_MAJOR_VERSION < 3
6367   0, /*nb_hex*/
6368   #endif
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*/
6374   #endif
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)
6387   0, /*nb_index*/
6388   #endif
6389 };
6390
6391 static PySequenceMethods __pyx_tp_as_sequence_NGramIter = {
6392   0, /*sq_length*/
6393   0, /*sq_concat*/
6394   0, /*sq_repeat*/
6395   0, /*sq_item*/
6396   0, /*sq_slice*/
6397   0, /*sq_ass_item*/
6398   0, /*sq_ass_slice*/
6399   0, /*sq_contains*/
6400   0, /*sq_inplace_concat*/
6401   0, /*sq_inplace_repeat*/
6402 };
6403
6404 static PyMappingMethods __pyx_tp_as_mapping_NGramIter = {
6405   0, /*mp_length*/
6406   0, /*mp_subscript*/
6407   0, /*mp_ass_subscript*/
6408 };
6409
6410 static PyBufferProcs __pyx_tp_as_buffer_NGramIter = {
6411   #if PY_MAJOR_VERSION < 3
6412   0, /*bf_getreadbuffer*/
6413   #endif
6414   #if PY_MAJOR_VERSION < 3
6415   0, /*bf_getwritebuffer*/
6416   #endif
6417   #if PY_MAJOR_VERSION < 3
6418   0, /*bf_getsegcount*/
6419   #endif
6420   #if PY_MAJOR_VERSION < 3
6421   0, /*bf_getcharbuffer*/
6422   #endif
6423   #if PY_VERSION_HEX >= 0x02060000
6424   0, /*bf_getbuffer*/
6425   #endif
6426   #if PY_VERSION_HEX >= 0x02060000
6427   0, /*bf_releasebuffer*/
6428   #endif
6429 };
6430
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*/
6435   0, /*tp_itemsize*/
6436   __pyx_tp_dealloc_10sphinxbase_NGramIter, /*tp_dealloc*/
6437   0, /*tp_print*/
6438   0, /*tp_getattr*/
6439   0, /*tp_setattr*/
6440   0, /*tp_compare*/
6441   0, /*tp_repr*/
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*/
6445   0, /*tp_hash*/
6446   0, /*tp_call*/
6447   0, /*tp_str*/
6448   0, /*tp_getattro*/
6449   0, /*tp_setattro*/
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*/
6461   0, /*tp_getset*/
6462   0, /*tp_base*/
6463   0, /*tp_dict*/
6464   0, /*tp_descr_get*/
6465   0, /*tp_descr_set*/
6466   0, /*tp_dictoffset*/
6467   0, /*tp_init*/
6468   0, /*tp_alloc*/
6469   __pyx_tp_new_10sphinxbase_NGramIter, /*tp_new*/
6470   0, /*tp_free*/
6471   0, /*tp_is_gc*/
6472   0, /*tp_bases*/
6473   0, /*tp_mro*/
6474   0, /*tp_cache*/
6475   0, /*tp_subclasses*/
6476   0, /*tp_weaklist*/
6477   0, /*tp_del*/
6478   #if PY_VERSION_HEX >= 0x02060000
6479   0, /*tp_version_tag*/
6480   #endif
6481 };
6482
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);
6486   if (!o) return 0;
6487   p = ((struct __pyx_obj_10sphinxbase_HuffCode *)o);
6488   p->fh = Py_None; Py_INCREF(Py_None);
6489   return o;
6490 }
6491
6492 static void __pyx_tp_dealloc_10sphinxbase_HuffCode(PyObject *o) {
6493   struct __pyx_obj_10sphinxbase_HuffCode *p = (struct __pyx_obj_10sphinxbase_HuffCode *)o;
6494   {
6495     PyObject *etype, *eval, *etb;
6496     PyErr_Fetch(&etype, &eval, &etb);
6497     ++Py_REFCNT(o);
6498     __pyx_pf_10sphinxbase_8HuffCode___dealloc__(o);
6499     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
6500     --Py_REFCNT(o);
6501     PyErr_Restore(etype, eval, etb);
6502   }
6503   Py_XDECREF(p->fh);
6504   (*Py_TYPE(o)->tp_free)(o);
6505 }
6506
6507 static int __pyx_tp_traverse_10sphinxbase_HuffCode(PyObject *o, visitproc v, void *a) {
6508   int e;
6509   struct __pyx_obj_10sphinxbase_HuffCode *p = (struct __pyx_obj_10sphinxbase_HuffCode *)o;
6510   if (p->fh) {
6511     e = (*v)(p->fh, a); if (e) return e;
6512   }
6513   return 0;
6514 }
6515
6516 static int __pyx_tp_clear_10sphinxbase_HuffCode(PyObject *o) {
6517   struct __pyx_obj_10sphinxbase_HuffCode *p = (struct __pyx_obj_10sphinxbase_HuffCode *)o;
6518   PyObject* tmp;
6519   tmp = ((PyObject*)p->fh);
6520   p->fh = Py_None; Py_INCREF(Py_None);
6521   Py_XDECREF(tmp);
6522   return 0;
6523 }
6524
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)},
6535   {0, 0, 0, 0}
6536 };
6537
6538 static PyNumberMethods __pyx_tp_as_number_HuffCode = {
6539   0, /*nb_add*/
6540   0, /*nb_subtract*/
6541   0, /*nb_multiply*/
6542   #if PY_MAJOR_VERSION < 3
6543   0, /*nb_divide*/
6544   #endif
6545   0, /*nb_remainder*/
6546   0, /*nb_divmod*/
6547   0, /*nb_power*/
6548   0, /*nb_negative*/
6549   0, /*nb_positive*/
6550   0, /*nb_absolute*/
6551   0, /*nb_nonzero*/
6552   0, /*nb_invert*/
6553   0, /*nb_lshift*/
6554   0, /*nb_rshift*/
6555   0, /*nb_and*/
6556   0, /*nb_xor*/
6557   0, /*nb_or*/
6558   #if PY_MAJOR_VERSION < 3
6559   0, /*nb_coerce*/
6560   #endif
6561   0, /*nb_int*/
6562   #if PY_MAJOR_VERSION >= 3
6563   0, /*reserved*/
6564   #else
6565   0, /*nb_long*/
6566   #endif
6567   0, /*nb_float*/
6568   #if PY_MAJOR_VERSION < 3
6569   0, /*nb_oct*/
6570   #endif
6571   #if PY_MAJOR_VERSION < 3
6572   0, /*nb_hex*/
6573   #endif
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*/
6579   #endif
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)
6592   0, /*nb_index*/
6593   #endif
6594 };
6595
6596 static PySequenceMethods __pyx_tp_as_sequence_HuffCode = {
6597   0, /*sq_length*/
6598   0, /*sq_concat*/
6599   0, /*sq_repeat*/
6600   0, /*sq_item*/
6601   0, /*sq_slice*/
6602   0, /*sq_ass_item*/
6603   0, /*sq_ass_slice*/
6604   0, /*sq_contains*/
6605   0, /*sq_inplace_concat*/
6606   0, /*sq_inplace_repeat*/
6607 };
6608
6609 static PyMappingMethods __pyx_tp_as_mapping_HuffCode = {
6610   0, /*mp_length*/
6611   0, /*mp_subscript*/
6612   0, /*mp_ass_subscript*/
6613 };
6614
6615 static PyBufferProcs __pyx_tp_as_buffer_HuffCode = {
6616   #if PY_MAJOR_VERSION < 3
6617   0, /*bf_getreadbuffer*/
6618   #endif
6619   #if PY_MAJOR_VERSION < 3
6620   0, /*bf_getwritebuffer*/
6621   #endif
6622   #if PY_MAJOR_VERSION < 3
6623   0, /*bf_getsegcount*/
6624   #endif
6625   #if PY_MAJOR_VERSION < 3
6626   0, /*bf_getcharbuffer*/
6627   #endif
6628   #if PY_VERSION_HEX >= 0x02060000
6629   0, /*bf_getbuffer*/
6630   #endif
6631   #if PY_VERSION_HEX >= 0x02060000
6632   0, /*bf_releasebuffer*/
6633   #endif
6634 };
6635
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*/
6640   0, /*tp_itemsize*/
6641   __pyx_tp_dealloc_10sphinxbase_HuffCode, /*tp_dealloc*/
6642   0, /*tp_print*/
6643   0, /*tp_getattr*/
6644   0, /*tp_setattr*/
6645   0, /*tp_compare*/
6646   0, /*tp_repr*/
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*/
6650   0, /*tp_hash*/
6651   0, /*tp_call*/
6652   0, /*tp_str*/
6653   0, /*tp_getattro*/
6654   0, /*tp_setattro*/
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*/
6662   0, /*tp_iter*/
6663   0, /*tp_iternext*/
6664   __pyx_methods_10sphinxbase_HuffCode, /*tp_methods*/
6665   0, /*tp_members*/
6666   0, /*tp_getset*/
6667   0, /*tp_base*/
6668   0, /*tp_dict*/
6669   0, /*tp_descr_get*/
6670   0, /*tp_descr_set*/
6671   0, /*tp_dictoffset*/
6672   __pyx_pf_10sphinxbase_8HuffCode___init__, /*tp_init*/
6673   0, /*tp_alloc*/
6674   __pyx_tp_new_10sphinxbase_HuffCode, /*tp_new*/
6675   0, /*tp_free*/
6676   0, /*tp_is_gc*/
6677   0, /*tp_bases*/
6678   0, /*tp_mro*/
6679   0, /*tp_cache*/
6680   0, /*tp_subclasses*/
6681   0, /*tp_weaklist*/
6682   0, /*tp_del*/
6683   #if PY_VERSION_HEX >= 0x02060000
6684   0, /*tp_version_tag*/
6685   #endif
6686 };
6687
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)},
6691   {0, 0, 0, 0}
6692 };
6693
6694 static void __pyx_init_filenames(void); /*proto*/
6695
6696 #if PY_MAJOR_VERSION >= 3
6697 static struct PyModuleDef __pyx_moduledef = {
6698     PyModuleDef_HEAD_INIT,
6699     __Pyx_NAMESTR("sphinxbase"),
6700     0, /* m_doc */
6701     -1, /* m_size */
6702     __pyx_methods /* m_methods */,
6703     NULL, /* m_reload */
6704     NULL, /* m_traverse */
6705     NULL, /* m_clear */
6706     NULL /* m_free */
6707 };
6708 #endif
6709
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}
6773 };
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;}
6782   return 0;
6783   __pyx_L1_error:;
6784   return -1;
6785 }
6786
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;};
6792   return 0;
6793   __pyx_L1_error:;
6794   return -1;
6795 }
6796
6797 #if PY_MAJOR_VERSION < 3
6798 PyMODINIT_FUNC initsphinxbase(void); /*proto*/
6799 PyMODINIT_FUNC initsphinxbase(void)
6800 #else
6801 PyMODINIT_FUNC PyInit_sphinxbase(void); /*proto*/
6802 PyMODINIT_FUNC PyInit_sphinxbase(void)
6803 #endif
6804 {
6805   PyObject *__pyx_t_1 = NULL;
6806   #if CYTHON_REFNANNY
6807   void* __pyx_refnanny = NULL;
6808   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
6809   if (!__Pyx_RefNanny) {
6810       PyErr_Clear();
6811       __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
6812       if (!__Pyx_RefNanny)
6813           Py_FatalError("failed to import 'refnanny' module");
6814   }
6815   __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_sphinxbase(void)", __LINE__, __FILE__);
6816   #endif
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;}
6821   #else
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;}
6823   #endif
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();
6829   #endif
6830   #endif
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);
6834   #else
6835   __pyx_m = PyModule_Create(&__pyx_moduledef);
6836   #endif
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
6839   Py_INCREF(__pyx_m);
6840   #endif
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;};
6848   }
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;
6858   #else
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;
6861   #endif
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;
6872   #else
6873   *(void(**)(void))&__pyx_vtable_10sphinxbase_NGramIter.set_iter = (void(*)(void))__pyx_f_10sphinxbase_9NGramIter_set_iter;
6874   #endif
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 ---*/
6885
6886   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":24
6887  *     @type use_table: bool
6888  *     """
6889  *     def __init__(self, base=1.0001, shift=0, use_table=1):             # <<<<<<<<<<<<<<
6890  *         self.lmath = logmath_init(base, shift, use_table)
6891  * 
6892  */
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);
6897   __pyx_t_1 = 0;
6898
6899   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":122
6900  * 
6901  * # Unfortunately, Cython doesn't actually export enums to Python...
6902  * AUTO = NGRAM_AUTO             # <<<<<<<<<<<<<<
6903  * ARPA = NGRAM_ARPA
6904  * DMP = NGRAM_DMP
6905  */
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;
6910
6911   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":123
6912  * # Unfortunately, Cython doesn't actually export enums to Python...
6913  * AUTO = NGRAM_AUTO
6914  * ARPA = NGRAM_ARPA             # <<<<<<<<<<<<<<
6915  * DMP = NGRAM_DMP
6916  * UPPER = NGRAM_UPPER
6917  */
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;
6922
6923   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":124
6924  * AUTO = NGRAM_AUTO
6925  * ARPA = NGRAM_ARPA
6926  * DMP = NGRAM_DMP             # <<<<<<<<<<<<<<
6927  * UPPER = NGRAM_UPPER
6928  * LOWER = NGRAM_LOWER
6929  */
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;
6934
6935   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":125
6936  * ARPA = NGRAM_ARPA
6937  * DMP = NGRAM_DMP
6938  * UPPER = NGRAM_UPPER             # <<<<<<<<<<<<<<
6939  * LOWER = NGRAM_LOWER
6940  * 
6941  */
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;
6946
6947   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":126
6948  * DMP = NGRAM_DMP
6949  * UPPER = NGRAM_UPPER
6950  * LOWER = NGRAM_LOWER             # <<<<<<<<<<<<<<
6951  * 
6952  * cdef class NGramModel:
6953  */
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;
6958
6959   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":146
6960  *     @type uw: float
6961  *     """
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)
6964  *         if file:
6965  */
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);
6970   __pyx_t_1 = 0;
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);
6975   __pyx_t_1 = 0;
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);
6980   __pyx_t_1 = 0;
6981
6982   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":176
6983  *         ngram_model_free(self.lm)
6984  * 
6985  *     def apply_weights(self, lw=1.0, wip=1.0, uw=1.0):             # <<<<<<<<<<<<<<
6986  *         """
6987  *         Change the language model weights applied in L{score}.
6988  */
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);
6993   __pyx_t_1 = 0;
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);
6998   __pyx_t_1 = 0;
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);
7003   __pyx_t_1 = 0;
7004
7005   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":369
7006  *         return itor
7007  * 
7008  *     def add_word(self, word, weight=1.0):             # <<<<<<<<<<<<<<
7009  *         return ngram_model_add_word(self.lm, word, weight)
7010  * 
7011  */
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);
7016   __pyx_t_1 = 0;
7017
7018   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pyx":384
7019  *             raise ValueError, "Casefolding failed"
7020  * 
7021  *     def write(self, file_name, format=NGRAM_AUTO):             # <<<<<<<<<<<<<<
7022  *         cdef int rv
7023  *         rv = ngram_model_write(self.lm, file_name, format)
7024  */
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);
7029   __pyx_t_1 = 0;
7030
7031   /* "/home/nshmyrev/projects/cmusphinx-dist/t/sphinxbase/python/sphinxbase.pxd":1
7032  * # Copyright (c) 2008 Carnegie Mellon University. All rights             # <<<<<<<<<<<<<<
7033  * # reserved.
7034  * #
7035  */
7036   goto __pyx_L0;
7037   __pyx_L1_error:;
7038   __Pyx_XDECREF(__pyx_t_1);
7039   if (__pyx_m) {
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");
7044   }
7045   __pyx_L0:;
7046   __Pyx_RefNannyFinishContext();
7047   #if PY_MAJOR_VERSION < 3
7048   return;
7049   #else
7050   return __pyx_m;
7051   #endif
7052 }
7053
7054 static const char *__pyx_filenames[] = {
7055   "sphinxbase.pyx",
7056 };
7057
7058 /* Runtime support code */
7059
7060 static void __pyx_init_filenames(void) {
7061   __pyx_f = __pyx_filenames;
7062 }
7063
7064 static void __Pyx_RaiseDoubleKeywordsError(
7065     const char* func_name,
7066     PyObject* kw_name)
7067 {
7068     PyErr_Format(PyExc_TypeError,
7069         #if PY_MAJOR_VERSION >= 3
7070         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
7071         #else
7072         "%s() got multiple values for keyword argument '%s'", func_name,
7073         PyString_AS_STRING(kw_name));
7074         #endif
7075 }
7076
7077 static void __Pyx_RaiseArgtupleInvalid(
7078     const char* func_name,
7079     int exact,
7080     Py_ssize_t num_min,
7081     Py_ssize_t num_max,
7082     Py_ssize_t num_found)
7083 {
7084     Py_ssize_t num_expected;
7085     const char *number, *more_or_less;
7086
7087     if (num_found < num_min) {
7088         num_expected = num_min;
7089         more_or_less = "at least";
7090     } else {
7091         num_expected = num_max;
7092         more_or_less = "at most";
7093     }
7094     if (exact) {
7095         more_or_less = "exactly";
7096     }
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)",
7101         #else
7102             "%s() takes %s %zd positional argument%s (%zd given)",
7103         #endif
7104         func_name, more_or_less, num_expected, number, num_found);
7105 }
7106
7107 static int __Pyx_ParseOptionalKeywords(
7108     PyObject *kwds,
7109     PyObject **argnames[],
7110     PyObject *kwds2,
7111     PyObject *values[],
7112     Py_ssize_t num_pos_args,
7113     const char* function_name)
7114 {
7115     PyObject *key = 0, *value = 0;
7116     Py_ssize_t pos = 0;
7117     PyObject*** name;
7118     PyObject*** first_kw_arg = argnames + num_pos_args;
7119
7120     while (PyDict_Next(kwds, &pos, &key, &value)) {
7121         name = first_kw_arg;
7122         while (*name && (**name != key)) name++;
7123         if (*name) {
7124             values[name-argnames] = value;
7125         } else {
7126             #if PY_MAJOR_VERSION < 3
7127             if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
7128             #else
7129             if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
7130             #endif
7131                 goto invalid_keyword_type;
7132             } else {
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;
7137                     #else
7138                     if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
7139                         _PyString_Eq(**name, key)) break;
7140                     #endif
7141                 }
7142                 if (*name) {
7143                     values[name-argnames] = value;
7144                 } else {
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;
7151                         #else
7152                         if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
7153                             _PyString_Eq(**name, key)) goto arg_passed_twice;
7154                         #endif
7155                     }
7156                     if (kwds2) {
7157                         if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
7158                     } else {
7159                         goto invalid_keyword;
7160                     }
7161                 }
7162             }
7163         }
7164     }
7165     return 0;
7166 arg_passed_twice:
7167     __Pyx_RaiseDoubleKeywordsError(function_name, **name);
7168     goto bad;
7169 invalid_keyword_type:
7170     PyErr_Format(PyExc_TypeError,
7171         "%s() keywords must be strings", function_name);
7172     goto bad;
7173 invalid_keyword:
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));
7178     #else
7179         "%s() got an unexpected keyword argument '%U'",
7180         function_name, key);
7181     #endif
7182 bad:
7183     return -1;
7184 }
7185
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,
7190         #else
7191                  "need more than %zd value%s to unpack", index,
7192         #endif
7193                  (index == 1) ? "" : "s");
7194 }
7195
7196 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(void) {
7197     PyErr_SetString(PyExc_ValueError, "too many values to unpack");
7198 }
7199
7200 static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
7201     PyObject *item;
7202     if (!(item = PyIter_Next(iter))) {
7203         if (!PyErr_Occurred()) {
7204             __Pyx_RaiseNeedMoreValuesError(index);
7205         }
7206     }
7207     return item;
7208 }
7209
7210 static int __Pyx_EndUnpack(PyObject *iter) {
7211     PyObject *item;
7212     if ((item = PyIter_Next(iter))) {
7213         Py_DECREF(item);
7214         __Pyx_RaiseTooManyValuesError();
7215         return -1;
7216     }
7217     else if (!PyErr_Occurred())
7218         return 0;
7219     else
7220         return -1;
7221 }
7222
7223
7224 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
7225     long q = a / b;
7226     long r = a - q*b;
7227     q -= ((r != 0) & ((r ^ b) < 0));
7228     return q;
7229 }
7230
7231 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
7232     const char *name, int exact)
7233 {
7234     if (!type) {
7235         PyErr_Format(PyExc_SystemError, "Missing type object");
7236         return 0;
7237     }
7238     if (none_allowed && obj == Py_None) return 1;
7239     else if (exact) {
7240         if (Py_TYPE(obj) == type) return 1;
7241     }
7242     else {
7243         if (PyObject_TypeCheck(obj, type)) return 1;
7244     }
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);
7248     return 0;
7249 }
7250
7251 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
7252     PyObject *result;
7253     result = PyObject_GetAttr(dict, name);
7254     if (!result)
7255         PyErr_SetObject(PyExc_NameError, name);
7256     return result;
7257 }
7258
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();
7262
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);
7271     Py_XDECREF(tmp_tb);
7272 }
7273
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;
7279
7280     tstate->curexc_type = 0;
7281     tstate->curexc_value = 0;
7282     tstate->curexc_traceback = 0;
7283 }
7284
7285
7286 #if PY_MAJOR_VERSION < 3
7287 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
7288     Py_XINCREF(type);
7289     Py_XINCREF(value);
7290     Py_XINCREF(tb);
7291     /* First, check the traceback argument, replacing None with NULL. */
7292     if (tb == Py_None) {
7293         Py_DECREF(tb);
7294         tb = 0;
7295     }
7296     else if (tb != NULL && !PyTraceBack_Check(tb)) {
7297         PyErr_SetString(PyExc_TypeError,
7298             "raise: arg 3 must be a traceback or None");
7299         goto raise_error;
7300     }
7301     /* Next, replace a missing value with None */
7302     if (value == NULL) {
7303         value = Py_None;
7304         Py_INCREF(value);
7305     }
7306     #if PY_VERSION_HEX < 0x02050000
7307     if (!PyClass_Check(type))
7308     #else
7309     if (!PyType_Check(type))
7310     #endif
7311     {
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");
7316             goto raise_error;
7317         }
7318         /* Normalize to raise <class>, <instance> */
7319         Py_DECREF(value);
7320         value = type;
7321         #if PY_VERSION_HEX < 0x02050000
7322             if (PyInstance_Check(type)) {
7323                 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
7324                 Py_INCREF(type);
7325             }
7326             else {
7327                 type = 0;
7328                 PyErr_SetString(PyExc_TypeError,
7329                     "raise: exception must be an old-style class or instance");
7330                 goto raise_error;
7331             }
7332         #else
7333             type = (PyObject*) Py_TYPE(type);
7334             Py_INCREF(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");
7338                 goto raise_error;
7339             }
7340         #endif
7341     }
7342
7343     __Pyx_ErrRestore(type, value, tb);
7344     return;
7345 raise_error:
7346     Py_XDECREF(value);
7347     Py_XDECREF(type);
7348     Py_XDECREF(tb);
7349     return;
7350 }
7351
7352 #else /* Python 3+ */
7353
7354 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
7355     if (tb == Py_None) {
7356         tb = 0;
7357     } else if (tb && !PyTraceBack_Check(tb)) {
7358         PyErr_SetString(PyExc_TypeError,
7359             "raise: arg 3 must be a traceback or None");
7360         goto bad;
7361     }
7362     if (value == Py_None)
7363         value = 0;
7364
7365     if (PyExceptionInstance_Check(type)) {
7366         if (value) {
7367             PyErr_SetString(PyExc_TypeError,
7368                 "instance exception may not have a separate value");
7369             goto bad;
7370         }
7371         value = type;
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");
7376         goto bad;
7377     }
7378
7379     PyErr_SetObject(type, value);
7380
7381     if (tb) {
7382         PyThreadState *tstate = PyThreadState_GET();
7383         PyObject* tmp_tb = tstate->curexc_traceback;
7384         if (tb != tmp_tb) {
7385             Py_INCREF(tb);
7386             tstate->curexc_traceback = tb;
7387             Py_XDECREF(tmp_tb);
7388         }
7389     }
7390
7391 bad:
7392     return;
7393 }
7394 #endif
7395
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");
7407             }
7408             return (unsigned char)-1;
7409         }
7410         return (unsigned char)val;
7411     }
7412     return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
7413 }
7414
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");
7426             }
7427             return (unsigned short)-1;
7428         }
7429         return (unsigned short)val;
7430     }
7431     return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
7432 }
7433
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");
7445             }
7446             return (unsigned int)-1;
7447         }
7448         return (unsigned int)val;
7449     }
7450     return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
7451 }
7452
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");
7464             }
7465             return (char)-1;
7466         }
7467         return (char)val;
7468     }
7469     return (char)__Pyx_PyInt_AsLong(x);
7470 }
7471
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");
7483             }
7484             return (short)-1;
7485         }
7486         return (short)val;
7487     }
7488     return (short)__Pyx_PyInt_AsLong(x);
7489 }
7490
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");
7502             }
7503             return (int)-1;
7504         }
7505         return (int)val;
7506     }
7507     return (int)__Pyx_PyInt_AsLong(x);
7508 }
7509
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");
7521             }
7522             return (signed char)-1;
7523         }
7524         return (signed char)val;
7525     }
7526     return (signed char)__Pyx_PyInt_AsSignedLong(x);
7527 }
7528
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");
7540             }
7541             return (signed short)-1;
7542         }
7543         return (signed short)val;
7544     }
7545     return (signed short)__Pyx_PyInt_AsSignedLong(x);
7546 }
7547
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");
7559             }
7560             return (signed int)-1;
7561         }
7562         return (signed int)val;
7563     }
7564     return (signed int)__Pyx_PyInt_AsSignedLong(x);
7565 }
7566
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;
7577         }
7578         return (unsigned long)val;
7579     } else
7580 #endif
7581     if (likely(PyLong_Check(x))) {
7582         if (is_unsigned) {
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;
7587             }
7588             return PyLong_AsUnsignedLong(x);
7589         } else {
7590             return PyLong_AsLong(x);
7591         }
7592     } else {
7593         unsigned long val;
7594         PyObject *tmp = __Pyx_PyNumber_Int(x);
7595         if (!tmp) return (unsigned long)-1;
7596         val = __Pyx_PyInt_AsUnsignedLong(tmp);
7597         Py_DECREF(tmp);
7598         return val;
7599     }
7600 }
7601
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;
7612         }
7613         return (unsigned PY_LONG_LONG)val;
7614     } else
7615 #endif
7616     if (likely(PyLong_Check(x))) {
7617         if (is_unsigned) {
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;
7622             }
7623             return PyLong_AsUnsignedLongLong(x);
7624         } else {
7625             return PyLong_AsLongLong(x);
7626         }
7627     } else {
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);
7632         Py_DECREF(tmp);
7633         return val;
7634     }
7635 }
7636
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");
7646             return (long)-1;
7647         }
7648         return (long)val;
7649     } else
7650 #endif
7651     if (likely(PyLong_Check(x))) {
7652         if (is_unsigned) {
7653             if (unlikely(Py_SIZE(x) < 0)) {
7654                 PyErr_SetString(PyExc_OverflowError,
7655                                 "can't convert negative value to long");
7656                 return (long)-1;
7657             }
7658             return PyLong_AsUnsignedLong(x);
7659         } else {
7660             return PyLong_AsLong(x);
7661         }
7662     } else {
7663         long val;
7664         PyObject *tmp = __Pyx_PyNumber_Int(x);
7665         if (!tmp) return (long)-1;
7666         val = __Pyx_PyInt_AsLong(tmp);
7667         Py_DECREF(tmp);
7668         return val;
7669     }
7670 }
7671
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;
7682         }
7683         return (PY_LONG_LONG)val;
7684     } else
7685 #endif
7686     if (likely(PyLong_Check(x))) {
7687         if (is_unsigned) {
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;
7692             }
7693             return PyLong_AsUnsignedLongLong(x);
7694         } else {
7695             return PyLong_AsLongLong(x);
7696         }
7697     } else {
7698         PY_LONG_LONG val;
7699         PyObject *tmp = __Pyx_PyNumber_Int(x);
7700         if (!tmp) return (PY_LONG_LONG)-1;
7701         val = __Pyx_PyInt_AsLongLong(tmp);
7702         Py_DECREF(tmp);
7703         return val;
7704     }
7705 }
7706
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;
7717         }
7718         return (signed long)val;
7719     } else
7720 #endif
7721     if (likely(PyLong_Check(x))) {
7722         if (is_unsigned) {
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;
7727             }
7728             return PyLong_AsUnsignedLong(x);
7729         } else {
7730             return PyLong_AsLong(x);
7731         }
7732     } else {
7733         signed long val;
7734         PyObject *tmp = __Pyx_PyNumber_Int(x);
7735         if (!tmp) return (signed long)-1;
7736         val = __Pyx_PyInt_AsSignedLong(tmp);
7737         Py_DECREF(tmp);
7738         return val;
7739     }
7740 }
7741
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;
7752         }
7753         return (signed PY_LONG_LONG)val;
7754     } else
7755 #endif
7756     if (likely(PyLong_Check(x))) {
7757         if (is_unsigned) {
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;
7762             }
7763             return PyLong_AsUnsignedLongLong(x);
7764         } else {
7765             return PyLong_AsLongLong(x);
7766         }
7767     } else {
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);
7772         Py_DECREF(tmp);
7773         return val;
7774     }
7775 }
7776
7777 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
7778 #if PY_VERSION_HEX < 0x03010000
7779     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
7780 #else
7781     PyObject *ob = PyCapsule_New(vtable, 0, 0);
7782 #endif
7783     if (!ob)
7784         goto bad;
7785     if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
7786         goto bad;
7787     Py_DECREF(ob);
7788     return 0;
7789 bad:
7790     Py_XDECREF(ob);
7791     return -1;
7792 }
7793
7794 #include "compile.h"
7795 #include "frameobject.h"
7796 #include "traceback.h"
7797
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;
7804
7805     #if PY_MAJOR_VERSION < 3
7806     py_srcfile = PyString_FromString(__pyx_filename);
7807     #else
7808     py_srcfile = PyUnicode_FromString(__pyx_filename);
7809     #endif
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);
7814         #else
7815         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
7816         #endif
7817     }
7818     else {
7819         #if PY_MAJOR_VERSION < 3
7820         py_funcname = PyString_FromString(funcname);
7821         #else
7822         py_funcname = PyUnicode_FromString(funcname);
7823         #endif
7824     }
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,*/
7832         #endif
7833         0,            /*int nlocals,*/
7834         0,            /*int stacksize,*/
7835         0,            /*int flags,*/
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*/
7846     );
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*/
7853     );
7854     if (!py_frame) goto bad;
7855     py_frame->f_lineno = __pyx_lineno;
7856     PyTraceBack_Here(py_frame);
7857 bad:
7858     Py_XDECREF(py_srcfile);
7859     Py_XDECREF(py_funcname);
7860     Py_XDECREF(py_code);
7861     Py_XDECREF(py_frame);
7862 }
7863
7864 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
7865     while (t->p) {
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);
7871         } else {
7872             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
7873         }
7874         #else  /* Python 3+ has unicode identifiers */
7875         if (t->is_unicode | t->is_str) {
7876             if (t->intern) {
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);
7880             } else {
7881                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
7882             }
7883         } else {
7884             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
7885         }
7886         #endif
7887         if (!*t->p)
7888             return -1;
7889         ++t;
7890     }
7891     return 0;
7892 }
7893
7894 /* Type Conversion Functions */
7895
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);
7900 }
7901
7902 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
7903   PyNumberMethods *m;
7904   const char *name = NULL;
7905   PyObject *res = NULL;
7906 #if PY_VERSION_HEX < 0x03000000
7907   if (PyInt_Check(x) || PyLong_Check(x))
7908 #else
7909   if (PyLong_Check(x))
7910 #endif
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) {
7915     name = "int";
7916     res = PyNumber_Int(x);
7917   }
7918   else if (m && m->nb_long) {
7919     name = "long";
7920     res = PyNumber_Long(x);
7921   }
7922 #else
7923   if (m && m->nb_int) {
7924     name = "int";
7925     res = PyNumber_Long(x);
7926   }
7927 #endif
7928   if (res) {
7929 #if PY_VERSION_HEX < 0x03000000
7930     if (!PyInt_Check(res) && !PyLong_Check(res)) {
7931 #else
7932     if (!PyLong_Check(res)) {
7933 #endif
7934       PyErr_Format(PyExc_TypeError,
7935                    "__%s__ returned non-%s (type %.200s)",
7936                    name, name, Py_TYPE(res)->tp_name);
7937       Py_DECREF(res);
7938       return NULL;
7939     }
7940   }
7941   else if (!PyErr_Occurred()) {
7942     PyErr_SetString(PyExc_TypeError,
7943                     "an integer is required");
7944   }
7945   return res;
7946 }
7947
7948 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
7949   Py_ssize_t ival;
7950   PyObject* x = PyNumber_Index(b);
7951   if (!x) return -1;
7952   ival = PyInt_AsSsize_t(x);
7953   Py_DECREF(x);
7954   return ival;
7955 }
7956
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);
7961    else {
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);
7965    }
7966 #else
7967    return PyInt_FromSize_t(ival);
7968 #endif
7969 }
7970
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())) {
7974        return (size_t)-1;
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");
7978        return (size_t)-1;
7979    }
7980    return (size_t)val;
7981 }
7982
7983
7984 #endif /* Py_PYTHON_H */