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
path: root/python
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2013-04-16 22:33:10 +0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2013-04-16 22:34:08 +0400
commit8791fa7b8a3dcff31423c9d01ad5a3e7abb48614 (patch)
treecad8e1db4db27ec0cbd82b4eba3c5e0f45362564 /python
parentabb129062c4547dc02dda9e1f3479fed7b3797be (diff)
More detailed loading error message
Diffstat (limited to 'python')
-rw-r--r--python/kenlm.cpp44
-rw-r--r--python/kenlm.pyx4
2 files changed, 32 insertions, 16 deletions
diff --git a/python/kenlm.cpp b/python/kenlm.cpp
index d09dfae..5379fd4 100644
--- a/python/kenlm.cpp
+++ b/python/kenlm.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.18 on Wed Mar 20 14:33:41 2013 */
+/* Generated by Cython 0.18 on Thu Apr 4 10:54:01 2013 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -598,7 +598,7 @@ static PyObject *__pyx_pf_5kenlm_13LanguageModel_4path___get__(struct __pyx_obj_
static int __pyx_pf_5kenlm_13LanguageModel_4path_2__set__(struct __pyx_obj_5kenlm_LanguageModel *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
static int __pyx_pf_5kenlm_13LanguageModel_4path_4__del__(struct __pyx_obj_5kenlm_LanguageModel *__pyx_v_self); /* proto */
static char __pyx_k_2[] = "Cannot convert %s to string";
-static char __pyx_k_3[] = "Cannot read model '%s'";
+static char __pyx_k_3[] = "Cannot read model '{}' ({})";
static char __pyx_k_4[] = "<LanguageModel from {0}>";
static char __pyx_k__os[] = "os";
static char __pyx_k__path[] = "path";
@@ -810,6 +810,7 @@ static int __pyx_pf_5kenlm_13LanguageModel___init__(struct __pyx_obj_5kenlm_Lang
int __pyx_t_9;
PyObject *__pyx_t_10 = NULL;
PyObject *__pyx_t_11 = NULL;
+ PyObject *__pyx_t_12 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
@@ -867,7 +868,7 @@ static int __pyx_pf_5kenlm_13LanguageModel___init__(struct __pyx_obj_5kenlm_Lang
* try:
* self.model = new Model(self.path) # <<<<<<<<<<<<<<
* except RuntimeError as exception:
- * raise IOError('Cannot read model \'%s\'' % path) from exception
+ * raise IOError('Cannot read model \'{}\' ({})'.format(path, exception)) from exception
*/
__pyx_t_7 = PyBytes_AsString(((PyObject *)__pyx_v_self->path)); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
try {
@@ -891,7 +892,7 @@ static int __pyx_pf_5kenlm_13LanguageModel___init__(struct __pyx_obj_5kenlm_Lang
* try:
* self.model = new Model(self.path)
* except RuntimeError as exception: # <<<<<<<<<<<<<<
- * raise IOError('Cannot read model \'%s\'' % path) from exception
+ * raise IOError('Cannot read model \'{}\' ({})'.format(path, exception)) from exception
* self.vocab = &self.model.GetVocabulary()
*/
__pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_RuntimeError);
@@ -907,22 +908,34 @@ static int __pyx_pf_5kenlm_13LanguageModel___init__(struct __pyx_obj_5kenlm_Lang
/* "kenlm.pyx":20
* self.model = new Model(self.path)
* except RuntimeError as exception:
- * raise IOError('Cannot read model \'%s\'' % path) from exception # <<<<<<<<<<<<<<
+ * raise IOError('Cannot read model \'{}\' ({})'.format(path, exception)) from exception # <<<<<<<<<<<<<<
* self.vocab = &self.model.GetVocabulary()
*
*/
- __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), __pyx_v_path); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+ __pyx_t_10 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_3), __pyx_n_s__format); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
+ __Pyx_GOTREF(__pyx_t_10);
+ __pyx_t_11 = PyTuple_New(2); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
+ __Pyx_GOTREF(__pyx_t_11);
+ __Pyx_INCREF(__pyx_v_path);
+ PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_path);
+ __Pyx_GIVEREF(__pyx_v_path);
+ __Pyx_INCREF(__pyx_v_exception);
+ PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_v_exception);
+ __Pyx_GIVEREF(__pyx_v_exception);
+ __pyx_t_12 = PyObject_Call(__pyx_t_10, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
+ __Pyx_GOTREF(__pyx_t_12);
+ __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
__pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
__Pyx_GOTREF(__pyx_t_11);
- PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_10));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
- __pyx_t_10 = 0;
- __pyx_t_10 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
- __Pyx_GOTREF(__pyx_t_10);
+ PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_t_12);
+ __Pyx_GIVEREF(__pyx_t_12);
+ __pyx_t_12 = 0;
+ __pyx_t_12 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
+ __Pyx_GOTREF(__pyx_t_12);
__Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
- __Pyx_Raise(__pyx_t_10, 0, 0, __pyx_v_exception);
- __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+ __Pyx_Raise(__pyx_t_12, 0, 0, __pyx_v_exception);
+ __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L5_except_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -945,7 +958,7 @@ static int __pyx_pf_5kenlm_13LanguageModel___init__(struct __pyx_obj_5kenlm_Lang
/* "kenlm.pyx":21
* except RuntimeError as exception:
- * raise IOError('Cannot read model \'%s\'' % path) from exception
+ * raise IOError('Cannot read model \'{}\' ({})'.format(path, exception)) from exception
* self.vocab = &self.model.GetVocabulary() # <<<<<<<<<<<<<<
*
* def __dealloc__(self):
@@ -960,6 +973,7 @@ static int __pyx_pf_5kenlm_13LanguageModel___init__(struct __pyx_obj_5kenlm_Lang
__Pyx_XDECREF(__pyx_t_3);
__Pyx_XDECREF(__pyx_t_10);
__Pyx_XDECREF(__pyx_t_11);
+ __Pyx_XDECREF(__pyx_t_12);
__Pyx_AddTraceback("kenlm.LanguageModel.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
diff --git a/python/kenlm.pyx b/python/kenlm.pyx
index 1783500..243b879 100644
--- a/python/kenlm.pyx
+++ b/python/kenlm.pyx
@@ -17,7 +17,9 @@ cdef class LanguageModel:
try:
self.model = new Model(self.path)
except RuntimeError as exception:
- raise IOError('Cannot read model \'%s\'' % path) from exception
+ exception_message = str(exception_message).replace('\n', ' ')
+ raise IOError('Cannot read model \'{}\' ({})'.format(path, exception_message))\
+ from exception
self.vocab = &self.model.GetVocabulary()
def __dealloc__(self):