Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kpu/kenlm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama W. Obeid <owo@owobeid.com>2020-09-30 10:10:38 +0300
committerOssama W. Obeid <owo@owobeid.com>2020-09-30 10:10:38 +0300
commit63537d94942754f53bf9adb156056afa156c638d (patch)
treee4af2131d5cc27cf88bcd89379dbe17d3533ac40
parentb63a09cebd4b94a78c876ee250bcc3dc49491da6 (diff)
Added arpa_complain option to Config python wrapper.
-rw-r--r--python/_kenlm.pxd7
-rw-r--r--python/kenlm.cpp1163
-rw-r--r--python/kenlm.pyx11
3 files changed, 904 insertions, 277 deletions
diff --git a/python/_kenlm.pxd b/python/_kenlm.pxd
index d27f1bb..9176017 100644
--- a/python/_kenlm.pxd
+++ b/python/_kenlm.pxd
@@ -39,12 +39,19 @@ cdef extern from "util/mmap.hh" namespace "util":
READ
PARALLEL_READ
+cdef extern from "lm/config.hh" namespace "lm::ngram::Config":
+ cdef enum ARPALoadComplain:
+ ALL
+ EXPENSIVE
+ NONE
+
cdef extern from "lm/config.hh" namespace "lm::ngram":
cdef cppclass Config:
Config()
float probing_multiplier
LoadMethod load_method
bool show_progress
+ ARPALoadComplain arpa_complain
float unknown_missing_logprob
cdef extern from "lm/model.hh" namespace "lm::ngram":
diff --git a/python/kenlm.cpp b/python/kenlm.cpp
index 500b4b3..9411808 100644
--- a/python/kenlm.cpp
+++ b/python/kenlm.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.29.15 */
+/* Generated by Cython 0.29.21 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -7,8 +7,8 @@
#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
#error Cython requires Python 2.6+ or Python 3.3+.
#else
-#define CYTHON_ABI "0_29_15"
-#define CYTHON_HEX_VERSION 0x001D0FF0
+#define CYTHON_ABI "0_29_21"
+#define CYTHON_HEX_VERSION 0x001D15F0
#define CYTHON_FUTURE_DIVISION 1
#include <stddef.h>
#ifndef offsetof
@@ -449,7 +449,11 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
#define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
#define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
+ #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
#define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
+ #else
+ #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
+ #endif
#else
#define CYTHON_PEP393_ENABLED 0
#define PyUnicode_1BYTE_KIND 1
@@ -498,8 +502,10 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#define PyString_Type PyUnicode_Type
#define PyString_Check PyUnicode_Check
#define PyString_CheckExact PyUnicode_CheckExact
+#ifndef PyObject_Unicode
#define PyObject_Unicode PyObject_Str
#endif
+#endif
#if PY_MAJOR_VERSION >= 3
#define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
#define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
@@ -510,6 +516,13 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#ifndef PySet_CheckExact
#define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
#endif
+#if PY_VERSION_HEX >= 0x030900A4
+ #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
+ #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
+#else
+ #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
+ #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
+#endif
#if CYTHON_ASSUME_SAFE_MACROS
#define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
#else
@@ -549,7 +562,7 @@ static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
#define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
#endif
#if PY_MAJOR_VERSION >= 3
- #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
+ #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
#else
#define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
#endif
@@ -590,11 +603,10 @@ static CYTHON_INLINE float __PYX_NAN() {
#define __Pyx_truncl truncl
#endif
-
+#define __PYX_MARK_ERR_POS(f_index, lineno) \
+ { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
#define __PYX_ERR(f_index, lineno, Ln_error) \
-{ \
- __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
-}
+ { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
#ifndef __PYX_EXTERN_C
#ifdef __cplusplus
@@ -866,8 +878,8 @@ struct __pyx_obj_5kenlm_State {
};
-/* "kenlm.pyx":88
- * PARALLEL_READ = _kenlm.PARALLEL_READ
+/* "kenlm.pyx":93
+ * NONE = _kenlm.NONE
*
* cdef class Config: # <<<<<<<<<<<<<<
* """
@@ -879,8 +891,8 @@ struct __pyx_obj_5kenlm_Config {
};
-/* "kenlm.pyx":110
- * self._c_config.show_progress = to
+/* "kenlm.pyx":121
+ * self._c_config.arpa_complain = to
*
* cdef class Model: # <<<<<<<<<<<<<<
* """
@@ -894,7 +906,7 @@ struct __pyx_obj_5kenlm_Model {
};
-/* "kenlm.pyx":206
+/* "kenlm.pyx":217
* return 10.0**(-self.score(sentence) / words)
*
* def full_scores(self, sentence, bos = True, eos = True): # <<<<<<<<<<<<<<
@@ -1212,6 +1224,9 @@ static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_nam
#define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
#endif
+/* PyObjectGetAttrStrNoError.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
+
/* SetupReduce.proto */
static int __Pyx_setup_reduce(PyObject* type_obj);
@@ -1271,6 +1286,9 @@ static void __Pyx_AddTraceback(const char *funcname, int c_line,
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__util_3a__3a_LoadMethod(enum util::LoadMethod value);
/* CIntToPy.proto */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(enum lm::ngram::Config::ARPALoadComplain value);
+
+/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
/* CppExceptionConversion.proto */
@@ -1327,6 +1345,9 @@ static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
/* CIntFromPy.proto */
static CYTHON_INLINE enum util::LoadMethod __Pyx_PyInt_As_enum__util_3a__3a_LoadMethod(PyObject *);
+/* CIntFromPy.proto */
+static CYTHON_INLINE enum lm::ngram::Config::ARPALoadComplain __Pyx_PyInt_As_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(PyObject *);
+
/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
@@ -1459,11 +1480,13 @@ static PyObject *__pyx_builtin_IOError;
static const char __pyx_k__8[] = "\n";
static const char __pyx_k__9[] = " ";
static const char __pyx_k_os[] = "os";
+static const char __pyx_k_ALL[] = "ALL";
static const char __pyx_k_bos[] = "bos";
static const char __pyx_k_doc[] = "__doc__";
static const char __pyx_k_eos[] = "eos";
static const char __pyx_k_oov[] = "oov";
static const char __pyx_k_LAZY[] = "LAZY";
+static const char __pyx_k_NONE[] = "NONE";
static const char __pyx_k_READ[] = "READ";
static const char __pyx_k_args[] = "args";
static const char __pyx_k_copy[] = "__copy__";
@@ -1500,6 +1523,7 @@ static const char __pyx_k_log_prob[] = "log_prob";
static const char __pyx_k_qualname[] = "__qualname__";
static const char __pyx_k_sentence[] = "sentence";
static const char __pyx_k_setstate[] = "__setstate__";
+static const char __pyx_k_EXPENSIVE[] = "EXPENSIVE";
static const char __pyx_k_TypeError[] = "TypeError";
static const char __pyx_k_metaclass[] = "__metaclass__";
static const char __pyx_k_out_state[] = "out_state";
@@ -1514,6 +1538,7 @@ static const char __pyx_k_PARALLEL_READ[] = "PARALLEL_READ";
static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
static const char __pyx_k_FullScoreReturn[] = "FullScoreReturn";
static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
+static const char __pyx_k_ARPALoadComplain[] = "ARPALoadComplain";
static const char __pyx_k_POPULATE_OR_LAZY[] = "POPULATE_OR_LAZY";
static const char __pyx_k_POPULATE_OR_READ[] = "POPULATE_OR_READ";
static const char __pyx_k_Cannot_read_model[] = "Cannot read model '{}' ({})";
@@ -1525,10 +1550,13 @@ static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __red
static const char __pyx_k_self__c_config_cannot_be_convert[] = "self._c_config cannot be converted to a Python object for pickling";
static const char __pyx_k_self__c_state_cannot_be_converte[] = "self._c_state cannot be converted to a Python object for pickling";
static PyObject *__pyx_kp_u_0_1_2_3;
+static PyObject *__pyx_n_s_ALL;
+static PyObject *__pyx_n_s_ARPALoadComplain;
static PyObject *__pyx_kp_s_Backwards_compatability_stub_Use;
static PyObject *__pyx_kp_u_Cannot_convert_s_to_string;
static PyObject *__pyx_kp_u_Cannot_read_model;
static PyObject *__pyx_n_s_Config;
+static PyObject *__pyx_n_s_EXPENSIVE;
static PyObject *__pyx_n_s_FullScoreReturn;
static PyObject *__pyx_n_s_IOError;
static PyObject *__pyx_n_s_LAZY;
@@ -1537,6 +1565,7 @@ static PyObject *__pyx_n_s_LoadMethod;
static PyObject *__pyx_n_s_Model;
static PyObject *__pyx_kp_u_Model_from_0;
static PyObject *__pyx_n_s_Model_full_scores;
+static PyObject *__pyx_n_s_NONE;
static PyObject *__pyx_n_s_PARALLEL_READ;
static PyObject *__pyx_n_s_POPULATE_OR_LAZY;
static PyObject *__pyx_n_s_POPULATE_OR_READ;
@@ -1610,6 +1639,8 @@ static PyObject *__pyx_pf_5kenlm_6Config_11load_method___get__(struct __pyx_obj_
static int __pyx_pf_5kenlm_6Config_11load_method_2__set__(struct __pyx_obj_5kenlm_Config *__pyx_v_self, PyObject *__pyx_v_to); /* proto */
static PyObject *__pyx_pf_5kenlm_6Config_13show_progress___get__(struct __pyx_obj_5kenlm_Config *__pyx_v_self); /* proto */
static int __pyx_pf_5kenlm_6Config_13show_progress_2__set__(struct __pyx_obj_5kenlm_Config *__pyx_v_self, PyObject *__pyx_v_to); /* proto */
+static PyObject *__pyx_pf_5kenlm_6Config_13arpa_complain___get__(struct __pyx_obj_5kenlm_Config *__pyx_v_self); /* proto */
+static int __pyx_pf_5kenlm_6Config_13arpa_complain_2__set__(struct __pyx_obj_5kenlm_Config *__pyx_v_self, PyObject *__pyx_v_to); /* proto */
static PyObject *__pyx_pf_5kenlm_6Config_2__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5kenlm_Config *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5kenlm_6Config_4__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5kenlm_Config *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */
static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_v_self, PyObject *__pyx_v_path, struct __pyx_obj_5kenlm_Config *__pyx_v_config); /* proto */
@@ -1659,6 +1690,9 @@ static PyObject *__pyx_f_5kenlm_as_str(PyObject *__pyx_v_data) {
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("as_str", 0);
/* "kenlm.pyx":5
@@ -1795,6 +1829,9 @@ static int __pyx_pw_5kenlm_15FullScoreReturn_1__cinit__(PyObject *__pyx_v_self,
PyObject *__pyx_v_log_prob = 0;
PyObject *__pyx_v_ngram_length = 0;
PyObject *__pyx_v_oov = 0;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
@@ -1867,6 +1904,9 @@ static int __pyx_pf_5kenlm_15FullScoreReturn___cinit__(struct __pyx_obj_5kenlm_F
float __pyx_t_1;
int __pyx_t_2;
int __pyx_t_3;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
/* "kenlm.pyx":25
@@ -1951,6 +1991,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_2__repr__(struct __pyx_obj_5k
PyObject *__pyx_t_7 = NULL;
int __pyx_t_8;
PyObject *__pyx_t_9 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__repr__", 0);
/* "kenlm.pyx":30
@@ -2097,6 +2140,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_8log_prob___get__(struct __py
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "kenlm.pyx":34
@@ -2157,6 +2203,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_12ngram_length___get__(struct
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "kenlm.pyx":38
@@ -2217,6 +2266,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_3oov___get__(struct __pyx_obj
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
/* "kenlm.pyx":42
@@ -2275,6 +2327,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_4__reduce_cython__(CYTHON_UNU
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
@@ -2329,6 +2384,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_6__setstate_cython__(CYTHON_U
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
@@ -2370,6 +2428,9 @@ static PyObject *__pyx_pf_5kenlm_15FullScoreReturn_6__setstate_cython__(CYTHON_U
/* Python wrapper */
static PyObject *__pyx_pw_5kenlm_5State_1__richcmp__(PyObject *__pyx_v_qa, PyObject *__pyx_v_qb, int __pyx_v_op); /*proto*/
static PyObject *__pyx_pw_5kenlm_5State_1__richcmp__(PyObject *__pyx_v_qa, PyObject *__pyx_v_qb, int __pyx_v_op) {
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
@@ -2390,6 +2451,9 @@ static PyObject *__pyx_pf_5kenlm_5State___richcmp__(struct __pyx_obj_5kenlm_Stat
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__richcmp__", 0);
/* "kenlm.pyx":56
@@ -2644,6 +2708,9 @@ static PyObject *__pyx_pf_5kenlm_5State_4__copy__(struct __pyx_obj_5kenlm_State
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
lm::ngram::State __pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__copy__", 0);
/* "kenlm.pyx":74
@@ -2727,6 +2794,9 @@ static PyObject *__pyx_pf_5kenlm_5State_6__deepcopy__(struct __pyx_obj_5kenlm_St
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__deepcopy__", 0);
/* "kenlm.pyx":79
@@ -2802,6 +2872,9 @@ static PyObject *__pyx_pf_5kenlm_5State_8__reduce_cython__(CYTHON_UNUSED struct
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
@@ -2856,6 +2929,9 @@ static PyObject *__pyx_pf_5kenlm_5State_10__setstate_cython__(CYTHON_UNUSED stru
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
@@ -2886,7 +2962,7 @@ static PyObject *__pyx_pf_5kenlm_5State_10__setstate_cython__(CYTHON_UNUSED stru
return __pyx_r;
}
-/* "kenlm.pyx":95
+/* "kenlm.pyx":100
* cdef _kenlm.Config _c_config
*
* def __init__(self): # <<<<<<<<<<<<<<
@@ -2915,7 +2991,7 @@ static int __pyx_pf_5kenlm_6Config___init__(struct __pyx_obj_5kenlm_Config *__py
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__", 0);
- /* "kenlm.pyx":96
+ /* "kenlm.pyx":101
*
* def __init__(self):
* self._c_config = _kenlm.Config() # <<<<<<<<<<<<<<
@@ -2924,7 +3000,7 @@ static int __pyx_pf_5kenlm_6Config___init__(struct __pyx_obj_5kenlm_Config *__py
*/
__pyx_v_self->_c_config = lm::ngram::Config();
- /* "kenlm.pyx":95
+ /* "kenlm.pyx":100
* cdef _kenlm.Config _c_config
*
* def __init__(self): # <<<<<<<<<<<<<<
@@ -2938,7 +3014,7 @@ static int __pyx_pf_5kenlm_6Config___init__(struct __pyx_obj_5kenlm_Config *__py
return __pyx_r;
}
-/* "kenlm.pyx":99
+/* "kenlm.pyx":104
*
* property load_method:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -2963,9 +3039,12 @@ static PyObject *__pyx_pf_5kenlm_6Config_11load_method___get__(struct __pyx_obj_
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "kenlm.pyx":100
+ /* "kenlm.pyx":105
* property load_method:
* def __get__(self):
* return self._c_config.load_method # <<<<<<<<<<<<<<
@@ -2973,13 +3052,13 @@ static PyObject *__pyx_pf_5kenlm_6Config_11load_method___get__(struct __pyx_obj_
* self._c_config.load_method = to
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_enum__util_3a__3a_LoadMethod(__pyx_v_self->_c_config.load_method); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 100, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyInt_From_enum__util_3a__3a_LoadMethod(__pyx_v_self->_c_config.load_method); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":99
+ /* "kenlm.pyx":104
*
* property load_method:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -2998,7 +3077,7 @@ static PyObject *__pyx_pf_5kenlm_6Config_11load_method___get__(struct __pyx_obj_
return __pyx_r;
}
-/* "kenlm.pyx":101
+/* "kenlm.pyx":106
* def __get__(self):
* return self._c_config.load_method
* def __set__(self, to): # <<<<<<<<<<<<<<
@@ -3023,19 +3102,22 @@ static int __pyx_pf_5kenlm_6Config_11load_method_2__set__(struct __pyx_obj_5kenl
int __pyx_r;
__Pyx_RefNannyDeclarations
enum util::LoadMethod __pyx_t_1;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "kenlm.pyx":102
+ /* "kenlm.pyx":107
* return self._c_config.load_method
* def __set__(self, to):
* self._c_config.load_method = to # <<<<<<<<<<<<<<
*
* property show_progress:
*/
- __pyx_t_1 = ((enum util::LoadMethod)__Pyx_PyInt_As_enum__util_3a__3a_LoadMethod(__pyx_v_to)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L1_error)
+ __pyx_t_1 = ((enum util::LoadMethod)__Pyx_PyInt_As_enum__util_3a__3a_LoadMethod(__pyx_v_to)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 107, __pyx_L1_error)
__pyx_v_self->_c_config.load_method = __pyx_t_1;
- /* "kenlm.pyx":101
+ /* "kenlm.pyx":106
* def __get__(self):
* return self._c_config.load_method
* def __set__(self, to): # <<<<<<<<<<<<<<
@@ -3054,7 +3136,7 @@ static int __pyx_pf_5kenlm_6Config_11load_method_2__set__(struct __pyx_obj_5kenl
return __pyx_r;
}
-/* "kenlm.pyx":105
+/* "kenlm.pyx":110
*
* property show_progress:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -3079,9 +3161,12 @@ static PyObject *__pyx_pf_5kenlm_6Config_13show_progress___get__(struct __pyx_ob
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "kenlm.pyx":106
+ /* "kenlm.pyx":111
* property show_progress:
* def __get__(self):
* return self._c_config.show_progress # <<<<<<<<<<<<<<
@@ -3089,13 +3174,13 @@ static PyObject *__pyx_pf_5kenlm_6Config_13show_progress___get__(struct __pyx_ob
* self._c_config.show_progress = to
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_config.show_progress); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_c_config.show_progress); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":105
+ /* "kenlm.pyx":110
*
* property show_progress:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -3114,7 +3199,7 @@ static PyObject *__pyx_pf_5kenlm_6Config_13show_progress___get__(struct __pyx_ob
return __pyx_r;
}
-/* "kenlm.pyx":107
+/* "kenlm.pyx":112
* def __get__(self):
* return self._c_config.show_progress
* def __set__(self, to): # <<<<<<<<<<<<<<
@@ -3139,19 +3224,22 @@ static int __pyx_pf_5kenlm_6Config_13show_progress_2__set__(struct __pyx_obj_5ke
int __pyx_r;
__Pyx_RefNannyDeclarations
bool __pyx_t_1;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- /* "kenlm.pyx":108
+ /* "kenlm.pyx":113
* return self._c_config.show_progress
* def __set__(self, to):
* self._c_config.show_progress = to # <<<<<<<<<<<<<<
*
- * cdef class Model:
+ * property arpa_complain:
*/
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_to); if (unlikely((__pyx_t_1 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 108, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_to); if (unlikely((__pyx_t_1 == ((bool)-1)) && PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L1_error)
__pyx_v_self->_c_config.show_progress = __pyx_t_1;
- /* "kenlm.pyx":107
+ /* "kenlm.pyx":112
* def __get__(self):
* return self._c_config.show_progress
* def __set__(self, to): # <<<<<<<<<<<<<<
@@ -3170,6 +3258,128 @@ static int __pyx_pf_5kenlm_6Config_13show_progress_2__set__(struct __pyx_obj_5ke
return __pyx_r;
}
+/* "kenlm.pyx":116
+ *
+ * property arpa_complain:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self._c_config.arpa_complain
+ * def __set__(self, to):
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5kenlm_6Config_13arpa_complain_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5kenlm_6Config_13arpa_complain_1__get__(PyObject *__pyx_v_self) {
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5kenlm_6Config_13arpa_complain___get__(((struct __pyx_obj_5kenlm_Config *)__pyx_v_self));
+
+ /* function exit code */
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static PyObject *__pyx_pf_5kenlm_6Config_13arpa_complain___get__(struct __pyx_obj_5kenlm_Config *__pyx_v_self) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__get__", 0);
+
+ /* "kenlm.pyx":117
+ * property arpa_complain:
+ * def __get__(self):
+ * return self._c_config.arpa_complain # <<<<<<<<<<<<<<
+ * def __set__(self, to):
+ * self._c_config.arpa_complain = to
+ */
+ __Pyx_XDECREF(__pyx_r);
+ __pyx_t_1 = __Pyx_PyInt_From_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(__pyx_v_self->_c_config.arpa_complain); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 117, __pyx_L1_error)
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_r = __pyx_t_1;
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+
+ /* "kenlm.pyx":116
+ *
+ * property arpa_complain:
+ * def __get__(self): # <<<<<<<<<<<<<<
+ * return self._c_config.arpa_complain
+ * def __set__(self, to):
+ */
+
+ /* function exit code */
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_AddTraceback("kenlm.Config.arpa_complain.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* "kenlm.pyx":118
+ * def __get__(self):
+ * return self._c_config.arpa_complain
+ * def __set__(self, to): # <<<<<<<<<<<<<<
+ * self._c_config.arpa_complain = to
+ *
+ */
+
+/* Python wrapper */
+static int __pyx_pw_5kenlm_6Config_13arpa_complain_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_to); /*proto*/
+static int __pyx_pw_5kenlm_6Config_13arpa_complain_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_to) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+ __pyx_r = __pyx_pf_5kenlm_6Config_13arpa_complain_2__set__(((struct __pyx_obj_5kenlm_Config *)__pyx_v_self), ((PyObject *)__pyx_v_to));
+
+ /* function exit code */
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static int __pyx_pf_5kenlm_6Config_13arpa_complain_2__set__(struct __pyx_obj_5kenlm_Config *__pyx_v_self, PyObject *__pyx_v_to) {
+ int __pyx_r;
+ __Pyx_RefNannyDeclarations
+ enum lm::ngram::Config::ARPALoadComplain __pyx_t_1;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("__set__", 0);
+
+ /* "kenlm.pyx":119
+ * return self._c_config.arpa_complain
+ * def __set__(self, to):
+ * self._c_config.arpa_complain = to # <<<<<<<<<<<<<<
+ *
+ * cdef class Model:
+ */
+ __pyx_t_1 = ((enum lm::ngram::Config::ARPALoadComplain)__Pyx_PyInt_As_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(__pyx_v_to)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 119, __pyx_L1_error)
+ __pyx_v_self->_c_config.arpa_complain = __pyx_t_1;
+
+ /* "kenlm.pyx":118
+ * def __get__(self):
+ * return self._c_config.arpa_complain
+ * def __set__(self, to): # <<<<<<<<<<<<<<
+ * self._c_config.arpa_complain = to
+ *
+ */
+
+ /* function exit code */
+ __pyx_r = 0;
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_AddTraceback("kenlm.Config.arpa_complain.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = -1;
+ __pyx_L0:;
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
/* "(tree fragment)":1
* def __reduce_cython__(self): # <<<<<<<<<<<<<<
* raise TypeError("self._c_config cannot be converted to a Python object for pickling")
@@ -3193,6 +3403,9 @@ static PyObject *__pyx_pf_5kenlm_6Config_2__reduce_cython__(CYTHON_UNUSED struct
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce_cython__", 0);
/* "(tree fragment)":2
@@ -3247,6 +3460,9 @@ static PyObject *__pyx_pf_5kenlm_6Config_4__setstate_cython__(CYTHON_UNUSED stru
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__setstate_cython__", 0);
/* "(tree fragment)":4
@@ -3277,7 +3493,7 @@ static PyObject *__pyx_pf_5kenlm_6Config_4__setstate_cython__(CYTHON_UNUSED stru
return __pyx_r;
}
-/* "kenlm.pyx":119
+/* "kenlm.pyx":130
* cdef _kenlm.const_Vocabulary* vocab
*
* def __init__(self, path, Config config = Config()): # <<<<<<<<<<<<<<
@@ -3294,6 +3510,9 @@ struct wrapperbase __pyx_wrapperbase_5kenlm_5Model___init__;
static int __pyx_pw_5kenlm_5Model_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
PyObject *__pyx_v_path = 0;
struct __pyx_obj_5kenlm_Config *__pyx_v_config = 0;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
int __pyx_r;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
@@ -3325,7 +3544,7 @@ static int __pyx_pw_5kenlm_5Model_1__init__(PyObject *__pyx_v_self, PyObject *__
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 119, __pyx_L3_error)
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 130, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -3341,13 +3560,13 @@ static int __pyx_pw_5kenlm_5Model_1__init__(PyObject *__pyx_v_self, PyObject *__
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 119, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 130, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("kenlm.Model.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return -1;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_config), __pyx_ptype_5kenlm_Config, 1, "config", 0))) __PYX_ERR(0, 119, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_config), __pyx_ptype_5kenlm_Config, 1, "config", 0))) __PYX_ERR(0, 130, __pyx_L1_error)
__pyx_r = __pyx_pf_5kenlm_5Model___init__(((struct __pyx_obj_5kenlm_Model *)__pyx_v_self), __pyx_v_path, __pyx_v_config);
/* function exit code */
@@ -3385,24 +3604,27 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
PyObject *__pyx_t_19 = NULL;
PyObject *__pyx_t_20 = NULL;
PyObject *__pyx_t_21 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__init__", 0);
- /* "kenlm.pyx":126
+ /* "kenlm.pyx":137
* :param config: configuration options (see lm/config.hh for documentation)
* """
* self.path = os.path.abspath(as_str(path)) # <<<<<<<<<<<<<<
* try:
* self.model = _kenlm.LoadVirtual(self.path, config._c_config)
*/
- __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
+ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_abspath); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_abspath); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = __pyx_f_5kenlm_as_str(__pyx_v_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error)
+ __pyx_t_3 = __pyx_f_5kenlm_as_str(__pyx_v_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_4 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
@@ -3417,17 +3639,17 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
+ if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 126, __pyx_L1_error)
+ if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 137, __pyx_L1_error)
__Pyx_GIVEREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_v_self->path);
__Pyx_DECREF(__pyx_v_self->path);
__pyx_v_self->path = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
- /* "kenlm.pyx":127
+ /* "kenlm.pyx":138
* """
* self.path = os.path.abspath(as_str(path))
* try: # <<<<<<<<<<<<<<
@@ -3443,7 +3665,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__Pyx_XGOTREF(__pyx_t_7);
/*try:*/ {
- /* "kenlm.pyx":128
+ /* "kenlm.pyx":139
* self.path = os.path.abspath(as_str(path))
* try:
* self.model = _kenlm.LoadVirtual(self.path, config._c_config) # <<<<<<<<<<<<<<
@@ -3452,18 +3674,18 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
*/
if (unlikely(__pyx_v_self->path == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(0, 128, __pyx_L3_error)
+ __PYX_ERR(0, 139, __pyx_L3_error)
}
- __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->path); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 128, __pyx_L3_error)
+ __pyx_t_8 = __Pyx_PyBytes_AsWritableString(__pyx_v_self->path); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 139, __pyx_L3_error)
try {
__pyx_t_9 = lm::ngram::LoadVirtual(__pyx_t_8, __pyx_v_config->_c_config);
} catch(...) {
__Pyx_CppExn2PyErr();
- __PYX_ERR(0, 128, __pyx_L3_error)
+ __PYX_ERR(0, 139, __pyx_L3_error)
}
__pyx_v_self->model = __pyx_t_9;
- /* "kenlm.pyx":127
+ /* "kenlm.pyx":138
* """
* self.path = os.path.abspath(as_str(path))
* try: # <<<<<<<<<<<<<<
@@ -3481,7 +3703,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
- /* "kenlm.pyx":129
+ /* "kenlm.pyx":140
* try:
* self.model = _kenlm.LoadVirtual(self.path, config._c_config)
* except RuntimeError as exception: # <<<<<<<<<<<<<<
@@ -3491,7 +3713,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__pyx_t_10 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_RuntimeError);
if (__pyx_t_10) {
__Pyx_AddTraceback("kenlm.Model.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
- if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 129, __pyx_L5_except_error)
+ if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 140, __pyx_L5_except_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_GOTREF(__pyx_t_2);
__Pyx_GOTREF(__pyx_t_3);
@@ -3499,29 +3721,29 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__pyx_v_exception = __pyx_t_2;
/*try:*/ {
- /* "kenlm.pyx":130
+ /* "kenlm.pyx":141
* self.model = _kenlm.LoadVirtual(self.path, config._c_config)
* except RuntimeError as exception:
* exception_message = str(exception).replace('\n', ' ') # <<<<<<<<<<<<<<
* raise IOError('Cannot read model \'{}\' ({})'.format(path, exception_message))\
* from exception
*/
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L14_error)
+ __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_v_exception); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 141, __pyx_L14_error)
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_11 = PyUnicode_Replace(((PyObject*)__pyx_t_4), __pyx_kp_u__8, __pyx_kp_u__9, -1L); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 130, __pyx_L14_error)
+ __pyx_t_11 = PyUnicode_Replace(((PyObject*)__pyx_t_4), __pyx_kp_u__8, __pyx_kp_u__9, -1L); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 141, __pyx_L14_error)
__Pyx_GOTREF(__pyx_t_11);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_v_exception_message = __pyx_t_11;
__pyx_t_11 = 0;
- /* "kenlm.pyx":131
+ /* "kenlm.pyx":142
* except RuntimeError as exception:
* exception_message = str(exception).replace('\n', ' ')
* raise IOError('Cannot read model \'{}\' ({})'.format(path, exception_message))\ # <<<<<<<<<<<<<<
* from exception
* self.vocab = &self.model.BaseVocabulary()
*/
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Cannot_read_model, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L14_error)
+ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Cannot_read_model, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L14_error)
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_12 = NULL;
__pyx_t_10 = 0;
@@ -3538,7 +3760,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
#if CYTHON_FAST_PYCALL
if (PyFunction_Check(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_path, __pyx_v_exception_message};
- __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 131, __pyx_L14_error)
+ __pyx_t_11 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 142, __pyx_L14_error)
__Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
__Pyx_GOTREF(__pyx_t_11);
} else
@@ -3546,13 +3768,13 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
#if CYTHON_FAST_PYCCALL
if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
PyObject *__pyx_temp[3] = {__pyx_t_12, __pyx_v_path, __pyx_v_exception_message};
- __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 131, __pyx_L14_error)
+ __pyx_t_11 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_10, 2+__pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 142, __pyx_L14_error)
__Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
__Pyx_GOTREF(__pyx_t_11);
} else
#endif
{
- __pyx_t_13 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 131, __pyx_L14_error)
+ __pyx_t_13 = PyTuple_New(2+__pyx_t_10); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 142, __pyx_L14_error)
__Pyx_GOTREF(__pyx_t_13);
if (__pyx_t_12) {
__Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
@@ -3563,16 +3785,16 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__Pyx_INCREF(__pyx_v_exception_message);
__Pyx_GIVEREF(__pyx_v_exception_message);
PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_10, __pyx_v_exception_message);
- __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 131, __pyx_L14_error)
+ __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_13, NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 142, __pyx_L14_error)
__Pyx_GOTREF(__pyx_t_11);
__Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IOError, __pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L14_error)
+ __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_builtin_IOError, __pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 142, __pyx_L14_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
- /* "kenlm.pyx":132
+ /* "kenlm.pyx":143
* exception_message = str(exception).replace('\n', ' ')
* raise IOError('Cannot read model \'{}\' ({})'.format(path, exception_message))\
* from exception # <<<<<<<<<<<<<<
@@ -3581,10 +3803,10 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
*/
__Pyx_Raise(__pyx_t_4, 0, 0, __pyx_v_exception);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __PYX_ERR(0, 131, __pyx_L14_error)
+ __PYX_ERR(0, 142, __pyx_L14_error)
}
- /* "kenlm.pyx":129
+ /* "kenlm.pyx":140
* try:
* self.model = _kenlm.LoadVirtual(self.path, config._c_config)
* except RuntimeError as exception: # <<<<<<<<<<<<<<
@@ -3633,7 +3855,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
goto __pyx_L5_except_error;
__pyx_L5_except_error:;
- /* "kenlm.pyx":127
+ /* "kenlm.pyx":138
* """
* self.path = os.path.abspath(as_str(path))
* try: # <<<<<<<<<<<<<<
@@ -3648,7 +3870,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
__pyx_L8_try_end:;
}
- /* "kenlm.pyx":133
+ /* "kenlm.pyx":144
* raise IOError('Cannot read model \'{}\' ({})'.format(path, exception_message))\
* from exception
* self.vocab = &self.model.BaseVocabulary() # <<<<<<<<<<<<<<
@@ -3657,7 +3879,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
*/
__pyx_v_self->vocab = (&__pyx_v_self->model->BaseVocabulary());
- /* "kenlm.pyx":119
+ /* "kenlm.pyx":130
* cdef _kenlm.const_Vocabulary* vocab
*
* def __init__(self, path, Config config = Config()): # <<<<<<<<<<<<<<
@@ -3685,7 +3907,7 @@ static int __pyx_pf_5kenlm_5Model___init__(struct __pyx_obj_5kenlm_Model *__pyx_
return __pyx_r;
}
-/* "kenlm.pyx":135
+/* "kenlm.pyx":146
* self.vocab = &self.model.BaseVocabulary()
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -3708,7 +3930,7 @@ static void __pyx_pf_5kenlm_5Model_2__dealloc__(struct __pyx_obj_5kenlm_Model *_
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "kenlm.pyx":136
+ /* "kenlm.pyx":147
*
* def __dealloc__(self):
* del self.model # <<<<<<<<<<<<<<
@@ -3717,7 +3939,7 @@ static void __pyx_pf_5kenlm_5Model_2__dealloc__(struct __pyx_obj_5kenlm_Model *_
*/
delete __pyx_v_self->model;
- /* "kenlm.pyx":135
+ /* "kenlm.pyx":146
* self.vocab = &self.model.BaseVocabulary()
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -3729,7 +3951,7 @@ static void __pyx_pf_5kenlm_5Model_2__dealloc__(struct __pyx_obj_5kenlm_Model *_
__Pyx_RefNannyFinishContext();
}
-/* "kenlm.pyx":139
+/* "kenlm.pyx":150
*
* property order:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -3754,9 +3976,12 @@ static PyObject *__pyx_pf_5kenlm_5Model_5order___get__(struct __pyx_obj_5kenlm_M
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__get__", 0);
- /* "kenlm.pyx":140
+ /* "kenlm.pyx":151
* property order:
* def __get__(self):
* return self.model.Order() # <<<<<<<<<<<<<<
@@ -3764,13 +3989,13 @@ static PyObject *__pyx_pf_5kenlm_5Model_5order___get__(struct __pyx_obj_5kenlm_M
* def score(self, sentence, bos = True, eos = True):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->model->Order()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_self->model->Order()); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":139
+ /* "kenlm.pyx":150
*
* property order:
* def __get__(self): # <<<<<<<<<<<<<<
@@ -3789,7 +4014,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_5order___get__(struct __pyx_obj_5kenlm_M
return __pyx_r;
}
-/* "kenlm.pyx":142
+/* "kenlm.pyx":153
* return self.model.Order()
*
* def score(self, sentence, bos = True, eos = True): # <<<<<<<<<<<<<<
@@ -3804,6 +4029,9 @@ static PyObject *__pyx_pw_5kenlm_5Model_5score(PyObject *__pyx_v_self, PyObject
PyObject *__pyx_v_sentence = 0;
PyObject *__pyx_v_bos = 0;
PyObject *__pyx_v_eos = 0;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("score (wrapper)", 0);
@@ -3844,7 +4072,7 @@ static PyObject *__pyx_pw_5kenlm_5Model_5score(PyObject *__pyx_v_self, PyObject
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "score") < 0)) __PYX_ERR(0, 142, __pyx_L3_error)
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "score") < 0)) __PYX_ERR(0, 153, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -3863,7 +4091,7 @@ static PyObject *__pyx_pw_5kenlm_5Model_5score(PyObject *__pyx_v_self, PyObject
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("score", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 142, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("score", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 153, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("kenlm.Model.score", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -3892,27 +4120,30 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
PyObject *__pyx_t_6 = NULL;
Py_ssize_t __pyx_t_7;
char *__pyx_t_8;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("score", 0);
- /* "kenlm.pyx":181
+ /* "kenlm.pyx":192
* model.score("a fragment </s>", bos = False, eos = False)
* """
* if bos and eos: # <<<<<<<<<<<<<<
* return _kenlm.ScoreSentence(self.model, as_str(sentence))
* cdef list words = as_str(sentence).split()
*/
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_bos); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 181, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_bos); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 192, __pyx_L1_error)
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
- __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_eos); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 181, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_eos); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 192, __pyx_L1_error)
__pyx_t_1 = __pyx_t_2;
__pyx_L4_bool_binop_done:;
if (__pyx_t_1) {
- /* "kenlm.pyx":182
+ /* "kenlm.pyx":193
* """
* if bos and eos:
* return _kenlm.ScoreSentence(self.model, as_str(sentence)) # <<<<<<<<<<<<<<
@@ -3920,21 +4151,21 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
* cdef _kenlm.State state
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __pyx_f_5kenlm_as_str(__pyx_v_sentence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error)
+ __pyx_t_3 = __pyx_f_5kenlm_as_str(__pyx_v_sentence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
if (unlikely(__pyx_t_3 == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(0, 182, __pyx_L1_error)
+ __PYX_ERR(0, 193, __pyx_L1_error)
}
- __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 182, __pyx_L1_error)
- __pyx_t_5 = PyFloat_FromDouble(lm::base::ScoreSentence(__pyx_v_self->model, __pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 182, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) __PYX_ERR(0, 193, __pyx_L1_error)
+ __pyx_t_5 = PyFloat_FromDouble(lm::base::ScoreSentence(__pyx_v_self->model, __pyx_t_4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 193, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":181
+ /* "kenlm.pyx":192
* model.score("a fragment </s>", bos = False, eos = False)
* """
* if bos and eos: # <<<<<<<<<<<<<<
@@ -3943,16 +4174,16 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
}
- /* "kenlm.pyx":183
+ /* "kenlm.pyx":194
* if bos and eos:
* return _kenlm.ScoreSentence(self.model, as_str(sentence))
* cdef list words = as_str(sentence).split() # <<<<<<<<<<<<<<
* cdef _kenlm.State state
* if bos:
*/
- __pyx_t_3 = __pyx_f_5kenlm_as_str(__pyx_v_sentence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error)
+ __pyx_t_3 = __pyx_f_5kenlm_as_str(__pyx_v_sentence); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 194, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 183, __pyx_L1_error)
+ __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_split); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 194, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__pyx_t_3 = NULL;
@@ -3967,24 +4198,24 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
}
__pyx_t_5 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 183, __pyx_L1_error)
+ if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 194, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 183, __pyx_L1_error)
+ if (!(likely(PyList_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_5)->tp_name), 0))) __PYX_ERR(0, 194, __pyx_L1_error)
__pyx_v_words = ((PyObject*)__pyx_t_5);
__pyx_t_5 = 0;
- /* "kenlm.pyx":185
+ /* "kenlm.pyx":196
* cdef list words = as_str(sentence).split()
* cdef _kenlm.State state
* if bos: # <<<<<<<<<<<<<<
* self.model.BeginSentenceWrite(&state)
* else:
*/
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_bos); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 185, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_bos); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 196, __pyx_L1_error)
if (__pyx_t_1) {
- /* "kenlm.pyx":186
+ /* "kenlm.pyx":197
* cdef _kenlm.State state
* if bos:
* self.model.BeginSentenceWrite(&state) # <<<<<<<<<<<<<<
@@ -3993,7 +4224,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
__pyx_v_self->model->BeginSentenceWrite((&__pyx_v_state));
- /* "kenlm.pyx":185
+ /* "kenlm.pyx":196
* cdef list words = as_str(sentence).split()
* cdef _kenlm.State state
* if bos: # <<<<<<<<<<<<<<
@@ -4003,7 +4234,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
goto __pyx_L6;
}
- /* "kenlm.pyx":188
+ /* "kenlm.pyx":199
* self.model.BeginSentenceWrite(&state)
* else:
* self.model.NullContextWrite(&state) # <<<<<<<<<<<<<<
@@ -4015,7 +4246,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
}
__pyx_L6:;
- /* "kenlm.pyx":190
+ /* "kenlm.pyx":201
* self.model.NullContextWrite(&state)
* cdef _kenlm.State out_state
* cdef float total = 0 # <<<<<<<<<<<<<<
@@ -4024,7 +4255,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
__pyx_v_total = 0.0;
- /* "kenlm.pyx":191
+ /* "kenlm.pyx":202
* cdef _kenlm.State out_state
* cdef float total = 0
* for word in words: # <<<<<<<<<<<<<<
@@ -4033,31 +4264,31 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
if (unlikely(__pyx_v_words == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 191, __pyx_L1_error)
+ __PYX_ERR(0, 202, __pyx_L1_error)
}
__pyx_t_5 = __pyx_v_words; __Pyx_INCREF(__pyx_t_5); __pyx_t_7 = 0;
for (;;) {
if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_5)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 191, __pyx_L1_error)
+ __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_7); __Pyx_INCREF(__pyx_t_6); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 202, __pyx_L1_error)
#else
- __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 191, __pyx_L1_error)
+ __pyx_t_6 = PySequence_ITEM(__pyx_t_5, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 202, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_6);
#endif
__Pyx_XDECREF_SET(__pyx_v_word, __pyx_t_6);
__pyx_t_6 = 0;
- /* "kenlm.pyx":192
+ /* "kenlm.pyx":203
* cdef float total = 0
* for word in words:
* total += self.model.BaseScore(&state, self.vocab.Index(word), &out_state) # <<<<<<<<<<<<<<
* state = out_state
* if eos:
*/
- __pyx_t_8 = __Pyx_PyObject_AsWritableString(__pyx_v_word); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L1_error)
+ __pyx_t_8 = __Pyx_PyObject_AsWritableString(__pyx_v_word); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 203, __pyx_L1_error)
__pyx_v_total = (__pyx_v_total + __pyx_v_self->model->BaseScore((&__pyx_v_state), __pyx_v_self->vocab->Index(__pyx_t_8), (&__pyx_v_out_state)));
- /* "kenlm.pyx":193
+ /* "kenlm.pyx":204
* for word in words:
* total += self.model.BaseScore(&state, self.vocab.Index(word), &out_state)
* state = out_state # <<<<<<<<<<<<<<
@@ -4066,7 +4297,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
__pyx_v_state = __pyx_v_out_state;
- /* "kenlm.pyx":191
+ /* "kenlm.pyx":202
* cdef _kenlm.State out_state
* cdef float total = 0
* for word in words: # <<<<<<<<<<<<<<
@@ -4076,17 +4307,17 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
}
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
- /* "kenlm.pyx":194
+ /* "kenlm.pyx":205
* total += self.model.BaseScore(&state, self.vocab.Index(word), &out_state)
* state = out_state
* if eos: # <<<<<<<<<<<<<<
* total += self.model.BaseScore(&state, self.vocab.EndSentence(), &out_state)
* return total
*/
- __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_eos); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 194, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_eos); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 205, __pyx_L1_error)
if (__pyx_t_1) {
- /* "kenlm.pyx":195
+ /* "kenlm.pyx":206
* state = out_state
* if eos:
* total += self.model.BaseScore(&state, self.vocab.EndSentence(), &out_state) # <<<<<<<<<<<<<<
@@ -4095,7 +4326,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
__pyx_v_total = (__pyx_v_total + __pyx_v_self->model->BaseScore((&__pyx_v_state), __pyx_v_self->vocab->EndSentence(), (&__pyx_v_out_state)));
- /* "kenlm.pyx":194
+ /* "kenlm.pyx":205
* total += self.model.BaseScore(&state, self.vocab.Index(word), &out_state)
* state = out_state
* if eos: # <<<<<<<<<<<<<<
@@ -4104,7 +4335,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
*/
}
- /* "kenlm.pyx":196
+ /* "kenlm.pyx":207
* if eos:
* total += self.model.BaseScore(&state, self.vocab.EndSentence(), &out_state)
* return total # <<<<<<<<<<<<<<
@@ -4112,13 +4343,13 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
* def perplexity(self, sentence):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_5 = PyFloat_FromDouble(__pyx_v_total); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 196, __pyx_L1_error)
+ __pyx_t_5 = PyFloat_FromDouble(__pyx_v_total); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__pyx_r = __pyx_t_5;
__pyx_t_5 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":142
+ /* "kenlm.pyx":153
* return self.model.Order()
*
* def score(self, sentence, bos = True, eos = True): # <<<<<<<<<<<<<<
@@ -4141,7 +4372,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_4score(struct __pyx_obj_5kenlm_Model *__
return __pyx_r;
}
-/* "kenlm.pyx":198
+/* "kenlm.pyx":209
* return total
*
* def perplexity(self, sentence): # <<<<<<<<<<<<<<
@@ -4171,18 +4402,21 @@ static PyObject *__pyx_pf_5kenlm_5Model_6perplexity(struct __pyx_obj_5kenlm_Mode
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
Py_ssize_t __pyx_t_4;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("perplexity", 0);
- /* "kenlm.pyx":203
+ /* "kenlm.pyx":214
* @param sentence One full sentence to score. Do not include <s> or </s>.
* """
* words = len(as_str(sentence).split()) + 1 # For </s> # <<<<<<<<<<<<<<
* return 10.0**(-self.score(sentence) / words)
*
*/
- __pyx_t_2 = __pyx_f_5kenlm_as_str(__pyx_v_sentence); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error)
+ __pyx_t_2 = __pyx_f_5kenlm_as_str(__pyx_v_sentence); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 203, __pyx_L1_error)
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
@@ -4197,17 +4431,17 @@ static PyObject *__pyx_pf_5kenlm_5Model_6perplexity(struct __pyx_obj_5kenlm_Mode
}
__pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
+ if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 203, __pyx_L1_error)
+ __pyx_t_4 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 214, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_4 + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error)
+ __pyx_t_1 = PyInt_FromSsize_t((__pyx_t_4 + 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_words = __pyx_t_1;
__pyx_t_1 = 0;
- /* "kenlm.pyx":204
+ /* "kenlm.pyx":215
* """
* words = len(as_str(sentence).split()) + 1 # For </s>
* return 10.0**(-self.score(sentence) / words) # <<<<<<<<<<<<<<
@@ -4215,7 +4449,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_6perplexity(struct __pyx_obj_5kenlm_Mode
* def full_scores(self, sentence, bos = True, eos = True):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_score); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_score); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__pyx_t_2 = NULL;
if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
@@ -4229,23 +4463,23 @@ static PyObject *__pyx_pf_5kenlm_5Model_6perplexity(struct __pyx_obj_5kenlm_Mode
}
__pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_sentence) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_sentence);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
+ if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
+ __pyx_t_3 = PyNumber_Negative(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_words); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 204, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_v_words); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- __pyx_t_3 = PyNumber_Power(__pyx_float_10_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 204, __pyx_L1_error)
+ __pyx_t_3 = PyNumber_Power(__pyx_float_10_0, __pyx_t_1, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 215, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_r = __pyx_t_3;
__pyx_t_3 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":198
+ /* "kenlm.pyx":209
* return total
*
* def perplexity(self, sentence): # <<<<<<<<<<<<<<
@@ -4268,7 +4502,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_6perplexity(struct __pyx_obj_5kenlm_Mode
}
static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */
-/* "kenlm.pyx":206
+/* "kenlm.pyx":217
* return 10.0**(-self.score(sentence) / words)
*
* def full_scores(self, sentence, bos = True, eos = True): # <<<<<<<<<<<<<<
@@ -4283,6 +4517,9 @@ static PyObject *__pyx_pw_5kenlm_5Model_9full_scores(PyObject *__pyx_v_self, PyO
PyObject *__pyx_v_sentence = 0;
PyObject *__pyx_v_bos = 0;
PyObject *__pyx_v_eos = 0;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("full_scores (wrapper)", 0);
@@ -4323,7 +4560,7 @@ static PyObject *__pyx_pw_5kenlm_5Model_9full_scores(PyObject *__pyx_v_self, PyO
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "full_scores") < 0)) __PYX_ERR(0, 206, __pyx_L3_error)
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "full_scores") < 0)) __PYX_ERR(0, 217, __pyx_L3_error)
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -4342,7 +4579,7 @@ static PyObject *__pyx_pw_5kenlm_5Model_9full_scores(PyObject *__pyx_v_self, PyO
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("full_scores", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 206, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("full_scores", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 217, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("kenlm.Model.full_scores", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -4359,12 +4596,15 @@ static PyObject *__pyx_pf_5kenlm_5Model_8full_scores(struct __pyx_obj_5kenlm_Mod
struct __pyx_obj_5kenlm___pyx_scope_struct__full_scores *__pyx_cur_scope;
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("full_scores", 0);
__pyx_cur_scope = (struct __pyx_obj_5kenlm___pyx_scope_struct__full_scores *)__pyx_tp_new_5kenlm___pyx_scope_struct__full_scores(__pyx_ptype_5kenlm___pyx_scope_struct__full_scores, __pyx_empty_tuple, NULL);
if (unlikely(!__pyx_cur_scope)) {
__pyx_cur_scope = ((struct __pyx_obj_5kenlm___pyx_scope_struct__full_scores *)Py_None);
__Pyx_INCREF(Py_None);
- __PYX_ERR(0, 206, __pyx_L1_error)
+ __PYX_ERR(0, 217, __pyx_L1_error)
} else {
__Pyx_GOTREF(__pyx_cur_scope);
}
@@ -4381,7 +4621,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_8full_scores(struct __pyx_obj_5kenlm_Mod
__Pyx_INCREF(__pyx_cur_scope->__pyx_v_eos);
__Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_eos);
{
- __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5kenlm_5Model_10generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_full_scores, __pyx_n_s_Model_full_scores, __pyx_n_s_kenlm); if (unlikely(!gen)) __PYX_ERR(0, 206, __pyx_L1_error)
+ __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_5kenlm_5Model_10generator, NULL, (PyObject *) __pyx_cur_scope, __pyx_n_s_full_scores, __pyx_n_s_Model_full_scores, __pyx_n_s_kenlm); if (unlikely(!gen)) __PYX_ERR(0, 217, __pyx_L1_error)
__Pyx_DECREF(__pyx_cur_scope);
__Pyx_RefNannyFinishContext();
return (PyObject *) gen;
@@ -4409,6 +4649,9 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
char *__pyx_t_6;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("full_scores", 0);
switch (__pyx_generator->resume_label) {
@@ -4420,18 +4663,18 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
return NULL;
}
__pyx_L3_first_run:;
- if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 206, __pyx_L1_error)
+ if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 217, __pyx_L1_error)
- /* "kenlm.pyx":213
+ /* "kenlm.pyx":224
* @param eos should kenlm add an eos state
* """
* cdef list words = as_str(sentence).split() # <<<<<<<<<<<<<<
* cdef _kenlm.State state
* if bos:
*/
- __pyx_t_2 = __pyx_f_5kenlm_as_str(__pyx_cur_scope->__pyx_v_sentence); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
+ __pyx_t_2 = __pyx_f_5kenlm_as_str(__pyx_cur_scope->__pyx_v_sentence); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error)
+ __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 224, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = NULL;
@@ -4446,25 +4689,25 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
}
__pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error)
+ if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 224, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 213, __pyx_L1_error)
+ if (!(likely(PyList_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 224, __pyx_L1_error)
__Pyx_GIVEREF(__pyx_t_1);
__pyx_cur_scope->__pyx_v_words = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
- /* "kenlm.pyx":215
+ /* "kenlm.pyx":226
* cdef list words = as_str(sentence).split()
* cdef _kenlm.State state
* if bos: # <<<<<<<<<<<<<<
* self.model.BeginSentenceWrite(&state)
* else:
*/
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_bos); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 215, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_bos); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 226, __pyx_L1_error)
if (__pyx_t_4) {
- /* "kenlm.pyx":216
+ /* "kenlm.pyx":227
* cdef _kenlm.State state
* if bos:
* self.model.BeginSentenceWrite(&state) # <<<<<<<<<<<<<<
@@ -4473,7 +4716,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
*/
__pyx_cur_scope->__pyx_v_self->model->BeginSentenceWrite((&__pyx_cur_scope->__pyx_v_state));
- /* "kenlm.pyx":215
+ /* "kenlm.pyx":226
* cdef list words = as_str(sentence).split()
* cdef _kenlm.State state
* if bos: # <<<<<<<<<<<<<<
@@ -4483,7 +4726,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
goto __pyx_L4;
}
- /* "kenlm.pyx":218
+ /* "kenlm.pyx":229
* self.model.BeginSentenceWrite(&state)
* else:
* self.model.NullContextWrite(&state) # <<<<<<<<<<<<<<
@@ -4495,7 +4738,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
}
__pyx_L4:;
- /* "kenlm.pyx":221
+ /* "kenlm.pyx":232
* cdef _kenlm.State out_state
* cdef _kenlm.FullScoreReturn ret
* cdef float total = 0 # <<<<<<<<<<<<<<
@@ -4504,7 +4747,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
*/
__pyx_cur_scope->__pyx_v_total = 0.0;
- /* "kenlm.pyx":223
+ /* "kenlm.pyx":234
* cdef float total = 0
* cdef _kenlm.WordIndex wid
* for word in words: # <<<<<<<<<<<<<<
@@ -4513,15 +4756,15 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
*/
if (unlikely(__pyx_cur_scope->__pyx_v_words == Py_None)) {
PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
- __PYX_ERR(0, 223, __pyx_L1_error)
+ __PYX_ERR(0, 234, __pyx_L1_error)
}
__pyx_t_1 = __pyx_cur_scope->__pyx_v_words; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
for (;;) {
if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
- __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 223, __pyx_L1_error)
+ __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_3); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 234, __pyx_L1_error)
#else
- __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 223, __pyx_L1_error)
+ __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
#endif
__Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_word);
@@ -4529,17 +4772,17 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_3 = 0;
- /* "kenlm.pyx":224
+ /* "kenlm.pyx":235
* cdef _kenlm.WordIndex wid
* for word in words:
* wid = self.vocab.Index(word) # <<<<<<<<<<<<<<
* ret = self.model.BaseFullScore(&state, wid, &out_state)
* yield (ret.prob, ret.ngram_length, wid == 0)
*/
- __pyx_t_6 = __Pyx_PyObject_AsWritableString(__pyx_cur_scope->__pyx_v_word); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 224, __pyx_L1_error)
+ __pyx_t_6 = __Pyx_PyObject_AsWritableString(__pyx_cur_scope->__pyx_v_word); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 235, __pyx_L1_error)
__pyx_cur_scope->__pyx_v_wid = __pyx_cur_scope->__pyx_v_self->vocab->Index(__pyx_t_6);
- /* "kenlm.pyx":225
+ /* "kenlm.pyx":236
* for word in words:
* wid = self.vocab.Index(word)
* ret = self.model.BaseFullScore(&state, wid, &out_state) # <<<<<<<<<<<<<<
@@ -4548,20 +4791,20 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
*/
__pyx_cur_scope->__pyx_v_ret = __pyx_cur_scope->__pyx_v_self->model->BaseFullScore((&__pyx_cur_scope->__pyx_v_state), __pyx_cur_scope->__pyx_v_wid, (&__pyx_cur_scope->__pyx_v_out_state));
- /* "kenlm.pyx":226
+ /* "kenlm.pyx":237
* wid = self.vocab.Index(word)
* ret = self.model.BaseFullScore(&state, wid, &out_state)
* yield (ret.prob, ret.ngram_length, wid == 0) # <<<<<<<<<<<<<<
* state = out_state
* if eos:
*/
- __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_ret.prob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error)
+ __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_ret.prob); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = __Pyx_PyInt_From_unsigned_char(__pyx_cur_scope->__pyx_v_ret.ngram_length); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyInt_From_unsigned_char(__pyx_cur_scope->__pyx_v_ret.ngram_length); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_7 = __Pyx_PyBool_FromLong((__pyx_cur_scope->__pyx_v_wid == 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 226, __pyx_L1_error)
+ __pyx_t_7 = __Pyx_PyBool_FromLong((__pyx_cur_scope->__pyx_v_wid == 0)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
- __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 226, __pyx_L1_error)
+ __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 237, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
__Pyx_GIVEREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
@@ -4588,9 +4831,9 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
__pyx_cur_scope->__pyx_t_0 = 0;
__Pyx_XGOTREF(__pyx_t_1);
__pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
- if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 226, __pyx_L1_error)
+ if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 237, __pyx_L1_error)
- /* "kenlm.pyx":227
+ /* "kenlm.pyx":238
* ret = self.model.BaseFullScore(&state, wid, &out_state)
* yield (ret.prob, ret.ngram_length, wid == 0)
* state = out_state # <<<<<<<<<<<<<<
@@ -4599,7 +4842,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
*/
__pyx_cur_scope->__pyx_v_state = __pyx_cur_scope->__pyx_v_out_state;
- /* "kenlm.pyx":223
+ /* "kenlm.pyx":234
* cdef float total = 0
* cdef _kenlm.WordIndex wid
* for word in words: # <<<<<<<<<<<<<<
@@ -4609,17 +4852,17 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /* "kenlm.pyx":228
+ /* "kenlm.pyx":239
* yield (ret.prob, ret.ngram_length, wid == 0)
* state = out_state
* if eos: # <<<<<<<<<<<<<<
* ret = self.model.BaseFullScore(&state,
* self.vocab.EndSentence(), &out_state)
*/
- __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_eos); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 228, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_eos); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 239, __pyx_L1_error)
if (__pyx_t_4) {
- /* "kenlm.pyx":229
+ /* "kenlm.pyx":240
* state = out_state
* if eos:
* ret = self.model.BaseFullScore(&state, # <<<<<<<<<<<<<<
@@ -4628,18 +4871,18 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
*/
__pyx_cur_scope->__pyx_v_ret = __pyx_cur_scope->__pyx_v_self->model->BaseFullScore((&__pyx_cur_scope->__pyx_v_state), __pyx_cur_scope->__pyx_v_self->vocab->EndSentence(), (&__pyx_cur_scope->__pyx_v_out_state));
- /* "kenlm.pyx":231
+ /* "kenlm.pyx":242
* ret = self.model.BaseFullScore(&state,
* self.vocab.EndSentence(), &out_state)
* yield (ret.prob, ret.ngram_length, False) # <<<<<<<<<<<<<<
*
*
*/
- __pyx_t_1 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_ret.prob); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error)
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_ret.prob); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_8 = __Pyx_PyInt_From_unsigned_char(__pyx_cur_scope->__pyx_v_ret.ngram_length); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 231, __pyx_L1_error)
+ __pyx_t_8 = __Pyx_PyInt_From_unsigned_char(__pyx_cur_scope->__pyx_v_ret.ngram_length); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 242, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_8);
- __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 231, __pyx_L1_error)
+ __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 242, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_7);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
@@ -4659,9 +4902,9 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
__pyx_generator->resume_label = 2;
return __pyx_r;
__pyx_L9_resume_from_yield:;
- if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 231, __pyx_L1_error)
+ if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 242, __pyx_L1_error)
- /* "kenlm.pyx":228
+ /* "kenlm.pyx":239
* yield (ret.prob, ret.ngram_length, wid == 0)
* state = out_state
* if eos: # <<<<<<<<<<<<<<
@@ -4671,7 +4914,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
}
CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);
- /* "kenlm.pyx":206
+ /* "kenlm.pyx":217
* return 10.0**(-self.score(sentence) / words)
*
* def full_scores(self, sentence, bos = True, eos = True): # <<<<<<<<<<<<<<
@@ -4700,7 +4943,7 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
return __pyx_r;
}
-/* "kenlm.pyx":234
+/* "kenlm.pyx":245
*
*
* def BeginSentenceWrite(self, State state): # <<<<<<<<<<<<<<
@@ -4712,10 +4955,13 @@ static PyObject *__pyx_gb_5kenlm_5Model_10generator(__pyx_CoroutineObject *__pyx
static PyObject *__pyx_pw_5kenlm_5Model_12BeginSentenceWrite(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static char __pyx_doc_5kenlm_5Model_11BeginSentenceWrite[] = "Change the given state to a BOS state.";
static PyObject *__pyx_pw_5kenlm_5Model_12BeginSentenceWrite(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("BeginSentenceWrite (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_5kenlm_State, 1, "state", 0))) __PYX_ERR(0, 234, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_5kenlm_State, 1, "state", 0))) __PYX_ERR(0, 245, __pyx_L1_error)
__pyx_r = __pyx_pf_5kenlm_5Model_11BeginSentenceWrite(((struct __pyx_obj_5kenlm_Model *)__pyx_v_self), ((struct __pyx_obj_5kenlm_State *)__pyx_v_state));
/* function exit code */
@@ -4732,7 +4978,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_11BeginSentenceWrite(struct __pyx_obj_5k
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("BeginSentenceWrite", 0);
- /* "kenlm.pyx":236
+ /* "kenlm.pyx":247
* def BeginSentenceWrite(self, State state):
* """Change the given state to a BOS state."""
* self.model.BeginSentenceWrite(&state._c_state) # <<<<<<<<<<<<<<
@@ -4741,7 +4987,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_11BeginSentenceWrite(struct __pyx_obj_5k
*/
__pyx_v_self->model->BeginSentenceWrite((&__pyx_v_state->_c_state));
- /* "kenlm.pyx":234
+ /* "kenlm.pyx":245
*
*
* def BeginSentenceWrite(self, State state): # <<<<<<<<<<<<<<
@@ -4756,7 +5002,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_11BeginSentenceWrite(struct __pyx_obj_5k
return __pyx_r;
}
-/* "kenlm.pyx":238
+/* "kenlm.pyx":249
* self.model.BeginSentenceWrite(&state._c_state)
*
* def NullContextWrite(self, State state): # <<<<<<<<<<<<<<
@@ -4768,10 +5014,13 @@ static PyObject *__pyx_pf_5kenlm_5Model_11BeginSentenceWrite(struct __pyx_obj_5k
static PyObject *__pyx_pw_5kenlm_5Model_14NullContextWrite(PyObject *__pyx_v_self, PyObject *__pyx_v_state); /*proto*/
static char __pyx_doc_5kenlm_5Model_13NullContextWrite[] = "Change the given state to a NULL state.";
static PyObject *__pyx_pw_5kenlm_5Model_14NullContextWrite(PyObject *__pyx_v_self, PyObject *__pyx_v_state) {
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("NullContextWrite (wrapper)", 0);
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_5kenlm_State, 1, "state", 0))) __PYX_ERR(0, 238, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_state), __pyx_ptype_5kenlm_State, 1, "state", 0))) __PYX_ERR(0, 249, __pyx_L1_error)
__pyx_r = __pyx_pf_5kenlm_5Model_13NullContextWrite(((struct __pyx_obj_5kenlm_Model *)__pyx_v_self), ((struct __pyx_obj_5kenlm_State *)__pyx_v_state));
/* function exit code */
@@ -4788,7 +5037,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_13NullContextWrite(struct __pyx_obj_5ken
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("NullContextWrite", 0);
- /* "kenlm.pyx":240
+ /* "kenlm.pyx":251
* def NullContextWrite(self, State state):
* """Change the given state to a NULL state."""
* self.model.NullContextWrite(&state._c_state) # <<<<<<<<<<<<<<
@@ -4797,7 +5046,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_13NullContextWrite(struct __pyx_obj_5ken
*/
__pyx_v_self->model->NullContextWrite((&__pyx_v_state->_c_state));
- /* "kenlm.pyx":238
+ /* "kenlm.pyx":249
* self.model.BeginSentenceWrite(&state._c_state)
*
* def NullContextWrite(self, State state): # <<<<<<<<<<<<<<
@@ -4812,7 +5061,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_13NullContextWrite(struct __pyx_obj_5ken
return __pyx_r;
}
-/* "kenlm.pyx":242
+/* "kenlm.pyx":253
* self.model.NullContextWrite(&state._c_state)
*
* def BaseScore(self, State in_state, str word, State out_state): # <<<<<<<<<<<<<<
@@ -4827,6 +5076,9 @@ static PyObject *__pyx_pw_5kenlm_5Model_16BaseScore(PyObject *__pyx_v_self, PyOb
struct __pyx_obj_5kenlm_State *__pyx_v_in_state = 0;
PyObject *__pyx_v_word = 0;
struct __pyx_obj_5kenlm_State *__pyx_v_out_state = 0;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("BaseScore (wrapper)", 0);
@@ -4855,17 +5107,17 @@ static PyObject *__pyx_pw_5kenlm_5Model_16BaseScore(PyObject *__pyx_v_self, PyOb
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("BaseScore", 1, 3, 3, 1); __PYX_ERR(0, 242, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("BaseScore", 1, 3, 3, 1); __PYX_ERR(0, 253, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_state)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("BaseScore", 1, 3, 3, 2); __PYX_ERR(0, 242, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("BaseScore", 1, 3, 3, 2); __PYX_ERR(0, 253, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "BaseScore") < 0)) __PYX_ERR(0, 242, __pyx_L3_error)
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "BaseScore") < 0)) __PYX_ERR(0, 253, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
goto __pyx_L5_argtuple_error;
@@ -4880,15 +5132,15 @@ static PyObject *__pyx_pw_5kenlm_5Model_16BaseScore(PyObject *__pyx_v_self, PyOb
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("BaseScore", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 242, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("BaseScore", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 253, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("kenlm.Model.BaseScore", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_state), __pyx_ptype_5kenlm_State, 1, "in_state", 0))) __PYX_ERR(0, 242, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_word), (&PyUnicode_Type), 1, "word", 1))) __PYX_ERR(0, 242, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_state), __pyx_ptype_5kenlm_State, 1, "out_state", 0))) __PYX_ERR(0, 242, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_state), __pyx_ptype_5kenlm_State, 1, "in_state", 0))) __PYX_ERR(0, 253, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_word), (&PyUnicode_Type), 1, "word", 1))) __PYX_ERR(0, 253, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_state), __pyx_ptype_5kenlm_State, 1, "out_state", 0))) __PYX_ERR(0, 253, __pyx_L1_error)
__pyx_r = __pyx_pf_5kenlm_5Model_15BaseScore(((struct __pyx_obj_5kenlm_Model *)__pyx_v_self), __pyx_v_in_state, __pyx_v_word, __pyx_v_out_state);
/* function exit code */
@@ -4906,26 +5158,29 @@ static PyObject *__pyx_pf_5kenlm_5Model_15BaseScore(struct __pyx_obj_5kenlm_Mode
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
char *__pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("BaseScore", 0);
- /* "kenlm.pyx":251
+ /* "kenlm.pyx":262
* :returns: p(word|state)
* """
* cdef float total = self.model.BaseScore(&in_state._c_state, self.vocab.Index(as_str(word)), &out_state._c_state) # <<<<<<<<<<<<<<
* return total
*
*/
- __pyx_t_1 = __pyx_f_5kenlm_as_str(__pyx_v_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
+ __pyx_t_1 = __pyx_f_5kenlm_as_str(__pyx_v_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(__pyx_t_1 == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(0, 251, __pyx_L1_error)
+ __PYX_ERR(0, 262, __pyx_L1_error)
}
- __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 251, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 262, __pyx_L1_error)
__pyx_v_total = __pyx_v_self->model->BaseScore((&__pyx_v_in_state->_c_state), __pyx_v_self->vocab->Index(__pyx_t_2), (&__pyx_v_out_state->_c_state));
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /* "kenlm.pyx":252
+ /* "kenlm.pyx":263
* """
* cdef float total = self.model.BaseScore(&in_state._c_state, self.vocab.Index(as_str(word)), &out_state._c_state)
* return total # <<<<<<<<<<<<<<
@@ -4933,13 +5188,13 @@ static PyObject *__pyx_pf_5kenlm_5Model_15BaseScore(struct __pyx_obj_5kenlm_Mode
* def BaseFullScore(self, State in_state, str word, State out_state):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_total); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_total); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 263, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":242
+ /* "kenlm.pyx":253
* self.model.NullContextWrite(&state._c_state)
*
* def BaseScore(self, State in_state, str word, State out_state): # <<<<<<<<<<<<<<
@@ -4958,7 +5213,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_15BaseScore(struct __pyx_obj_5kenlm_Mode
return __pyx_r;
}
-/* "kenlm.pyx":254
+/* "kenlm.pyx":265
* return total
*
* def BaseFullScore(self, State in_state, str word, State out_state): # <<<<<<<<<<<<<<
@@ -4973,6 +5228,9 @@ static PyObject *__pyx_pw_5kenlm_5Model_18BaseFullScore(PyObject *__pyx_v_self,
struct __pyx_obj_5kenlm_State *__pyx_v_in_state = 0;
PyObject *__pyx_v_word = 0;
struct __pyx_obj_5kenlm_State *__pyx_v_out_state = 0;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("BaseFullScore (wrapper)", 0);
@@ -5001,17 +5259,17 @@ static PyObject *__pyx_pw_5kenlm_5Model_18BaseFullScore(PyObject *__pyx_v_self,
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_word)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("BaseFullScore", 1, 3, 3, 1); __PYX_ERR(0, 254, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("BaseFullScore", 1, 3, 3, 1); __PYX_ERR(0, 265, __pyx_L3_error)
}
CYTHON_FALLTHROUGH;
case 2:
if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_out_state)) != 0)) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("BaseFullScore", 1, 3, 3, 2); __PYX_ERR(0, 254, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("BaseFullScore", 1, 3, 3, 2); __PYX_ERR(0, 265, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "BaseFullScore") < 0)) __PYX_ERR(0, 254, __pyx_L3_error)
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "BaseFullScore") < 0)) __PYX_ERR(0, 265, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
goto __pyx_L5_argtuple_error;
@@ -5026,15 +5284,15 @@ static PyObject *__pyx_pw_5kenlm_5Model_18BaseFullScore(PyObject *__pyx_v_self,
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("BaseFullScore", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 254, __pyx_L3_error)
+ __Pyx_RaiseArgtupleInvalid("BaseFullScore", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 265, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("kenlm.Model.BaseFullScore", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_state), __pyx_ptype_5kenlm_State, 1, "in_state", 0))) __PYX_ERR(0, 254, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_word), (&PyUnicode_Type), 1, "word", 1))) __PYX_ERR(0, 254, __pyx_L1_error)
- if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_state), __pyx_ptype_5kenlm_State, 1, "out_state", 0))) __PYX_ERR(0, 254, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_in_state), __pyx_ptype_5kenlm_State, 1, "in_state", 0))) __PYX_ERR(0, 265, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_word), (&PyUnicode_Type), 1, "word", 1))) __PYX_ERR(0, 265, __pyx_L1_error)
+ if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_out_state), __pyx_ptype_5kenlm_State, 1, "out_state", 0))) __PYX_ERR(0, 265, __pyx_L1_error)
__pyx_r = __pyx_pf_5kenlm_5Model_17BaseFullScore(((struct __pyx_obj_5kenlm_Model *)__pyx_v_self), __pyx_v_in_state, __pyx_v_word, __pyx_v_out_state);
/* function exit code */
@@ -5056,26 +5314,29 @@ static PyObject *__pyx_pf_5kenlm_5Model_17BaseFullScore(struct __pyx_obj_5kenlm_
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("BaseFullScore", 0);
- /* "kenlm.pyx":262
+ /* "kenlm.pyx":273
* :returns: FullScoreReturn(word|state)
* """
* cdef _kenlm.WordIndex wid = self.vocab.Index(as_str(word)) # <<<<<<<<<<<<<<
* cdef _kenlm.FullScoreReturn ret = self.model.BaseFullScore(&in_state._c_state, wid, &out_state._c_state)
* return FullScoreReturn(ret.prob, ret.ngram_length, wid == 0)
*/
- __pyx_t_1 = __pyx_f_5kenlm_as_str(__pyx_v_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
+ __pyx_t_1 = __pyx_f_5kenlm_as_str(__pyx_v_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
if (unlikely(__pyx_t_1 == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(0, 262, __pyx_L1_error)
+ __PYX_ERR(0, 273, __pyx_L1_error)
}
- __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 262, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_t_1); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 273, __pyx_L1_error)
__pyx_v_wid = __pyx_v_self->vocab->Index(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /* "kenlm.pyx":263
+ /* "kenlm.pyx":274
* """
* cdef _kenlm.WordIndex wid = self.vocab.Index(as_str(word))
* cdef _kenlm.FullScoreReturn ret = self.model.BaseFullScore(&in_state._c_state, wid, &out_state._c_state) # <<<<<<<<<<<<<<
@@ -5084,7 +5345,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_17BaseFullScore(struct __pyx_obj_5kenlm_
*/
__pyx_v_ret = __pyx_v_self->model->BaseFullScore((&__pyx_v_in_state->_c_state), __pyx_v_wid, (&__pyx_v_out_state->_c_state));
- /* "kenlm.pyx":264
+ /* "kenlm.pyx":275
* cdef _kenlm.WordIndex wid = self.vocab.Index(as_str(word))
* cdef _kenlm.FullScoreReturn ret = self.model.BaseFullScore(&in_state._c_state, wid, &out_state._c_state)
* return FullScoreReturn(ret.prob, ret.ngram_length, wid == 0) # <<<<<<<<<<<<<<
@@ -5092,13 +5353,13 @@ static PyObject *__pyx_pf_5kenlm_5Model_17BaseFullScore(struct __pyx_obj_5kenlm_
* def __contains__(self, word):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ret.prob); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error)
+ __pyx_t_1 = PyFloat_FromDouble(__pyx_v_ret.prob); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = __Pyx_PyInt_From_unsigned_char(__pyx_v_ret.ngram_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 264, __pyx_L1_error)
+ __pyx_t_3 = __Pyx_PyInt_From_unsigned_char(__pyx_v_ret.ngram_length); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_wid == 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 264, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_PyBool_FromLong((__pyx_v_wid == 0)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 264, __pyx_L1_error)
+ __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_GIVEREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
@@ -5109,14 +5370,14 @@ static PyObject *__pyx_pf_5kenlm_5Model_17BaseFullScore(struct __pyx_obj_5kenlm_
__pyx_t_1 = 0;
__pyx_t_3 = 0;
__pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5kenlm_FullScoreReturn), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 264, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5kenlm_FullScoreReturn), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_r = __pyx_t_4;
__pyx_t_4 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":254
+ /* "kenlm.pyx":265
* return total
*
* def BaseFullScore(self, State in_state, str word, State out_state): # <<<<<<<<<<<<<<
@@ -5138,7 +5399,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_17BaseFullScore(struct __pyx_obj_5kenlm_
return __pyx_r;
}
-/* "kenlm.pyx":266
+/* "kenlm.pyx":277
* return FullScoreReturn(ret.prob, ret.ngram_length, wid == 0)
*
* def __contains__(self, word): # <<<<<<<<<<<<<<
@@ -5165,21 +5426,24 @@ static int __pyx_pf_5kenlm_5Model_19__contains__(struct __pyx_obj_5kenlm_Model *
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
char *__pyx_t_2;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__contains__", 0);
- /* "kenlm.pyx":267
+ /* "kenlm.pyx":278
*
* def __contains__(self, word):
* cdef bytes w = as_str(word) # <<<<<<<<<<<<<<
* return (self.vocab.Index(w) != 0)
*
*/
- __pyx_t_1 = __pyx_f_5kenlm_as_str(__pyx_v_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
+ __pyx_t_1 = __pyx_f_5kenlm_as_str(__pyx_v_word); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_v_w = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
- /* "kenlm.pyx":268
+ /* "kenlm.pyx":279
* def __contains__(self, word):
* cdef bytes w = as_str(word)
* return (self.vocab.Index(w) != 0) # <<<<<<<<<<<<<<
@@ -5188,13 +5452,13 @@ static int __pyx_pf_5kenlm_5Model_19__contains__(struct __pyx_obj_5kenlm_Model *
*/
if (unlikely(__pyx_v_w == Py_None)) {
PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
- __PYX_ERR(0, 268, __pyx_L1_error)
+ __PYX_ERR(0, 279, __pyx_L1_error)
}
- __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_w); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 268, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyBytes_AsWritableString(__pyx_v_w); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 279, __pyx_L1_error)
__pyx_r = (__pyx_v_self->vocab->Index(__pyx_t_2) != 0);
goto __pyx_L0;
- /* "kenlm.pyx":266
+ /* "kenlm.pyx":277
* return FullScoreReturn(ret.prob, ret.ngram_length, wid == 0)
*
* def __contains__(self, word): # <<<<<<<<<<<<<<
@@ -5213,7 +5477,7 @@ static int __pyx_pf_5kenlm_5Model_19__contains__(struct __pyx_obj_5kenlm_Model *
return __pyx_r;
}
-/* "kenlm.pyx":270
+/* "kenlm.pyx":281
* return (self.vocab.Index(w) != 0)
*
* def __repr__(self): # <<<<<<<<<<<<<<
@@ -5242,9 +5506,12 @@ static PyObject *__pyx_pf_5kenlm_5Model_21__repr__(struct __pyx_obj_5kenlm_Model
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
PyObject *__pyx_t_5 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__repr__", 0);
- /* "kenlm.pyx":271
+ /* "kenlm.pyx":282
*
* def __repr__(self):
* return '<Model from {0}>'.format(os.path.basename(self.path)) # <<<<<<<<<<<<<<
@@ -5252,14 +5519,14 @@ static PyObject *__pyx_pf_5kenlm_5Model_21__repr__(struct __pyx_obj_5kenlm_Model
* def __reduce__(self):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Model_from_0, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_kp_u_Model_from_0, __pyx_n_s_format); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
- __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
+ __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 271, __pyx_L1_error)
+ __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_basename); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_basename); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_5 = NULL;
@@ -5274,7 +5541,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_21__repr__(struct __pyx_obj_5kenlm_Model
}
__pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_v_self->path) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_self->path);
__Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
- if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
+ if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__pyx_t_4 = NULL;
@@ -5290,14 +5557,14 @@ static PyObject *__pyx_pf_5kenlm_5Model_21__repr__(struct __pyx_obj_5kenlm_Model
__pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
__Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
+ if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 282, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":270
+ /* "kenlm.pyx":281
* return (self.vocab.Index(w) != 0)
*
* def __repr__(self): # <<<<<<<<<<<<<<
@@ -5320,7 +5587,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_21__repr__(struct __pyx_obj_5kenlm_Model
return __pyx_r;
}
-/* "kenlm.pyx":273
+/* "kenlm.pyx":284
* return '<Model from {0}>'.format(os.path.basename(self.path))
*
* def __reduce__(self): # <<<<<<<<<<<<<<
@@ -5346,9 +5613,12 @@ static PyObject *__pyx_pf_5kenlm_5Model_23__reduce__(struct __pyx_obj_5kenlm_Mod
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__reduce__", 0);
- /* "kenlm.pyx":274
+ /* "kenlm.pyx":285
*
* def __reduce__(self):
* return (Model, (self.path,)) # <<<<<<<<<<<<<<
@@ -5356,12 +5626,12 @@ static PyObject *__pyx_pf_5kenlm_5Model_23__reduce__(struct __pyx_obj_5kenlm_Mod
* class LanguageModel(Model):
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(__pyx_v_self->path);
__Pyx_GIVEREF(__pyx_v_self->path);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->path);
- __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 274, __pyx_L1_error)
+ __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(((PyObject *)__pyx_ptype_5kenlm_Model));
__Pyx_GIVEREF(((PyObject *)__pyx_ptype_5kenlm_Model));
@@ -5373,7 +5643,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_23__reduce__(struct __pyx_obj_5kenlm_Mod
__pyx_t_2 = 0;
goto __pyx_L0;
- /* "kenlm.pyx":273
+ /* "kenlm.pyx":284
* return '<Model from {0}>'.format(os.path.basename(self.path))
*
* def __reduce__(self): # <<<<<<<<<<<<<<
@@ -5393,7 +5663,7 @@ static PyObject *__pyx_pf_5kenlm_5Model_23__reduce__(struct __pyx_obj_5kenlm_Mod
return __pyx_r;
}
-/* "kenlm.pyx":116
+/* "kenlm.pyx":127
*
* cdef _kenlm.Model* model
* cdef public bytes path # <<<<<<<<<<<<<<
@@ -5447,8 +5717,11 @@ static int __pyx_pf_5kenlm_5Model_4path_2__set__(struct __pyx_obj_5kenlm_Model *
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__set__", 0);
- if (!(likely(PyBytes_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 116, __pyx_L1_error)
+ if (!(likely(PyBytes_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 127, __pyx_L1_error)
__pyx_t_1 = __pyx_v_value;
__Pyx_INCREF(__pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
@@ -5771,6 +6044,20 @@ static int __pyx_setprop_5kenlm_6Config_show_progress(PyObject *o, PyObject *v,
}
}
+static PyObject *__pyx_getprop_5kenlm_6Config_arpa_complain(PyObject *o, CYTHON_UNUSED void *x) {
+ return __pyx_pw_5kenlm_6Config_13arpa_complain_1__get__(o);
+}
+
+static int __pyx_setprop_5kenlm_6Config_arpa_complain(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+ if (v) {
+ return __pyx_pw_5kenlm_6Config_13arpa_complain_3__set__(o, v);
+ }
+ else {
+ PyErr_SetString(PyExc_NotImplementedError, "__del__");
+ return -1;
+ }
+}
+
static PyMethodDef __pyx_methods_5kenlm_Config[] = {
{"__reduce_cython__", (PyCFunction)__pyx_pw_5kenlm_6Config_3__reduce_cython__, METH_NOARGS, 0},
{"__setstate_cython__", (PyCFunction)__pyx_pw_5kenlm_6Config_5__setstate_cython__, METH_O, 0},
@@ -5780,6 +6067,7 @@ static PyMethodDef __pyx_methods_5kenlm_Config[] = {
static struct PyGetSetDef __pyx_getsets_5kenlm_Config[] = {
{(char *)"load_method", __pyx_getprop_5kenlm_6Config_load_method, __pyx_setprop_5kenlm_6Config_load_method, (char *)0, 0},
{(char *)"show_progress", __pyx_getprop_5kenlm_6Config_show_progress, __pyx_setprop_5kenlm_6Config_show_progress, (char *)0, 0},
+ {(char *)"arpa_complain", __pyx_getprop_5kenlm_6Config_arpa_complain, __pyx_setprop_5kenlm_6Config_arpa_complain, (char *)0, 0},
{0, 0, 0, 0, 0}
};
@@ -5876,9 +6164,9 @@ static void __pyx_tp_dealloc_5kenlm_Model(PyObject *o) {
{
PyObject *etype, *eval, *etb;
PyErr_Fetch(&etype, &eval, &etb);
- ++Py_REFCNT(o);
+ __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
__pyx_pw_5kenlm_5Model_3__dealloc__(o);
- --Py_REFCNT(o);
+ __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
PyErr_Restore(etype, eval, etb);
}
Py_CLEAR(p->path);
@@ -6185,10 +6473,13 @@ static struct PyModuleDef __pyx_moduledef = {
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_u_0_1_2_3, __pyx_k_0_1_2_3, sizeof(__pyx_k_0_1_2_3), 0, 1, 0, 0},
+ {&__pyx_n_s_ALL, __pyx_k_ALL, sizeof(__pyx_k_ALL), 0, 0, 1, 1},
+ {&__pyx_n_s_ARPALoadComplain, __pyx_k_ARPALoadComplain, sizeof(__pyx_k_ARPALoadComplain), 0, 0, 1, 1},
{&__pyx_kp_s_Backwards_compatability_stub_Use, __pyx_k_Backwards_compatability_stub_Use, sizeof(__pyx_k_Backwards_compatability_stub_Use), 0, 0, 1, 0},
{&__pyx_kp_u_Cannot_convert_s_to_string, __pyx_k_Cannot_convert_s_to_string, sizeof(__pyx_k_Cannot_convert_s_to_string), 0, 1, 0, 0},
{&__pyx_kp_u_Cannot_read_model, __pyx_k_Cannot_read_model, sizeof(__pyx_k_Cannot_read_model), 0, 1, 0, 0},
{&__pyx_n_s_Config, __pyx_k_Config, sizeof(__pyx_k_Config), 0, 0, 1, 1},
+ {&__pyx_n_s_EXPENSIVE, __pyx_k_EXPENSIVE, sizeof(__pyx_k_EXPENSIVE), 0, 0, 1, 1},
{&__pyx_n_s_FullScoreReturn, __pyx_k_FullScoreReturn, sizeof(__pyx_k_FullScoreReturn), 0, 0, 1, 1},
{&__pyx_n_s_IOError, __pyx_k_IOError, sizeof(__pyx_k_IOError), 0, 0, 1, 1},
{&__pyx_n_s_LAZY, __pyx_k_LAZY, sizeof(__pyx_k_LAZY), 0, 0, 1, 1},
@@ -6197,6 +6488,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_Model, __pyx_k_Model, sizeof(__pyx_k_Model), 0, 0, 1, 1},
{&__pyx_kp_u_Model_from_0, __pyx_k_Model_from_0, sizeof(__pyx_k_Model_from_0), 0, 1, 0, 0},
{&__pyx_n_s_Model_full_scores, __pyx_k_Model_full_scores, sizeof(__pyx_k_Model_full_scores), 0, 0, 1, 1},
+ {&__pyx_n_s_NONE, __pyx_k_NONE, sizeof(__pyx_k_NONE), 0, 0, 1, 1},
{&__pyx_n_s_PARALLEL_READ, __pyx_k_PARALLEL_READ, sizeof(__pyx_k_PARALLEL_READ), 0, 0, 1, 1},
{&__pyx_n_s_POPULATE_OR_LAZY, __pyx_k_POPULATE_OR_LAZY, sizeof(__pyx_k_POPULATE_OR_LAZY), 0, 0, 1, 1},
{&__pyx_n_s_POPULATE_OR_READ, __pyx_k_POPULATE_OR_READ, sizeof(__pyx_k_POPULATE_OR_READ), 0, 0, 1, 1},
@@ -6256,8 +6548,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
};
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 9, __pyx_L1_error)
- __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 129, __pyx_L1_error)
- __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) __PYX_ERR(0, 131, __pyx_L1_error)
+ __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 140, __pyx_L1_error)
+ __pyx_builtin_IOError = __Pyx_GetBuiltinName(__pyx_n_s_IOError); if (!__pyx_builtin_IOError) __PYX_ERR(0, 142, __pyx_L1_error)
return 0;
__pyx_L1_error:;
return -1;
@@ -6372,6 +6664,9 @@ static int __Pyx_modinit_function_export_code(void) {
static int __Pyx_modinit_type_init_code(void) {
__Pyx_RefNannyDeclarations
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
/*--- Type init code ---*/
if (PyType_Ready(&__pyx_type_5kenlm_FullScoreReturn) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
@@ -6394,17 +6689,17 @@ static int __Pyx_modinit_type_init_code(void) {
if (PyObject_SetAttr(__pyx_m, __pyx_n_s_State, (PyObject *)&__pyx_type_5kenlm_State) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5kenlm_State) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
__pyx_ptype_5kenlm_State = &__pyx_type_5kenlm_State;
- if (PyType_Ready(&__pyx_type_5kenlm_Config) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
+ if (PyType_Ready(&__pyx_type_5kenlm_Config) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type_5kenlm_Config.tp_print = 0;
#endif
if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_5kenlm_Config.tp_dictoffset && __pyx_type_5kenlm_Config.tp_getattro == PyObject_GenericGetAttr)) {
__pyx_type_5kenlm_Config.tp_getattro = __Pyx_PyObject_GenericGetAttr;
}
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Config, (PyObject *)&__pyx_type_5kenlm_Config) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
- if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5kenlm_Config) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Config, (PyObject *)&__pyx_type_5kenlm_Config) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
+ if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5kenlm_Config) < 0) __PYX_ERR(0, 93, __pyx_L1_error)
__pyx_ptype_5kenlm_Config = &__pyx_type_5kenlm_Config;
- if (PyType_Ready(&__pyx_type_5kenlm_Model) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
+ if (PyType_Ready(&__pyx_type_5kenlm_Model) < 0) __PYX_ERR(0, 121, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type_5kenlm_Model.tp_print = 0;
#endif
@@ -6413,7 +6708,7 @@ static int __Pyx_modinit_type_init_code(void) {
}
#if CYTHON_COMPILING_IN_CPYTHON
{
- PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5kenlm_Model, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 110, __pyx_L1_error)
+ PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_5kenlm_Model, "__init__"); if (unlikely(!wrapper)) __PYX_ERR(0, 121, __pyx_L1_error)
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
__pyx_wrapperbase_5kenlm_5Model___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
__pyx_wrapperbase_5kenlm_5Model___init__.doc = __pyx_doc_5kenlm_5Model___init__;
@@ -6421,9 +6716,9 @@ static int __Pyx_modinit_type_init_code(void) {
}
}
#endif
- if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Model, (PyObject *)&__pyx_type_5kenlm_Model) < 0) __PYX_ERR(0, 110, __pyx_L1_error)
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s_Model, (PyObject *)&__pyx_type_5kenlm_Model) < 0) __PYX_ERR(0, 121, __pyx_L1_error)
__pyx_ptype_5kenlm_Model = &__pyx_type_5kenlm_Model;
- if (PyType_Ready(&__pyx_type_5kenlm___pyx_scope_struct__full_scores) < 0) __PYX_ERR(0, 206, __pyx_L1_error)
+ if (PyType_Ready(&__pyx_type_5kenlm___pyx_scope_struct__full_scores) < 0) __PYX_ERR(0, 217, __pyx_L1_error)
#if PY_VERSION_HEX < 0x030800B1
__pyx_type_5kenlm___pyx_scope_struct__full_scores.tp_print = 0;
#endif
@@ -6463,17 +6758,19 @@ static int __Pyx_modinit_function_import_code(void) {
}
-#if PY_MAJOR_VERSION < 3
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC void
-#else
+#ifndef CYTHON_NO_PYINIT_EXPORT
#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
+#elif PY_MAJOR_VERSION < 3
+#ifdef __cplusplus
+#define __Pyx_PyMODINIT_FUNC extern "C" void
+#else
+#define __Pyx_PyMODINIT_FUNC void
#endif
#else
-#ifdef CYTHON_NO_PYINIT_EXPORT
-#define __Pyx_PyMODINIT_FUNC PyObject *
+#ifdef __cplusplus
+#define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
#else
-#define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
+#define __Pyx_PyMODINIT_FUNC PyObject *
#endif
#endif
@@ -6558,6 +6855,9 @@ static CYTHON_SMALL_CODE int __pyx_pymod_exec_kenlm(PyObject *__pyx_pyinit_modul
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
PyObject *__pyx_t_4 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
__Pyx_RefNannyDeclarations
#if CYTHON_PEP489_MULTI_PHASE_INIT
if (__pyx_m) {
@@ -6646,14 +6946,14 @@ if (!__Pyx_RefNanny) {
}
#endif
/*--- Builtin init code ---*/
- if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error;
+ if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Constants init code ---*/
- if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error;
+ if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
/*--- Global type/function init code ---*/
(void)__Pyx_modinit_global_init_code();
(void)__Pyx_modinit_variable_export_code();
(void)__Pyx_modinit_function_export_code();
- if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
+ if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
(void)__Pyx_modinit_type_import_code();
(void)__Pyx_modinit_variable_import_code();
(void)__Pyx_modinit_function_import_code();
@@ -6735,7 +7035,7 @@ if (!__Pyx_RefNanny) {
* READ = _kenlm.READ
* PARALLEL_READ = _kenlm.PARALLEL_READ # <<<<<<<<<<<<<<
*
- * cdef class Config:
+ * class ARPALoadComplain:
*/
__pyx_t_2 = __Pyx_PyInt_From_enum__util_3a__3a_LoadMethod(util::PARALLEL_READ); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
@@ -6755,37 +7055,96 @@ if (!__Pyx_RefNanny) {
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- /* "kenlm.pyx":119
+ /* "kenlm.pyx":88
+ * PARALLEL_READ = _kenlm.PARALLEL_READ
+ *
+ * class ARPALoadComplain: # <<<<<<<<<<<<<<
+ * ALL = _kenlm.ALL
+ * EXPENSIVE = _kenlm.EXPENSIVE
+ */
+ __pyx_t_1 = __Pyx_Py3MetaclassPrepare((PyObject *) NULL, __pyx_empty_tuple, __pyx_n_s_ARPALoadComplain, __pyx_n_s_ARPALoadComplain, (PyObject *) NULL, __pyx_n_s_kenlm, (PyObject *) NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 88, __pyx_L1_error)
+ __Pyx_GOTREF(__pyx_t_1);
+
+ /* "kenlm.pyx":89
+ *
+ * class ARPALoadComplain:
+ * ALL = _kenlm.ALL # <<<<<<<<<<<<<<
+ * EXPENSIVE = _kenlm.EXPENSIVE
+ * NONE = _kenlm.NONE
+ */
+ __pyx_t_2 = __Pyx_PyInt_From_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(lm::ngram::Config::ALL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 89, __pyx_L1_error)
+ __Pyx_GOTREF(__pyx_t_2);
+ if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_ALL, __pyx_t_2) < 0) __PYX_ERR(0, 89, __pyx_L1_error)
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "kenlm.pyx":90
+ * class ARPALoadComplain:
+ * ALL = _kenlm.ALL
+ * EXPENSIVE = _kenlm.EXPENSIVE # <<<<<<<<<<<<<<
+ * NONE = _kenlm.NONE
+ *
+ */
+ __pyx_t_2 = __Pyx_PyInt_From_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(lm::ngram::Config::EXPENSIVE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error)
+ __Pyx_GOTREF(__pyx_t_2);
+ if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_EXPENSIVE, __pyx_t_2) < 0) __PYX_ERR(0, 90, __pyx_L1_error)
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "kenlm.pyx":91
+ * ALL = _kenlm.ALL
+ * EXPENSIVE = _kenlm.EXPENSIVE
+ * NONE = _kenlm.NONE # <<<<<<<<<<<<<<
+ *
+ * cdef class Config:
+ */
+ __pyx_t_2 = __Pyx_PyInt_From_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(lm::ngram::Config::NONE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 91, __pyx_L1_error)
+ __Pyx_GOTREF(__pyx_t_2);
+ if (__Pyx_SetNameInClass(__pyx_t_1, __pyx_n_s_NONE, __pyx_t_2) < 0) __PYX_ERR(0, 91, __pyx_L1_error)
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "kenlm.pyx":88
+ * PARALLEL_READ = _kenlm.PARALLEL_READ
+ *
+ * class ARPALoadComplain: # <<<<<<<<<<<<<<
+ * ALL = _kenlm.ALL
+ * EXPENSIVE = _kenlm.EXPENSIVE
+ */
+ __pyx_t_2 = __Pyx_Py3ClassCreate(((PyObject*)&__Pyx_DefaultClassType), __pyx_n_s_ARPALoadComplain, __pyx_empty_tuple, __pyx_t_1, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error)
+ __Pyx_GOTREF(__pyx_t_2);
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s_ARPALoadComplain, __pyx_t_2) < 0) __PYX_ERR(0, 88, __pyx_L1_error)
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "kenlm.pyx":130
* cdef _kenlm.const_Vocabulary* vocab
*
* def __init__(self, path, Config config = Config()): # <<<<<<<<<<<<<<
* """
* Load the language model.
*/
- __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_5kenlm_Config)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
+ __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)__pyx_ptype_5kenlm_Config)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 130, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__pyx_k__7 = ((struct __pyx_obj_5kenlm_Config *)__pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- /* "kenlm.pyx":276
+ /* "kenlm.pyx":287
* return (Model, (self.path,))
*
* class LanguageModel(Model): # <<<<<<<<<<<<<<
* """Backwards compatability stub. Use Model."""
*/
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 276, __pyx_L1_error)
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)__pyx_ptype_5kenlm_Model));
__Pyx_GIVEREF(((PyObject *)__pyx_ptype_5kenlm_Model));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_ptype_5kenlm_Model));
- __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 276, __pyx_L1_error)
+ __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_LanguageModel, __pyx_n_s_LanguageModel, (PyObject *) NULL, __pyx_n_s_kenlm, __pyx_kp_s_Backwards_compatability_stub_Use); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 276, __pyx_L1_error)
+ __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_LanguageModel, __pyx_n_s_LanguageModel, (PyObject *) NULL, __pyx_n_s_kenlm, __pyx_kp_s_Backwards_compatability_stub_Use); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_LanguageModel, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 276, __pyx_L1_error)
+ __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_LanguageModel, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error)
__Pyx_GOTREF(__pyx_t_4);
- if (PyDict_SetItem(__pyx_d, __pyx_n_s_LanguageModel, __pyx_t_4) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
+ if (PyDict_SetItem(__pyx_d, __pyx_n_s_LanguageModel, __pyx_t_4) < 0) __PYX_ERR(0, 287, __pyx_L1_error)
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -7370,7 +7729,7 @@ static int __Pyx_ParseOptionalKeywords(
}
name = first_kw_arg;
#if PY_MAJOR_VERSION < 3
- if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
+ if (likely(PyString_Check(key))) {
while (*name) {
if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
&& _PyString_Eq(**name, key)) {
@@ -7397,7 +7756,7 @@ static int __Pyx_ParseOptionalKeywords(
while (*name) {
int cmp = (**name == key) ? 0 :
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
+ (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
#endif
PyUnicode_Compare(**name, key);
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
@@ -7413,7 +7772,7 @@ static int __Pyx_ParseOptionalKeywords(
while (argname != first_kw_arg) {
int cmp = (**argname == key) ? 0 :
#if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
- (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
+ (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
#endif
PyUnicode_Compare(**argname, key);
if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
@@ -7834,6 +8193,28 @@ static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_nam
}
#endif
+/* PyObjectGetAttrStrNoError */
+static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
+ __Pyx_PyThreadState_declare
+ __Pyx_PyThreadState_assign
+ if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
+ __Pyx_PyErr_Clear();
+}
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
+ PyObject *result;
+#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
+ PyTypeObject* tp = Py_TYPE(obj);
+ if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
+ return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
+ }
+#endif
+ result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
+ if (unlikely(!result)) {
+ __Pyx_PyObject_GetAttrStr_ClearAttributeError();
+ }
+ return result;
+}
+
/* SetupReduce */
static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
int ret;
@@ -7879,15 +8260,23 @@ static int __Pyx_setup_reduce(PyObject* type_obj) {
#endif
reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
- reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto __PYX_BAD;
- ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
- ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
+ reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
+ if (likely(reduce_cython)) {
+ ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
+ ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
+ } else if (reduce == object_reduce || PyErr_Occurred()) {
+ goto __PYX_BAD;
+ }
setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
if (!setstate) PyErr_Clear();
if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
- setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto __PYX_BAD;
- ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
- ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
+ setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
+ if (likely(setstate_cython)) {
+ ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
+ ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
+ } else if (!setstate || PyErr_Occurred()) {
+ goto __PYX_BAD;
+ }
}
PyType_Modified((PyTypeObject*)type_obj);
}
@@ -7940,7 +8329,7 @@ static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
{
#if PY_MAJOR_VERSION >= 3
if (level == -1) {
- if (strchr(__Pyx_MODULE_NAME, '.')) {
+ if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
module = PyImport_ImportModuleLevelObject(
name, global_dict, empty_dict, list, 1);
if (!module) {
@@ -8083,7 +8472,7 @@ static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObj
/* CLineInTraceback */
#ifndef CYTHON_CLINE_IN_TRACEBACK
-static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
+static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
PyObject *use_cline;
PyObject *ptype, *pvalue, *ptraceback;
#if CYTHON_COMPILING_IN_CPYTHON
@@ -8187,7 +8576,7 @@ static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
int new_max = __pyx_code_cache.max_count + 64;
entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
- __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
+ __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
if (unlikely(!entries)) {
return;
}
@@ -8342,6 +8731,37 @@ static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__util_3a__3a_LoadMethod(enu
}
/* CIntToPy */
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(enum lm::ngram::Config::ARPALoadComplain value) {
+ const enum lm::ngram::Config::ARPALoadComplain neg_one = (enum lm::ngram::Config::ARPALoadComplain) ((enum lm::ngram::Config::ARPALoadComplain) 0 - (enum lm::ngram::Config::ARPALoadComplain) 1), const_zero = (enum lm::ngram::Config::ARPALoadComplain) 0;
+ const int is_unsigned = neg_one > const_zero;
+ if (is_unsigned) {
+ if (sizeof(enum lm::ngram::Config::ARPALoadComplain) < sizeof(long)) {
+ return PyInt_FromLong((long) value);
+ } else if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(unsigned long)) {
+ return PyLong_FromUnsignedLong((unsigned long) value);
+#ifdef HAVE_LONG_LONG
+ } else if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(unsigned PY_LONG_LONG)) {
+ return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+#endif
+ }
+ } else {
+ if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(long)) {
+ return PyInt_FromLong((long) value);
+#ifdef HAVE_LONG_LONG
+ } else if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(PY_LONG_LONG)) {
+ return PyLong_FromLongLong((PY_LONG_LONG) value);
+#endif
+ }
+ }
+ {
+ int one = 1; int little = (int)*(unsigned char *)&one;
+ unsigned char *bytes = (unsigned char *)&value;
+ return _PyLong_FromByteArray(bytes, sizeof(enum lm::ngram::Config::ARPALoadComplain),
+ little, !is_unsigned);
+ }
+}
+
+/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
const int is_unsigned = neg_one > const_zero;
@@ -8812,6 +9232,195 @@ raise_neg_overflow:
return (enum util::LoadMethod) -1;
}
+/* CIntFromPy */
+static CYTHON_INLINE enum lm::ngram::Config::ARPALoadComplain __Pyx_PyInt_As_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(PyObject *x) {
+ const enum lm::ngram::Config::ARPALoadComplain neg_one = (enum lm::ngram::Config::ARPALoadComplain) ((enum lm::ngram::Config::ARPALoadComplain) 0 - (enum lm::ngram::Config::ARPALoadComplain) 1), const_zero = (enum lm::ngram::Config::ARPALoadComplain) 0;
+ const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+ if (likely(PyInt_Check(x))) {
+ if (sizeof(enum lm::ngram::Config::ARPALoadComplain) < sizeof(long)) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, long, PyInt_AS_LONG(x))
+ } else {
+ long val = PyInt_AS_LONG(x);
+ if (is_unsigned && unlikely(val < 0)) {
+ goto raise_neg_overflow;
+ }
+ return (enum lm::ngram::Config::ARPALoadComplain) val;
+ }
+ } else
+#endif
+ if (likely(PyLong_Check(x))) {
+ if (is_unsigned) {
+#if CYTHON_USE_PYLONG_INTERNALS
+ const digit* digits = ((PyLongObject*)x)->ob_digit;
+ switch (Py_SIZE(x)) {
+ case 0: return (enum lm::ngram::Config::ARPALoadComplain) 0;
+ case 1: __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, digit, digits[0])
+ case 2:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) > 1 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) >= 2 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) (((((enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0]));
+ }
+ }
+ break;
+ case 3:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) > 2 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) >= 3 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) (((((((enum lm::ngram::Config::ARPALoadComplain)digits[2]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0]));
+ }
+ }
+ break;
+ case 4:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) > 3 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) >= 4 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) (((((((((enum lm::ngram::Config::ARPALoadComplain)digits[3]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[2]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0]));
+ }
+ }
+ break;
+ }
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+ if (unlikely(Py_SIZE(x) < 0)) {
+ goto raise_neg_overflow;
+ }
+#else
+ {
+ int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+ if (unlikely(result < 0))
+ return (enum lm::ngram::Config::ARPALoadComplain) -1;
+ if (unlikely(result == 1))
+ goto raise_neg_overflow;
+ }
+#endif
+ if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(unsigned long)) {
+ __PYX_VERIFY_RETURN_INT_EXC(enum lm::ngram::Config::ARPALoadComplain, unsigned long, PyLong_AsUnsignedLong(x))
+#ifdef HAVE_LONG_LONG
+ } else if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(unsigned PY_LONG_LONG)) {
+ __PYX_VERIFY_RETURN_INT_EXC(enum lm::ngram::Config::ARPALoadComplain, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+#endif
+ }
+ } else {
+#if CYTHON_USE_PYLONG_INTERNALS
+ const digit* digits = ((PyLongObject*)x)->ob_digit;
+ switch (Py_SIZE(x)) {
+ case 0: return (enum lm::ngram::Config::ARPALoadComplain) 0;
+ case -1: __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, sdigit, (sdigit) (-(sdigit)digits[0]))
+ case 1: __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, digit, +digits[0])
+ case -2:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 1 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 2 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) (((enum lm::ngram::Config::ARPALoadComplain)-1)*(((((enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0])));
+ }
+ }
+ break;
+ case 2:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) > 1 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 2 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) ((((((enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0])));
+ }
+ }
+ break;
+ case -3:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 2 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 3 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) (((enum lm::ngram::Config::ARPALoadComplain)-1)*(((((((enum lm::ngram::Config::ARPALoadComplain)digits[2]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0])));
+ }
+ }
+ break;
+ case 3:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) > 2 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 3 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) ((((((((enum lm::ngram::Config::ARPALoadComplain)digits[2]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0])));
+ }
+ }
+ break;
+ case -4:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 3 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 4 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) (((enum lm::ngram::Config::ARPALoadComplain)-1)*(((((((((enum lm::ngram::Config::ARPALoadComplain)digits[3]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[2]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0])));
+ }
+ }
+ break;
+ case 4:
+ if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) > 3 * PyLong_SHIFT) {
+ if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
+ __PYX_VERIFY_RETURN_INT(enum lm::ngram::Config::ARPALoadComplain, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
+ } else if (8 * sizeof(enum lm::ngram::Config::ARPALoadComplain) - 1 > 4 * PyLong_SHIFT) {
+ return (enum lm::ngram::Config::ARPALoadComplain) ((((((((((enum lm::ngram::Config::ARPALoadComplain)digits[3]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[2]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[1]) << PyLong_SHIFT) | (enum lm::ngram::Config::ARPALoadComplain)digits[0])));
+ }
+ }
+ break;
+ }
+#endif
+ if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(long)) {
+ __PYX_VERIFY_RETURN_INT_EXC(enum lm::ngram::Config::ARPALoadComplain, long, PyLong_AsLong(x))
+#ifdef HAVE_LONG_LONG
+ } else if (sizeof(enum lm::ngram::Config::ARPALoadComplain) <= sizeof(PY_LONG_LONG)) {
+ __PYX_VERIFY_RETURN_INT_EXC(enum lm::ngram::Config::ARPALoadComplain, PY_LONG_LONG, PyLong_AsLongLong(x))
+#endif
+ }
+ }
+ {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+ PyErr_SetString(PyExc_RuntimeError,
+ "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+ enum lm::ngram::Config::ARPALoadComplain val;
+ PyObject *v = __Pyx_PyNumber_IntOrLong(x);
+ #if PY_MAJOR_VERSION < 3
+ if (likely(v) && !PyLong_Check(v)) {
+ PyObject *tmp = v;
+ v = PyNumber_Long(tmp);
+ Py_DECREF(tmp);
+ }
+ #endif
+ if (likely(v)) {
+ int one = 1; int is_little = (int)*(unsigned char *)&one;
+ unsigned char *bytes = (unsigned char *)&val;
+ int ret = _PyLong_AsByteArray((PyLongObject *)v,
+ bytes, sizeof(val),
+ is_little, !is_unsigned);
+ Py_DECREF(v);
+ if (likely(!ret))
+ return val;
+ }
+#endif
+ return (enum lm::ngram::Config::ARPALoadComplain) -1;
+ }
+ } else {
+ enum lm::ngram::Config::ARPALoadComplain val;
+ PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
+ if (!tmp) return (enum lm::ngram::Config::ARPALoadComplain) -1;
+ val = __Pyx_PyInt_As_enum__lm_3a__3a_ngram_3a__3a_Config_3a__3a_ARPALoadComplain(tmp);
+ Py_DECREF(tmp);
+ return val;
+ }
+raise_overflow:
+ PyErr_SetString(PyExc_OverflowError,
+ "value too large to convert to enum lm::ngram::Config::ARPALoadComplain");
+ return (enum lm::ngram::Config::ARPALoadComplain) -1;
+raise_neg_overflow:
+ PyErr_SetString(PyExc_OverflowError,
+ "can't convert negative value to enum lm::ngram::Config::ARPALoadComplain");
+ return (enum lm::ngram::Config::ARPALoadComplain) -1;
+}
+
/* CIntToPy */
static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
diff --git a/python/kenlm.pyx b/python/kenlm.pyx
index 201720b..3e4cd9a 100644
--- a/python/kenlm.pyx
+++ b/python/kenlm.pyx
@@ -85,6 +85,11 @@ class LoadMethod:
READ = _kenlm.READ
PARALLEL_READ = _kenlm.PARALLEL_READ
+class ARPALoadComplain:
+ ALL = _kenlm.ALL
+ EXPENSIVE = _kenlm.EXPENSIVE
+ NONE = _kenlm.NONE
+
cdef class Config:
"""
Wrapper around lm::ngram::Config.
@@ -107,6 +112,12 @@ cdef class Config:
def __set__(self, to):
self._c_config.show_progress = to
+ property arpa_complain:
+ def __get__(self):
+ return self._c_config.arpa_complain
+ def __set__(self, to):
+ self._c_config.arpa_complain = to
+
cdef class Model:
"""
Wrapper around lm::ngram::Model.