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

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilker Aziz <wilker.aziz@gmail.com>2012-09-14 14:51:31 +0400
committerWilker Aziz <wilker.aziz@gmail.com>2012-09-14 14:51:31 +0400
commitc300705772f694f6764b75a5e6c84bcbb613c091 (patch)
treef7ebfdffe2b2c7923d4ebc25d2b439517895a7c2 /contrib
parenta8b8e5c3623a415b7b5d76831ccb54e0cd467e7b (diff)
i) check for invalid paths; ii) added sample data; iii) added --with-cmph in setup.py
Diffstat (limited to 'contrib')
-rw-r--r--contrib/python/README.md6
-rw-r--r--contrib/python/binpt/binpt.cpp1223
-rw-r--r--contrib/python/binpt/binpt.pyx21
-rw-r--r--contrib/python/examples/phrase-table.binphr.idxbin0 -> 20 bytes
-rw-r--r--contrib/python/examples/phrase-table.binphr.srctree.wabin0 -> 84 bytes
-rw-r--r--contrib/python/examples/phrase-table.binphr.srcvoc2
-rw-r--r--contrib/python/examples/phrase-table.binphr.tgtdata.wabin0 -> 180 bytes
-rw-r--r--contrib/python/examples/phrase-table.binphr.tgtvoc4
-rw-r--r--contrib/python/examples/phrase-table.txt4
-rw-r--r--contrib/python/setup.py10
10 files changed, 1035 insertions, 235 deletions
diff --git a/contrib/python/README.md b/contrib/python/README.md
index 4535dae33..fa7d270c8 100644
--- a/contrib/python/README.md
+++ b/contrib/python/README.md
@@ -12,12 +12,12 @@ The idea is to have some of Moses' internals exposed to Python (inspired on pycd
1. Build the python extension
- python setup.py build_ext -i
+ python setup.py build_ext -i [--with-cmph]
3. Check the example code
- echo '! " and "' | python example.py bin-ptable-stem 5 1
- echo "casa" | python example.py bin-ptable-stem 5
+ echo "casa" | python example.py examples/phrase-table 5 1
+ echo "essa casa" | python example.py examples/phrase-table 5 1
## Changing the code
diff --git a/contrib/python/binpt/binpt.cpp b/contrib/python/binpt/binpt.cpp
index 044b55201..b5b2d0f27 100644
--- a/contrib/python/binpt/binpt.cpp
+++ b/contrib/python/binpt/binpt.cpp
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.16 on Wed Sep 12 11:46:20 2012 */
+/* Generated by Cython 0.16 on Fri Sep 14 12:51:05 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -375,7 +375,7 @@ struct __pyx_opt_args_5binpt_get_query_result;
*/
typedef std::string *__pyx_t_5binpt_str_pointer;
-/* "binpt.pyx":58
+/* "binpt.pyx":59
* return repr((repr(self._words), repr(self._scores), repr(self._wa)))
*
* cdef QueryResult get_query_result(StringTgtCand& cand, wa = None): # <<<<<<<<<<<<<<
@@ -387,7 +387,7 @@ struct __pyx_opt_args_5binpt_get_query_result {
PyObject *wa;
};
-/* "binpt.pyx":11
+/* "binpt.pyx":12
* raise TypeError('Cannot convert %s to string' % type(data))
*
* cdef class QueryResult(object): # <<<<<<<<<<<<<<
@@ -402,7 +402,7 @@ struct __pyx_obj_5binpt_QueryResult {
};
-/* "binpt.pyx":65
+/* "binpt.pyx":66
* return QueryResult(words, scores, wa)
*
* cdef class BinaryPhraseTable(object): # <<<<<<<<<<<<<<
@@ -488,6 +488,8 @@ static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
const char* function_name); /*proto*/
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level); /*proto*/
+
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
@@ -560,8 +562,10 @@ int __pyx_module_is_main_binpt = 0;
/* Implementation of 'binpt' */
static PyObject *__pyx_builtin_property;
+static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_TypeError;
static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_builtin_ValueError;
static int __pyx_pf_5binpt_11QueryResult___cinit__(struct __pyx_obj_5binpt_QueryResult *__pyx_v_self, PyObject *__pyx_v_words, PyObject *__pyx_v_scores, PyObject *__pyx_v_wa); /* proto */
static PyObject *__pyx_pf_5binpt_11QueryResult_2words(struct __pyx_obj_5binpt_QueryResult *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_5binpt_11QueryResult_4scores(struct __pyx_obj_5binpt_QueryResult *__pyx_v_self); /* proto */
@@ -570,21 +574,35 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
static PyObject *__pyx_pf_5binpt_11QueryResult_10__repr__(struct __pyx_obj_5binpt_QueryResult *__pyx_v_self); /* proto */
static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self, char *__pyx_v_path, unsigned int __pyx_v_nscores, int __pyx_v_wa, PyObject *__pyx_v_delimiter); /* proto */
static void __pyx_pf_5binpt_17BinaryPhraseTable_2__dealloc__(CYTHON_UNUSED struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_4path(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6nscores(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8wa(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_10delimiter(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self, char *__pyx_v_line); /* proto */
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_4isValidBinaryTable(PyObject *__pyx_v_stem, int __pyx_v_wa); /* proto */
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6path(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8nscores(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_10wa(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12delimiter(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_14query(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self, char *__pyx_v_line); /* proto */
static char __pyx_k_1[] = "UTF-8";
static char __pyx_k_3[] = "Cannot convert %s to string";
static char __pyx_k_4[] = " ||| ";
static char __pyx_k_5[] = " ";
+static char __pyx_k_6[] = "'%s' doesn't seem a valid binary table.";
+static char __pyx_k_7[] = ".binphr.idx";
+static char __pyx_k_8[] = ".binphr.srctree.wa";
+static char __pyx_k_9[] = ".binphr.srcvoc";
+static char __pyx_k_10[] = ".binphr.tgtdata.wa";
+static char __pyx_k_11[] = ".binphr.tgtvoc";
+static char __pyx_k_12[] = ".binphr.srctree";
+static char __pyx_k_13[] = ".binphr.tgtdata";
+static char __pyx_k_16[] = "/media/Data/tools/moses/mosesdecoder/contrib/python/binpt/binpt.pyx";
+static char __pyx_k__os[] = "os";
static char __pyx_k__wa[] = "wa";
static char __pyx_k__join[] = "join";
static char __pyx_k__path[] = "path";
+static char __pyx_k__stem[] = "stem";
+static char __pyx_k__binpt[] = "binpt";
static char __pyx_k__range[] = "range";
static char __pyx_k__words[] = "words";
static char __pyx_k__encode[] = "encode";
+static char __pyx_k__isfile[] = "isfile";
static char __pyx_k__scores[] = "scores";
static char __pyx_k__nscores[] = "nscores";
static char __pyx_k____main__[] = "__main__";
@@ -592,27 +610,48 @@ static char __pyx_k____test__[] = "__test__";
static char __pyx_k__property[] = "property";
static char __pyx_k__TypeError[] = "TypeError";
static char __pyx_k__delimiter[] = "delimiter";
+static char __pyx_k__ValueError[] = "ValueError";
+static char __pyx_k__staticmethod[] = "staticmethod";
+static char __pyx_k__isValidBinaryTable[] = "isValidBinaryTable";
static PyObject *__pyx_kp_s_1;
+static PyObject *__pyx_kp_s_10;
+static PyObject *__pyx_kp_s_11;
+static PyObject *__pyx_kp_s_12;
+static PyObject *__pyx_kp_s_13;
+static PyObject *__pyx_kp_s_16;
static PyObject *__pyx_kp_s_3;
static PyObject *__pyx_kp_s_4;
static PyObject *__pyx_kp_s_5;
+static PyObject *__pyx_kp_s_6;
+static PyObject *__pyx_kp_s_7;
+static PyObject *__pyx_kp_s_8;
+static PyObject *__pyx_kp_s_9;
static PyObject *__pyx_n_s__TypeError;
+static PyObject *__pyx_n_s__ValueError;
static PyObject *__pyx_n_s____main__;
static PyObject *__pyx_n_s____test__;
+static PyObject *__pyx_n_s__binpt;
static PyObject *__pyx_n_s__delimiter;
static PyObject *__pyx_n_s__encode;
+static PyObject *__pyx_n_s__isValidBinaryTable;
+static PyObject *__pyx_n_s__isfile;
static PyObject *__pyx_n_s__join;
static PyObject *__pyx_n_s__nscores;
+static PyObject *__pyx_n_s__os;
static PyObject *__pyx_n_s__path;
static PyObject *__pyx_n_s__property;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__scores;
+static PyObject *__pyx_n_s__staticmethod;
+static PyObject *__pyx_n_s__stem;
static PyObject *__pyx_n_s__wa;
static PyObject *__pyx_n_s__words;
static PyObject *__pyx_k_tuple_2;
+static PyObject *__pyx_k_tuple_14;
+static PyObject *__pyx_k_codeobj_15;
-/* "binpt.pyx":4
- * from libcpp.vector cimport vector
+/* "binpt.pyx":5
+ * import os
*
* cdef bytes as_str(data): # <<<<<<<<<<<<<<
* if isinstance(data, bytes):
@@ -630,7 +669,7 @@ static PyObject *__pyx_f_5binpt_as_str(PyObject *__pyx_v_data) {
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("as_str", 0);
- /* "binpt.pyx":5
+ /* "binpt.pyx":6
*
* cdef bytes as_str(data):
* if isinstance(data, bytes): # <<<<<<<<<<<<<<
@@ -643,7 +682,7 @@ static PyObject *__pyx_f_5binpt_as_str(PyObject *__pyx_v_data) {
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "binpt.pyx":6
+ /* "binpt.pyx":7
* cdef bytes as_str(data):
* if isinstance(data, bytes):
* return data # <<<<<<<<<<<<<<
@@ -651,14 +690,14 @@ static PyObject *__pyx_f_5binpt_as_str(PyObject *__pyx_v_data) {
* return data.encode('UTF-8')
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
- if (!(likely(PyBytes_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_data)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyBytes_CheckExact(__pyx_v_data))||((__pyx_v_data) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_data)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_data);
__pyx_r = ((PyObject*)__pyx_v_data);
goto __pyx_L0;
goto __pyx_L3;
}
- /* "binpt.pyx":7
+ /* "binpt.pyx":8
* if isinstance(data, bytes):
* return data
* elif isinstance(data, unicode): # <<<<<<<<<<<<<<
@@ -671,7 +710,7 @@ static PyObject *__pyx_f_5binpt_as_str(PyObject *__pyx_v_data) {
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
if (__pyx_t_2) {
- /* "binpt.pyx":8
+ /* "binpt.pyx":9
* return data
* elif isinstance(data, unicode):
* return data.encode('UTF-8') # <<<<<<<<<<<<<<
@@ -679,12 +718,12 @@ static PyObject *__pyx_f_5binpt_as_str(PyObject *__pyx_v_data) {
*
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_GetAttr(__pyx_v_data, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyObject*)__pyx_t_3);
__pyx_t_3 = 0;
goto __pyx_L0;
@@ -692,26 +731,26 @@ static PyObject *__pyx_f_5binpt_as_str(PyObject *__pyx_v_data) {
}
__pyx_L3:;
- /* "binpt.pyx":9
+ /* "binpt.pyx":10
* elif isinstance(data, unicode):
* return data.encode('UTF-8')
* raise TypeError('Cannot convert %s to string' % type(data)) # <<<<<<<<<<<<<<
*
* cdef class QueryResult(object):
*/
- __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_data))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)Py_TYPE(__pyx_v_data))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_3));
- __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
__pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__Pyx_Raise(__pyx_t_3, 0, 0, 0);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
- {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
goto __pyx_L0;
@@ -739,7 +778,7 @@ static int __pyx_pw_5binpt_11QueryResult_1__cinit__(PyObject *__pyx_v_self, PyOb
{
PyObject* values[3] = {0,0,0};
- /* "binpt.pyx":23
+ /* "binpt.pyx":24
* cdef bytes _wa
*
* def __cinit__(self, words, scores, wa = None): # <<<<<<<<<<<<<<
@@ -767,7 +806,7 @@ static int __pyx_pw_5binpt_11QueryResult_1__cinit__(PyObject *__pyx_v_self, PyOb
values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__scores);
if (likely(values[1])) kw_args--;
else {
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
case 2:
if (kw_args > 0) {
@@ -776,7 +815,7 @@ static int __pyx_pw_5binpt_11QueryResult_1__cinit__(PyObject *__pyx_v_self, PyOb
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
} else {
switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -793,7 +832,7 @@ static int __pyx_pw_5binpt_11QueryResult_1__cinit__(PyObject *__pyx_v_self, PyOb
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("binpt.QueryResult.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -812,42 +851,42 @@ static int __pyx_pf_5binpt_11QueryResult___cinit__(struct __pyx_obj_5binpt_Query
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
- /* "binpt.pyx":26
+ /* "binpt.pyx":27
* '''Requires a tuple of words (as strings) and a tuple of scores (as floats).
* Word-alignment info (as string) may be provided'''
* self._words = words # <<<<<<<<<<<<<<
* self._scores = scores
* self._wa = wa
*/
- if (!(likely(PyTuple_CheckExact(__pyx_v_words))||((__pyx_v_words) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_v_words)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyTuple_CheckExact(__pyx_v_words))||((__pyx_v_words) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_v_words)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_words);
__Pyx_GIVEREF(__pyx_v_words);
__Pyx_GOTREF(__pyx_v_self->_words);
__Pyx_DECREF(((PyObject *)__pyx_v_self->_words));
__pyx_v_self->_words = ((PyObject*)__pyx_v_words);
- /* "binpt.pyx":27
+ /* "binpt.pyx":28
* Word-alignment info (as string) may be provided'''
* self._words = words
* self._scores = scores # <<<<<<<<<<<<<<
* self._wa = wa
*
*/
- if (!(likely(PyTuple_CheckExact(__pyx_v_scores))||((__pyx_v_scores) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_v_scores)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyTuple_CheckExact(__pyx_v_scores))||((__pyx_v_scores) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected tuple, got %.200s", Py_TYPE(__pyx_v_scores)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_scores);
__Pyx_GIVEREF(__pyx_v_scores);
__Pyx_GOTREF(__pyx_v_self->_scores);
__Pyx_DECREF(((PyObject *)__pyx_v_self->_scores));
__pyx_v_self->_scores = ((PyObject*)__pyx_v_scores);
- /* "binpt.pyx":28
+ /* "binpt.pyx":29
* self._words = words
* self._scores = scores
* self._wa = wa # <<<<<<<<<<<<<<
*
* @property
*/
- if (!(likely(PyBytes_CheckExact(__pyx_v_wa))||((__pyx_v_wa) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_wa)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyBytes_CheckExact(__pyx_v_wa))||((__pyx_v_wa) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_wa)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_wa);
__Pyx_GIVEREF(__pyx_v_wa);
__Pyx_GOTREF(__pyx_v_self->_wa);
@@ -876,7 +915,7 @@ static PyObject *__pyx_pw_5binpt_11QueryResult_3words(PyObject *__pyx_v_self, CY
return __pyx_r;
}
-/* "binpt.pyx":31
+/* "binpt.pyx":32
*
* @property
* def words(self): # <<<<<<<<<<<<<<
@@ -889,7 +928,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_2words(struct __pyx_obj_5binpt_Qu
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("words", 0);
- /* "binpt.pyx":33
+ /* "binpt.pyx":34
* def words(self):
* '''Tuple of words (as strings)'''
* return self._words # <<<<<<<<<<<<<<
@@ -920,7 +959,7 @@ static PyObject *__pyx_pw_5binpt_11QueryResult_5scores(PyObject *__pyx_v_self, C
return __pyx_r;
}
-/* "binpt.pyx":36
+/* "binpt.pyx":37
*
* @property
* def scores(self): # <<<<<<<<<<<<<<
@@ -933,7 +972,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_4scores(struct __pyx_obj_5binpt_Q
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("scores", 0);
- /* "binpt.pyx":38
+ /* "binpt.pyx":39
* def scores(self):
* '''Tuple of scores (as floats)'''
* return self._scores # <<<<<<<<<<<<<<
@@ -964,7 +1003,7 @@ static PyObject *__pyx_pw_5binpt_11QueryResult_7wa(PyObject *__pyx_v_self, CYTHO
return __pyx_r;
}
-/* "binpt.pyx":41
+/* "binpt.pyx":42
*
* @property
* def wa(self): # <<<<<<<<<<<<<<
@@ -977,7 +1016,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_6wa(struct __pyx_obj_5binpt_Query
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("wa", 0);
- /* "binpt.pyx":43
+ /* "binpt.pyx":44
* def wa(self):
* '''Word-alignment info (as string)'''
* return self._wa # <<<<<<<<<<<<<<
@@ -1009,7 +1048,7 @@ static PyObject *__pyx_pw_5binpt_11QueryResult_9__str__(PyObject *__pyx_v_self)
return __pyx_r;
}
-/* "binpt.pyx":45
+/* "binpt.pyx":46
* return self._wa
*
* def __str__(self): # <<<<<<<<<<<<<<
@@ -1035,7 +1074,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__str__", 0);
- /* "binpt.pyx":47
+ /* "binpt.pyx":48
* def __str__(self):
* '''Returns a string such as: <words> ||| <scores> [||| word-alignment info]'''
* if self._wa: # <<<<<<<<<<<<<<
@@ -1045,7 +1084,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
__pyx_t_1 = (((PyObject *)__pyx_v_self->_wa) != Py_None) && (PyBytes_GET_SIZE(((PyObject *)__pyx_v_self->_wa)) != 0);
if (__pyx_t_1) {
- /* "binpt.pyx":48
+ /* "binpt.pyx":49
* '''Returns a string such as: <words> ||| <scores> [||| word-alignment info]'''
* if self._wa:
* return ' ||| '.join( (' '.join(self._words), # <<<<<<<<<<<<<<
@@ -1053,33 +1092,33 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
* self._wa) )
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_4), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_4), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_INCREF(((PyObject *)__pyx_v_self->_words));
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_v_self->_words));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self->_words));
- __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
- /* "binpt.pyx":49
+ /* "binpt.pyx":50
* if self._wa:
* return ' ||| '.join( (' '.join(self._words),
* ' '.join([str(x) for x in self._scores]), # <<<<<<<<<<<<<<
* self._wa) )
* else:
*/
- __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
- __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if (unlikely(((PyObject *)__pyx_v_self->_scores) == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_6 = ((PyObject *)__pyx_v_self->_scores); __Pyx_INCREF(__pyx_t_6); __pyx_t_7 = 0;
for (;;) {
@@ -1088,37 +1127,37 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
__Pyx_XDECREF(__pyx_v_x);
__pyx_v_x = __pyx_t_8;
__pyx_t_8 = 0;
- __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_INCREF(__pyx_v_x);
PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_x);
__Pyx_GIVEREF(__pyx_v_x);
- __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
- if (unlikely(PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
- __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_INCREF(((PyObject *)__pyx_t_3));
PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
- /* "binpt.pyx":50
+ /* "binpt.pyx":51
* return ' ||| '.join( (' '.join(self._words),
* ' '.join([str(x) for x in self._scores]),
* self._wa) ) # <<<<<<<<<<<<<<
* else:
* return ' ||| '.join( (' '.join(self._words),
*/
- __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
@@ -1129,12 +1168,12 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
__Pyx_GIVEREF(((PyObject *)__pyx_v_self->_wa));
__pyx_t_5 = 0;
__pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_6));
__Pyx_GIVEREF(((PyObject *)__pyx_t_6));
__pyx_t_6 = 0;
- __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
@@ -1145,7 +1184,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
}
/*else*/ {
- /* "binpt.pyx":52
+ /* "binpt.pyx":53
* self._wa) )
* else:
* return ' ||| '.join( (' '.join(self._words), # <<<<<<<<<<<<<<
@@ -1153,33 +1192,33 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
*
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_4), __pyx_n_s__join); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_4), __pyx_n_s__join); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
- __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_INCREF(((PyObject *)__pyx_v_self->_words));
PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->_words));
__Pyx_GIVEREF(((PyObject *)__pyx_v_self->_words));
- __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- /* "binpt.pyx":53
+ /* "binpt.pyx":54
* else:
* return ' ||| '.join( (' '.join(self._words),
* ' '.join([str(x) for x in self._scores]) ) ) # <<<<<<<<<<<<<<
*
* def __repr__(self):
*/
- __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
if (unlikely(((PyObject *)__pyx_v_self->_scores) == Py_None)) {
- PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
__pyx_t_4 = ((PyObject *)__pyx_v_self->_scores); __Pyx_INCREF(__pyx_t_4); __pyx_t_7 = 0;
for (;;) {
@@ -1188,29 +1227,29 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
__Pyx_XDECREF(__pyx_v_x);
__pyx_v_x = __pyx_t_9;
__pyx_t_9 = 0;
- __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_9);
__Pyx_INCREF(__pyx_v_x);
PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_x);
__Pyx_GIVEREF(__pyx_v_x);
- __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
- if (unlikely(PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
}
__Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_INCREF(((PyObject *)__pyx_t_3));
PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
__Pyx_GIVEREF(((PyObject *)__pyx_t_3));
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
- __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
- __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
@@ -1218,12 +1257,12 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_8__str__(struct __pyx_obj_5binpt_
__Pyx_GIVEREF(__pyx_t_3);
__pyx_t_5 = 0;
__pyx_t_3 = 0;
- __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
__Pyx_GIVEREF(((PyObject *)__pyx_t_4));
__pyx_t_4 = 0;
- __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 53; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
__Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
@@ -1263,7 +1302,7 @@ static PyObject *__pyx_pw_5binpt_11QueryResult_11__repr__(PyObject *__pyx_v_self
return __pyx_r;
}
-/* "binpt.pyx":55
+/* "binpt.pyx":56
* ' '.join([str(x) for x in self._scores]) ) )
*
* def __repr__(self): # <<<<<<<<<<<<<<
@@ -1283,7 +1322,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_10__repr__(struct __pyx_obj_5binp
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__repr__", 0);
- /* "binpt.pyx":56
+ /* "binpt.pyx":57
*
* def __repr__(self):
* return repr((repr(self._words), repr(self._scores), repr(self._wa))) # <<<<<<<<<<<<<<
@@ -1293,20 +1332,20 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_10__repr__(struct __pyx_obj_5binp
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = ((PyObject *)__pyx_v_self->_words);
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = ((PyObject *)__pyx_v_self->_scores);
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_3 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__pyx_t_1 = ((PyObject *)__pyx_v_self->_wa);
__Pyx_INCREF(__pyx_t_1);
- __pyx_t_4 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
__Pyx_GIVEREF(__pyx_t_2);
@@ -1317,7 +1356,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_10__repr__(struct __pyx_obj_5binp
__pyx_t_2 = 0;
__pyx_t_3 = 0;
__pyx_t_4 = 0;
- __pyx_t_4 = PyObject_Repr(((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Repr(((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_r = __pyx_t_4;
@@ -1339,7 +1378,7 @@ static PyObject *__pyx_pf_5binpt_11QueryResult_10__repr__(struct __pyx_obj_5binp
return __pyx_r;
}
-/* "binpt.pyx":58
+/* "binpt.pyx":59
* return repr((repr(self._words), repr(self._scores), repr(self._wa)))
*
* cdef QueryResult get_query_result(StringTgtCand& cand, wa = None): # <<<<<<<<<<<<<<
@@ -1368,53 +1407,53 @@ static struct __pyx_obj_5binpt_QueryResult *__pyx_f_5binpt_get_query_result(Mose
}
}
- /* "binpt.pyx":61
+ /* "binpt.pyx":62
* '''Converts a StringTgtCandidate (c++ object) and possibly a word-alignment info (string)
* to a QueryResult (python object).'''
* cdef tuple words = tuple([cand.first[i].c_str() for i in range(cand.first.size())]) # <<<<<<<<<<<<<<
* cdef tuple scores = tuple([cand.second[i] for i in range(cand.second.size())])
* return QueryResult(words, scores, wa)
*/
- __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __pyx_v_cand.first.size();
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
- __pyx_t_4 = PyBytes_FromString((__pyx_v_cand.first[__pyx_v_i])->c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyBytes_FromString((__pyx_v_cand.first[__pyx_v_i])->c_str()); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
- if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyList_Append(__pyx_t_1, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
}
- __pyx_t_4 = ((PyObject *)PyList_AsTuple(__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = ((PyObject *)PyList_AsTuple(__pyx_t_1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_4));
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_v_words = __pyx_t_4;
__pyx_t_4 = 0;
- /* "binpt.pyx":62
+ /* "binpt.pyx":63
* to a QueryResult (python object).'''
* cdef tuple words = tuple([cand.first[i].c_str() for i in range(cand.first.size())])
* cdef tuple scores = tuple([cand.second[i] for i in range(cand.second.size())]) # <<<<<<<<<<<<<<
* return QueryResult(words, scores, wa)
*
*/
- __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_2 = __pyx_v_cand.second.size();
for (__pyx_t_3 = 0; __pyx_t_3 < __pyx_t_2; __pyx_t_3+=1) {
__pyx_v_i = __pyx_t_3;
- __pyx_t_1 = PyFloat_FromDouble((__pyx_v_cand.second[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyFloat_FromDouble((__pyx_v_cand.second[__pyx_v_i])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyList_Append(__pyx_t_4, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyList_Append(__pyx_t_4, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
- __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_t_4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
__pyx_v_scores = __pyx_t_1;
__pyx_t_1 = 0;
- /* "binpt.pyx":63
+ /* "binpt.pyx":64
* cdef tuple words = tuple([cand.first[i].c_str() for i in range(cand.first.size())])
* cdef tuple scores = tuple([cand.second[i] for i in range(cand.second.size())])
* return QueryResult(words, scores, wa) # <<<<<<<<<<<<<<
@@ -1422,7 +1461,7 @@ static struct __pyx_obj_5binpt_QueryResult *__pyx_f_5binpt_get_query_result(Mose
* cdef class BinaryPhraseTable(object):
*/
__Pyx_XDECREF(((PyObject *)__pyx_r));
- __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_INCREF(((PyObject *)__pyx_v_words));
PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_words));
@@ -1433,7 +1472,7 @@ static struct __pyx_obj_5binpt_QueryResult *__pyx_f_5binpt_get_query_result(Mose
__Pyx_INCREF(__pyx_v_wa);
PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_wa);
__Pyx_GIVEREF(__pyx_v_wa);
- __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5binpt_QueryResult)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5binpt_QueryResult)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_r = ((struct __pyx_obj_5binpt_QueryResult *)__pyx_t_4);
@@ -1503,7 +1542,7 @@ static int __pyx_pw_5binpt_17BinaryPhraseTable_1__cinit__(PyObject *__pyx_v_self
}
}
if (unlikely(kw_args > 0)) {
- if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
if (values[1]) {
} else {
@@ -1512,7 +1551,7 @@ static int __pyx_pw_5binpt_17BinaryPhraseTable_1__cinit__(PyObject *__pyx_v_self
if (values[2]) {
} else {
- /* "binpt.pyx":75
+ /* "binpt.pyx":76
* cdef bytes _delimiter
*
* def __cinit__(self, char* path, unsigned nscores = 5, bint wa = False, delimiter = ' '): # <<<<<<<<<<<<<<
@@ -1531,14 +1570,14 @@ static int __pyx_pw_5binpt_17BinaryPhraseTable_1__cinit__(PyObject *__pyx_v_self
default: goto __pyx_L5_argtuple_error;
}
}
- __pyx_v_path = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_path) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_path = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_path) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
if (values[1]) {
- __pyx_v_nscores = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_nscores == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_nscores = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_nscores == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else {
__pyx_v_nscores = ((unsigned int)5);
}
if (values[2]) {
- __pyx_v_wa = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wa == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_wa = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_wa == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
} else {
__pyx_v_wa = ((int)0);
}
@@ -1546,7 +1585,7 @@ static int __pyx_pw_5binpt_17BinaryPhraseTable_1__cinit__(PyObject *__pyx_v_self
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
- __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
__pyx_L3_error:;
__Pyx_AddTraceback("binpt.BinaryPhraseTable.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
@@ -1561,28 +1600,82 @@ static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt
int __pyx_r;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ PyObject *__pyx_t_4 = NULL;
+ int __pyx_t_5;
+ int __pyx_t_6;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("__cinit__", 0);
- /* "binpt.pyx":81
- * and whether or not there is word-alignment info in the table (usually not).
+ /* "binpt.pyx":83
* One can also specify the token delimiter, for Moses::Tokenize(text, delimiter), which is one space by default.'''
+ *
+ * if not BinaryPhraseTable.isValidBinaryTable(path, wa): # <<<<<<<<<<<<<<
+ * raise ValueError, "'%s' doesn't seem a valid binary table." % path
+ * self._path = path
+ */
+ __pyx_t_1 = PyObject_GetAttr(((PyObject *)((PyObject*)__pyx_ptype_5binpt_BinaryPhraseTable)), __pyx_n_s__isValidBinaryTable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyBytes_FromString(__pyx_v_path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+ __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_wa); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_4);
+ PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+ PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ __pyx_t_2 = 0;
+ __pyx_t_3 = 0;
+ __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+ __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_6 = (!__pyx_t_5);
+ if (__pyx_t_6) {
+
+ /* "binpt.pyx":84
+ *
+ * if not BinaryPhraseTable.isValidBinaryTable(path, wa):
+ * raise ValueError, "'%s' doesn't seem a valid binary table." % path # <<<<<<<<<<<<<<
+ * self._path = path
+ * self._nscores = nscores
+ */
+ __pyx_t_3 = PyBytes_FromString(__pyx_v_path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+ __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __Pyx_Raise(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), 0, 0);
+ __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+ {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ goto __pyx_L3;
+ }
+ __pyx_L3:;
+
+ /* "binpt.pyx":85
+ * if not BinaryPhraseTable.isValidBinaryTable(path, wa):
+ * raise ValueError, "'%s' doesn't seem a valid binary table." % path
* self._path = path # <<<<<<<<<<<<<<
* self._nscores = nscores
* self._wa = wa
*/
- __pyx_t_1 = PyBytes_FromString(__pyx_v_path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+ __pyx_t_4 = PyBytes_FromString(__pyx_v_path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+ __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
__Pyx_GOTREF(__pyx_v_self->_path);
__Pyx_DECREF(((PyObject *)__pyx_v_self->_path));
- __pyx_v_self->_path = __pyx_t_1;
- __pyx_t_1 = 0;
+ __pyx_v_self->_path = __pyx_t_4;
+ __pyx_t_4 = 0;
- /* "binpt.pyx":82
- * One can also specify the token delimiter, for Moses::Tokenize(text, delimiter), which is one space by default.'''
+ /* "binpt.pyx":86
+ * raise ValueError, "'%s' doesn't seem a valid binary table." % path
* self._path = path
* self._nscores = nscores # <<<<<<<<<<<<<<
* self._wa = wa
@@ -1590,7 +1683,7 @@ static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt
*/
__pyx_v_self->_nscores = __pyx_v_nscores;
- /* "binpt.pyx":83
+ /* "binpt.pyx":87
* self._path = path
* self._nscores = nscores
* self._wa = wa # <<<<<<<<<<<<<<
@@ -1599,21 +1692,21 @@ static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt
*/
__pyx_v_self->_wa = __pyx_v_wa;
- /* "binpt.pyx":84
+ /* "binpt.pyx":88
* self._nscores = nscores
* self._wa = wa
* self._delimiter = delimiter # <<<<<<<<<<<<<<
* self.__tree = new PhraseDictionaryTree(nscores)
* self.__tree.UseWordAlignment(wa)
*/
- if (!(likely(PyBytes_CheckExact(__pyx_v_delimiter))||((__pyx_v_delimiter) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_delimiter)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (!(likely(PyBytes_CheckExact(__pyx_v_delimiter))||((__pyx_v_delimiter) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_v_delimiter)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_INCREF(__pyx_v_delimiter);
__Pyx_GIVEREF(__pyx_v_delimiter);
__Pyx_GOTREF(__pyx_v_self->_delimiter);
__Pyx_DECREF(((PyObject *)__pyx_v_self->_delimiter));
__pyx_v_self->_delimiter = ((PyObject*)__pyx_v_delimiter);
- /* "binpt.pyx":85
+ /* "binpt.pyx":89
* self._wa = wa
* self._delimiter = delimiter
* self.__tree = new PhraseDictionaryTree(nscores) # <<<<<<<<<<<<<<
@@ -1622,7 +1715,7 @@ static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt
*/
__pyx_v_self->__pyx___tree = new Moses::PhraseDictionaryTree(__pyx_v_nscores);
- /* "binpt.pyx":86
+ /* "binpt.pyx":90
* self._delimiter = delimiter
* self.__tree = new PhraseDictionaryTree(nscores)
* self.__tree.UseWordAlignment(wa) # <<<<<<<<<<<<<<
@@ -1631,7 +1724,7 @@ static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt
*/
__pyx_v_self->__pyx___tree->UseWordAlignment(__pyx_v_wa);
- /* "binpt.pyx":87
+ /* "binpt.pyx":91
* self.__tree = new PhraseDictionaryTree(nscores)
* self.__tree.UseWordAlignment(wa)
* self.__tree.Read(path) # <<<<<<<<<<<<<<
@@ -1644,6 +1737,9 @@ static int __pyx_pf_5binpt_17BinaryPhraseTable___cinit__(struct __pyx_obj_5binpt
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_4);
__Pyx_AddTraceback("binpt.BinaryPhraseTable.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
@@ -1660,7 +1756,7 @@ static void __pyx_pw_5binpt_17BinaryPhraseTable_3__dealloc__(PyObject *__pyx_v_s
__Pyx_RefNannyFinishContext();
}
-/* "binpt.pyx":89
+/* "binpt.pyx":93
* self.__tree.Read(path)
*
* def __dealloc__(self): # <<<<<<<<<<<<<<
@@ -1672,12 +1768,12 @@ static void __pyx_pf_5binpt_17BinaryPhraseTable_2__dealloc__(CYTHON_UNUSED struc
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__dealloc__", 0);
- /* "binpt.pyx":90
+ /* "binpt.pyx":94
*
* def __dealloc__(self):
* del self.__tree # <<<<<<<<<<<<<<
*
- * @property
+ * @staticmethod
*/
delete __pyx_v_self->__pyx___tree;
@@ -1685,17 +1781,524 @@ static void __pyx_pf_5binpt_17BinaryPhraseTable_2__dealloc__(CYTHON_UNUSED struc
}
/* Python wrapper */
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_5path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_5path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_5isValidBinaryTable(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_5binpt_17BinaryPhraseTable_4isValidBinaryTable[] = "This sanity check was added to the constructor, but you can access it from outside this class\n to determine whether or not you are providing a valid stem to BinaryPhraseTable.";
+static PyMethodDef __pyx_mdef_5binpt_17BinaryPhraseTable_5isValidBinaryTable = {__Pyx_NAMESTR("isValidBinaryTable"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_5isValidBinaryTable, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5binpt_17BinaryPhraseTable_4isValidBinaryTable)};
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_5isValidBinaryTable(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+ PyObject *__pyx_v_stem = 0;
+ int __pyx_v_wa;
+ static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__stem,&__pyx_n_s__wa,0};
+ PyObject *__pyx_r = 0;
+ __Pyx_RefNannyDeclarations
+ __Pyx_RefNannySetupContext("isValidBinaryTable (wrapper)", 0);
+ {
+ PyObject* values[2] = {0,0};
+ if (unlikely(__pyx_kwds)) {
+ Py_ssize_t kw_args;
+ const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+ switch (pos_args) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ case 0: break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ kw_args = PyDict_Size(__pyx_kwds);
+ switch (pos_args) {
+ case 0:
+ values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__stem);
+ if (likely(values[0])) kw_args--;
+ else goto __pyx_L5_argtuple_error;
+ case 1:
+ if (kw_args > 0) {
+ PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__wa);
+ if (value) { values[1] = value; kw_args--; }
+ }
+ }
+ if (unlikely(kw_args > 0)) {
+ if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "isValidBinaryTable") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ }
+ if (values[1]) {
+ } else {
+
+ /* "binpt.pyx":97
+ *
+ * @staticmethod
+ * def isValidBinaryTable(stem, bint wa = False): # <<<<<<<<<<<<<<
+ * '''This sanity check was added to the constructor, but you can access it from outside this class
+ * to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ */
+ __pyx_v_wa = ((int)0);
+ }
+ } else {
+ switch (PyTuple_GET_SIZE(__pyx_args)) {
+ case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+ case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+ break;
+ default: goto __pyx_L5_argtuple_error;
+ }
+ }
+ __pyx_v_stem = values[0];
+ if (values[1]) {
+ __pyx_v_wa = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_wa == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ } else {
+ __pyx_v_wa = ((int)0);
+ }
+ }
+ goto __pyx_L4_argument_unpacking_done;
+ __pyx_L5_argtuple_error:;
+ __Pyx_RaiseArgtupleInvalid("isValidBinaryTable", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_L3_error:;
+ __Pyx_AddTraceback("binpt.BinaryPhraseTable.isValidBinaryTable", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __Pyx_RefNannyFinishContext();
+ return NULL;
+ __pyx_L4_argument_unpacking_done:;
+ __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_4isValidBinaryTable(__pyx_v_stem, __pyx_v_wa);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_4isValidBinaryTable(PyObject *__pyx_v_stem, int __pyx_v_wa) {
+ PyObject *__pyx_r = NULL;
+ __Pyx_RefNannyDeclarations
+ PyObject *__pyx_t_1 = NULL;
+ PyObject *__pyx_t_2 = NULL;
+ PyObject *__pyx_t_3 = NULL;
+ int __pyx_t_4;
+ PyObject *__pyx_t_5 = NULL;
+ PyObject *__pyx_t_6 = NULL;
+ PyObject *__pyx_t_7 = NULL;
+ PyObject *__pyx_t_8 = NULL;
+ int __pyx_lineno = 0;
+ const char *__pyx_filename = NULL;
+ int __pyx_clineno = 0;
+ __Pyx_RefNannySetupContext("isValidBinaryTable", 0);
+
+ /* "binpt.pyx":100
+ * '''This sanity check was added to the constructor, but you can access it from outside this class
+ * to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ * if wa: # <<<<<<<<<<<<<<
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \
+ */
+ if (__pyx_v_wa) {
+
+ /* "binpt.pyx":101
+ * to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ * if wa:
+ * return os.path.isfile(stem + ".binphr.idx") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ */
+ __Pyx_XDECREF(__pyx_r);
+
+ /* "binpt.pyx":102
+ * if wa:
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata.wa") \
+ */
+ __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__isfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "binpt.pyx":101
+ * to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ * if wa:
+ * return os.path.isfile(stem + ".binphr.idx") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ */
+ __pyx_t_2 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __pyx_t_2 = 0;
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "binpt.pyx":102
+ * if wa:
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata.wa") \
+ */
+ __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__isfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_8)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "binpt.pyx":103
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.tgtdata.wa") \
+ * and os.path.isfile(stem + ".binphr.tgtvoc")
+ */
+ __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__isfile); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_3 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_9)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ __pyx_t_3 = 0;
+ __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "binpt.pyx":104
+ * and os.path.isfile(stem + ".binphr.srctree.wa") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata.wa") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.tgtvoc")
+ * else:
+ */
+ __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __pyx_t_5 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__path); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_6 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__isfile); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_5 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
+ __Pyx_GIVEREF(__pyx_t_5);
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+ /* "binpt.pyx":105
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata.wa") \
+ * and os.path.isfile(stem + ".binphr.tgtvoc") # <<<<<<<<<<<<<<
+ * else:
+ * return os.path.isfile(stem + ".binphr.idx") \
+ */
+ __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ __pyx_t_7 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__isfile); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_6 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_11)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
+ __Pyx_GIVEREF(__pyx_t_6);
+ __pyx_t_6 = 0;
+ __pyx_t_6 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+ __pyx_t_8 = __pyx_t_6;
+ __pyx_t_6 = 0;
+ } else {
+ __pyx_t_8 = __pyx_t_5;
+ __pyx_t_5 = 0;
+ }
+ __pyx_t_5 = __pyx_t_8;
+ __pyx_t_8 = 0;
+ } else {
+ __pyx_t_5 = __pyx_t_3;
+ __pyx_t_3 = 0;
+ }
+ __pyx_t_3 = __pyx_t_5;
+ __pyx_t_5 = 0;
+ } else {
+ __pyx_t_3 = __pyx_t_1;
+ __pyx_t_1 = 0;
+ }
+ __pyx_t_1 = __pyx_t_3;
+ __pyx_t_3 = 0;
+ } else {
+ __pyx_t_1 = __pyx_t_2;
+ __pyx_t_2 = 0;
+ }
+ __pyx_r = __pyx_t_1;
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+ goto __pyx_L3;
+ }
+ /*else*/ {
+
+ /* "binpt.pyx":107
+ * and os.path.isfile(stem + ".binphr.tgtvoc")
+ * else:
+ * return os.path.isfile(stem + ".binphr.idx") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srctree") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ */
+ __Pyx_XDECREF(__pyx_r);
+
+ /* "binpt.pyx":108
+ * else:
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata") \
+ */
+ __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__isfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "binpt.pyx":107
+ * and os.path.isfile(stem + ".binphr.tgtvoc")
+ * else:
+ * return os.path.isfile(stem + ".binphr.idx") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srctree") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ */
+ __pyx_t_2 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+ __Pyx_GIVEREF(__pyx_t_2);
+ __pyx_t_2 = 0;
+ __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+ /* "binpt.pyx":108
+ * else:
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata") \
+ */
+ __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__isfile); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ __pyx_t_1 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_12)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "binpt.pyx":109
+ * return os.path.isfile(stem + ".binphr.idx") \
+ * and os.path.isfile(stem + ".binphr.srctree") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.tgtdata") \
+ * and os.path.isfile(stem + ".binphr.tgtvoc")
+ */
+ __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__isfile); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+ __pyx_t_3 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_9)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
+ __Pyx_GIVEREF(__pyx_t_3);
+ __pyx_t_3 = 0;
+ __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_3);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+ /* "binpt.pyx":110
+ * and os.path.isfile(stem + ".binphr.srctree") \
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata") \ # <<<<<<<<<<<<<<
+ * and os.path.isfile(stem + ".binphr.tgtvoc")
+ *
+ */
+ __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__path); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__isfile); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+ __pyx_t_5 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_13)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
+ __Pyx_GIVEREF(__pyx_t_5);
+ __pyx_t_5 = 0;
+ __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_5);
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+ __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__pyx_t_4) {
+ __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+ /* "binpt.pyx":111
+ * and os.path.isfile(stem + ".binphr.srcvoc") \
+ * and os.path.isfile(stem + ".binphr.tgtdata") \
+ * and os.path.isfile(stem + ".binphr.tgtvoc") # <<<<<<<<<<<<<<
+ *
+ * @property
+ */
+ __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __pyx_t_8 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__path); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __pyx_t_6 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__isfile); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_6);
+ __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+ __pyx_t_8 = PyNumber_Add(__pyx_v_stem, ((PyObject *)__pyx_kp_s_11)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_7);
+ PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
+ __Pyx_GIVEREF(__pyx_t_8);
+ __pyx_t_8 = 0;
+ __pyx_t_8 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_8);
+ __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+ __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+ __pyx_t_7 = __pyx_t_8;
+ __pyx_t_8 = 0;
+ } else {
+ __pyx_t_7 = __pyx_t_5;
+ __pyx_t_5 = 0;
+ }
+ __pyx_t_5 = __pyx_t_7;
+ __pyx_t_7 = 0;
+ } else {
+ __pyx_t_5 = __pyx_t_3;
+ __pyx_t_3 = 0;
+ }
+ __pyx_t_3 = __pyx_t_5;
+ __pyx_t_5 = 0;
+ } else {
+ __pyx_t_3 = __pyx_t_1;
+ __pyx_t_1 = 0;
+ }
+ __pyx_t_1 = __pyx_t_3;
+ __pyx_t_3 = 0;
+ } else {
+ __pyx_t_1 = __pyx_t_2;
+ __pyx_t_2 = 0;
+ }
+ __pyx_r = __pyx_t_1;
+ __pyx_t_1 = 0;
+ goto __pyx_L0;
+ }
+ __pyx_L3:;
+
+ __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+ goto __pyx_L0;
+ __pyx_L1_error:;
+ __Pyx_XDECREF(__pyx_t_1);
+ __Pyx_XDECREF(__pyx_t_2);
+ __Pyx_XDECREF(__pyx_t_3);
+ __Pyx_XDECREF(__pyx_t_5);
+ __Pyx_XDECREF(__pyx_t_6);
+ __Pyx_XDECREF(__pyx_t_7);
+ __Pyx_XDECREF(__pyx_t_8);
+ __Pyx_AddTraceback("binpt.BinaryPhraseTable.isValidBinaryTable", __pyx_clineno, __pyx_lineno, __pyx_filename);
+ __pyx_r = NULL;
+ __pyx_L0:;
+ __Pyx_XGIVEREF(__pyx_r);
+ __Pyx_RefNannyFinishContext();
+ return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_7path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_7path(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("path (wrapper)", 0);
- __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_4path(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_6path(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "binpt.pyx":93
+/* "binpt.pyx":114
*
* @property
* def path(self): # <<<<<<<<<<<<<<
@@ -1703,12 +2306,12 @@ static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_5path(PyObject *__pyx_v_sel
*
*/
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_4path(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6path(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("path", 0);
- /* "binpt.pyx":94
+ /* "binpt.pyx":115
* @property
* def path(self):
* return self._path # <<<<<<<<<<<<<<
@@ -1728,17 +2331,17 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_4path(struct __pyx_obj_5bin
}
/* Python wrapper */
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_7nscores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_7nscores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_9nscores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_9nscores(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("nscores (wrapper)", 0);
- __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_6nscores(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_8nscores(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "binpt.pyx":97
+/* "binpt.pyx":118
*
* @property
* def nscores(self): # <<<<<<<<<<<<<<
@@ -1746,7 +2349,7 @@ static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_7nscores(PyObject *__pyx_v_
*
*/
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6nscores(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8nscores(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -1755,7 +2358,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6nscores(struct __pyx_obj_5
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("nscores", 0);
- /* "binpt.pyx":98
+ /* "binpt.pyx":119
* @property
* def nscores(self):
* return self._nscores # <<<<<<<<<<<<<<
@@ -1763,7 +2366,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6nscores(struct __pyx_obj_5
* @property
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->_nscores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_self->_nscores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -1782,17 +2385,17 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_6nscores(struct __pyx_obj_5
}
/* Python wrapper */
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_9wa(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_9wa(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_11wa(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_11wa(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("wa (wrapper)", 0);
- __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_8wa(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_10wa(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "binpt.pyx":101
+/* "binpt.pyx":122
*
* @property
* def wa(self): # <<<<<<<<<<<<<<
@@ -1800,7 +2403,7 @@ static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_9wa(PyObject *__pyx_v_self,
*
*/
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8wa(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_10wa(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
@@ -1809,7 +2412,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8wa(struct __pyx_obj_5binpt
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("wa", 0);
- /* "binpt.pyx":102
+ /* "binpt.pyx":123
* @property
* def wa(self):
* return self._wa # <<<<<<<<<<<<<<
@@ -1817,7 +2420,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8wa(struct __pyx_obj_5binpt
* @property
*/
__Pyx_XDECREF(__pyx_r);
- __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_wa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->_wa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
@@ -1836,17 +2439,17 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_8wa(struct __pyx_obj_5binpt
}
/* Python wrapper */
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_11delimiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_11delimiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_13delimiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_13delimiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("delimiter (wrapper)", 0);
- __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_10delimiter(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
+ __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_12delimiter(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "binpt.pyx":105
+/* "binpt.pyx":126
*
* @property
* def delimiter(self): # <<<<<<<<<<<<<<
@@ -1854,12 +2457,12 @@ static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_11delimiter(PyObject *__pyx
*
*/
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_10delimiter(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12delimiter(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self) {
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("delimiter", 0);
- /* "binpt.pyx":106
+ /* "binpt.pyx":127
* @property
* def delimiter(self):
* return self._delimiter # <<<<<<<<<<<<<<
@@ -1879,15 +2482,15 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_10delimiter(struct __pyx_ob
}
/* Python wrapper */
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_13query(PyObject *__pyx_v_self, PyObject *__pyx_arg_line); /*proto*/
-static char __pyx_doc_5binpt_17BinaryPhraseTable_12query[] = "Queries the phrase table and returns a list of matches.\n Each match is a QueryResult.";
-static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_13query(PyObject *__pyx_v_self, PyObject *__pyx_arg_line) {
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_15query(PyObject *__pyx_v_self, PyObject *__pyx_arg_line); /*proto*/
+static char __pyx_doc_5binpt_17BinaryPhraseTable_14query[] = "Queries the phrase table and returns a list of matches.\n Each match is a QueryResult.";
+static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_15query(PyObject *__pyx_v_self, PyObject *__pyx_arg_line) {
char *__pyx_v_line;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("query (wrapper)", 0);
assert(__pyx_arg_line); {
- __pyx_v_line = PyBytes_AsString(__pyx_arg_line); if (unlikely((!__pyx_v_line) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+ __pyx_v_line = PyBytes_AsString(__pyx_arg_line); if (unlikely((!__pyx_v_line) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L3_error:;
@@ -1895,12 +2498,12 @@ static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_13query(PyObject *__pyx_v_s
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
- __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_12query(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self), ((char *)__pyx_v_line));
+ __pyx_r = __pyx_pf_5binpt_17BinaryPhraseTable_14query(((struct __pyx_obj_5binpt_BinaryPhraseTable *)__pyx_v_self), ((char *)__pyx_v_line));
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
-/* "binpt.pyx":108
+/* "binpt.pyx":129
* return self._delimiter
*
* def query(self, char* line): # <<<<<<<<<<<<<<
@@ -1908,7 +2511,7 @@ static PyObject *__pyx_pw_5binpt_17BinaryPhraseTable_13query(PyObject *__pyx_v_s
* Each match is a QueryResult.'''
*/
-static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self, char *__pyx_v_line) {
+static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_14query(struct __pyx_obj_5binpt_BinaryPhraseTable *__pyx_v_self, char *__pyx_v_line) {
PyObject *__pyx_v_text = 0;
std::vector<std::string> __pyx_v_fphrase;
std::vector<Moses::StringTgtCand> *__pyx_v_rv;
@@ -1931,36 +2534,36 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
int __pyx_clineno = 0;
__Pyx_RefNannySetupContext("query", 0);
- /* "binpt.pyx":111
+ /* "binpt.pyx":132
* '''Queries the phrase table and returns a list of matches.
* Each match is a QueryResult.'''
* cdef bytes text = as_str(line) # <<<<<<<<<<<<<<
* cdef vector[string] fphrase = Tokenize(text, self.delimiter)
* cdef vector[StringTgtCand]* rv = new vector[StringTgtCand]()
*/
- __pyx_t_1 = PyBytes_FromString(__pyx_v_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(__pyx_v_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
- __pyx_t_2 = ((PyObject *)__pyx_f_5binpt_as_str(((PyObject *)__pyx_t_1))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = ((PyObject *)__pyx_f_5binpt_as_str(((PyObject *)__pyx_t_1))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
__pyx_v_text = ((PyObject*)__pyx_t_2);
__pyx_t_2 = 0;
- /* "binpt.pyx":112
+ /* "binpt.pyx":133
* Each match is a QueryResult.'''
* cdef bytes text = as_str(line)
* cdef vector[string] fphrase = Tokenize(text, self.delimiter) # <<<<<<<<<<<<<<
* cdef vector[StringTgtCand]* rv = new vector[StringTgtCand]()
* cdef vector[string]* wa
*/
- __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_text)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__delimiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_text)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__delimiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
- __pyx_t_4 = PyBytes_AsString(__pyx_t_2); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_4 = PyBytes_AsString(__pyx_t_2); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_v_fphrase = Moses::Tokenize(__pyx_t_3, __pyx_t_4);
- /* "binpt.pyx":113
+ /* "binpt.pyx":134
* cdef bytes text = as_str(line)
* cdef vector[string] fphrase = Tokenize(text, self.delimiter)
* cdef vector[StringTgtCand]* rv = new vector[StringTgtCand]() # <<<<<<<<<<<<<<
@@ -1969,7 +2572,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
*/
__pyx_v_rv = new std::vector<Moses::StringTgtCand>();
- /* "binpt.pyx":116
+ /* "binpt.pyx":137
* cdef vector[string]* wa
* cdef list phrases
* if not self.__tree.UseWordAlignment(): # <<<<<<<<<<<<<<
@@ -1979,7 +2582,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
__pyx_t_5 = (!__pyx_v_self->__pyx___tree->UseWordAlignment());
if (__pyx_t_5) {
- /* "binpt.pyx":117
+ /* "binpt.pyx":138
* cdef list phrases
* if not self.__tree.UseWordAlignment():
* self.__tree.GetTargetCandidates(fphrase, rv[0]) # <<<<<<<<<<<<<<
@@ -1988,21 +2591,21 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
*/
__pyx_v_self->__pyx___tree->GetTargetCandidates(__pyx_v_fphrase, (__pyx_v_rv[0]));
- /* "binpt.pyx":118
+ /* "binpt.pyx":139
* if not self.__tree.UseWordAlignment():
* self.__tree.GetTargetCandidates(fphrase, rv[0])
* phrases = [get_query_result(rv[0][i]) for i in range(rv.size())] # <<<<<<<<<<<<<<
* else:
* wa = new vector[string]()
*/
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_6 = __pyx_v_rv->size();
for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
__pyx_v_i = __pyx_t_7;
- __pyx_t_1 = ((PyObject *)__pyx_f_5binpt_get_query_result(((__pyx_v_rv[0])[__pyx_v_i]), NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = ((PyObject *)__pyx_f_5binpt_get_query_result(((__pyx_v_rv[0])[__pyx_v_i]), NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
}
__Pyx_INCREF(((PyObject *)__pyx_t_2));
@@ -2012,7 +2615,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
}
/*else*/ {
- /* "binpt.pyx":120
+ /* "binpt.pyx":141
* phrases = [get_query_result(rv[0][i]) for i in range(rv.size())]
* else:
* wa = new vector[string]() # <<<<<<<<<<<<<<
@@ -2021,7 +2624,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
*/
__pyx_v_wa = new std::vector<std::string>();
- /* "binpt.pyx":121
+ /* "binpt.pyx":142
* else:
* wa = new vector[string]()
* self.__tree.GetTargetCandidates(fphrase, rv[0], wa[0]) # <<<<<<<<<<<<<<
@@ -2030,33 +2633,33 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
*/
__pyx_v_self->__pyx___tree->GetTargetCandidates(__pyx_v_fphrase, (__pyx_v_rv[0]), (__pyx_v_wa[0]));
- /* "binpt.pyx":122
+ /* "binpt.pyx":143
* wa = new vector[string]()
* self.__tree.GetTargetCandidates(fphrase, rv[0], wa[0])
* phrases = [get_query_result(rv[0][i], wa[0][i].c_str()) for i in range(rv.size())] # <<<<<<<<<<<<<<
* del wa
* del rv
*/
- __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_6 = __pyx_v_rv->size();
for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
__pyx_v_i = __pyx_t_7;
- __pyx_t_1 = PyBytes_FromString(((__pyx_v_wa[0])[__pyx_v_i]).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyBytes_FromString(((__pyx_v_wa[0])[__pyx_v_i]).c_str()); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
__pyx_t_9.__pyx_n = 1;
__pyx_t_9.wa = ((PyObject *)__pyx_t_1);
- __pyx_t_8 = ((PyObject *)__pyx_f_5binpt_get_query_result(((__pyx_v_rv[0])[__pyx_v_i]), &__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_8 = ((PyObject *)__pyx_f_5binpt_get_query_result(((__pyx_v_rv[0])[__pyx_v_i]), &__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
- if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (unlikely(PyList_Append(__pyx_t_2, (PyObject*)__pyx_t_8))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
}
__Pyx_INCREF(((PyObject *)__pyx_t_2));
__pyx_v_phrases = __pyx_t_2;
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- /* "binpt.pyx":123
+ /* "binpt.pyx":144
* self.__tree.GetTargetCandidates(fphrase, rv[0], wa[0])
* phrases = [get_query_result(rv[0][i], wa[0][i].c_str()) for i in range(rv.size())]
* del wa # <<<<<<<<<<<<<<
@@ -2067,7 +2670,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
}
__pyx_L3:;
- /* "binpt.pyx":124
+ /* "binpt.pyx":145
* phrases = [get_query_result(rv[0][i], wa[0][i].c_str()) for i in range(rv.size())]
* del wa
* del rv # <<<<<<<<<<<<<<
@@ -2076,7 +2679,7 @@ static PyObject *__pyx_pf_5binpt_17BinaryPhraseTable_12query(struct __pyx_obj_5b
*/
delete __pyx_v_rv;
- /* "binpt.pyx":125
+ /* "binpt.pyx":146
* del wa
* del rv
* return phrases # <<<<<<<<<<<<<<
@@ -2370,11 +2973,12 @@ static int __pyx_tp_clear_5binpt_BinaryPhraseTable(PyObject *o) {
}
static PyMethodDef __pyx_methods_5binpt_BinaryPhraseTable[] = {
- {__Pyx_NAMESTR("path"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_5path, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("nscores"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_7nscores, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("wa"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_9wa, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("delimiter"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_11delimiter, METH_NOARGS, __Pyx_DOCSTR(0)},
- {__Pyx_NAMESTR("query"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_13query, METH_O, __Pyx_DOCSTR(__pyx_doc_5binpt_17BinaryPhraseTable_12query)},
+ {__Pyx_NAMESTR("isValidBinaryTable"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_5isValidBinaryTable, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_5binpt_17BinaryPhraseTable_4isValidBinaryTable)},
+ {__Pyx_NAMESTR("path"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_7path, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("nscores"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_9nscores, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("wa"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_11wa, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("delimiter"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_13delimiter, METH_NOARGS, __Pyx_DOCSTR(0)},
+ {__Pyx_NAMESTR("query"), (PyCFunction)__pyx_pw_5binpt_17BinaryPhraseTable_15query, METH_O, __Pyx_DOCSTR(__pyx_doc_5binpt_17BinaryPhraseTable_14query)},
{0, 0, 0, 0}
};
@@ -2552,28 +3156,46 @@ static struct PyModuleDef __pyx_moduledef = {
static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
+ {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
+ {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
+ {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
+ {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
+ {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
{&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
{&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
{&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
+ {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
+ {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
+ {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
+ {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
{&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
+ {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
{&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
{&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
+ {&__pyx_n_s__binpt, __pyx_k__binpt, sizeof(__pyx_k__binpt), 0, 0, 1, 1},
{&__pyx_n_s__delimiter, __pyx_k__delimiter, sizeof(__pyx_k__delimiter), 0, 0, 1, 1},
{&__pyx_n_s__encode, __pyx_k__encode, sizeof(__pyx_k__encode), 0, 0, 1, 1},
+ {&__pyx_n_s__isValidBinaryTable, __pyx_k__isValidBinaryTable, sizeof(__pyx_k__isValidBinaryTable), 0, 0, 1, 1},
+ {&__pyx_n_s__isfile, __pyx_k__isfile, sizeof(__pyx_k__isfile), 0, 0, 1, 1},
{&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
{&__pyx_n_s__nscores, __pyx_k__nscores, sizeof(__pyx_k__nscores), 0, 0, 1, 1},
+ {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
{&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
{&__pyx_n_s__property, __pyx_k__property, sizeof(__pyx_k__property), 0, 0, 1, 1},
{&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
{&__pyx_n_s__scores, __pyx_k__scores, sizeof(__pyx_k__scores), 0, 0, 1, 1},
+ {&__pyx_n_s__staticmethod, __pyx_k__staticmethod, sizeof(__pyx_k__staticmethod), 0, 0, 1, 1},
+ {&__pyx_n_s__stem, __pyx_k__stem, sizeof(__pyx_k__stem), 0, 0, 1, 1},
{&__pyx_n_s__wa, __pyx_k__wa, sizeof(__pyx_k__wa), 0, 0, 1, 1},
{&__pyx_n_s__words, __pyx_k__words, sizeof(__pyx_k__words), 0, 0, 1, 1},
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
- __pyx_builtin_property = __Pyx_GetName(__pyx_b, __pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_property = __Pyx_GetName(__pyx_b, __pyx_n_s__property); if (!__pyx_builtin_property) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_staticmethod = __Pyx_GetName(__pyx_b, __pyx_n_s__staticmethod); if (!__pyx_builtin_staticmethod) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;
__pyx_L1_error:;
return -1;
@@ -2583,19 +3205,37 @@ static int __Pyx_InitCachedConstants(void) {
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
- /* "binpt.pyx":8
+ /* "binpt.pyx":9
* return data
* elif isinstance(data, unicode):
* return data.encode('UTF-8') # <<<<<<<<<<<<<<
* raise TypeError('Cannot convert %s to string' % type(data))
*
*/
- __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_k_tuple_2 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_k_tuple_2);
__Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
PyTuple_SET_ITEM(__pyx_k_tuple_2, 0, ((PyObject *)__pyx_kp_s_1));
__Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
__Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_2));
+
+ /* "binpt.pyx":97
+ *
+ * @staticmethod
+ * def isValidBinaryTable(stem, bint wa = False): # <<<<<<<<<<<<<<
+ * '''This sanity check was added to the constructor, but you can access it from outside this class
+ * to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ */
+ __pyx_k_tuple_14 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_k_tuple_14);
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__stem));
+ PyTuple_SET_ITEM(__pyx_k_tuple_14, 0, ((PyObject *)__pyx_n_s__stem));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__stem));
+ __Pyx_INCREF(((PyObject *)__pyx_n_s__wa));
+ PyTuple_SET_ITEM(__pyx_k_tuple_14, 1, ((PyObject *)__pyx_n_s__wa));
+ __Pyx_GIVEREF(((PyObject *)__pyx_n_s__wa));
+ __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));
+ __pyx_k_codeobj_15 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_14, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_16, __pyx_n_s__isValidBinaryTable, 97, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_RefNannyFinishContext();
return 0;
__pyx_L1_error:;
@@ -2676,176 +3316,230 @@ PyMODINIT_FUNC PyInit_binpt(void)
/*--- Variable export code ---*/
/*--- Function export code ---*/
/*--- Type init code ---*/
- if (PyType_Ready(&__pyx_type_5binpt_QueryResult) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5binpt_QueryResult) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
{
- PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5binpt_QueryResult, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5binpt_QueryResult, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
__pyx_wrapperbase_5binpt_11QueryResult_8__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
__pyx_wrapperbase_5binpt_11QueryResult_8__str__.doc = __pyx_doc_5binpt_11QueryResult_8__str__;
((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5binpt_11QueryResult_8__str__;
}
}
- if (__Pyx_SetAttrString(__pyx_m, "QueryResult", (PyObject *)&__pyx_type_5binpt_QueryResult) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "QueryResult", (PyObject *)&__pyx_type_5binpt_QueryResult) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5binpt_QueryResult = &__pyx_type_5binpt_QueryResult;
- if (PyType_Ready(&__pyx_type_5binpt_BinaryPhraseTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
- if (__Pyx_SetAttrString(__pyx_m, "BinaryPhraseTable", (PyObject *)&__pyx_type_5binpt_BinaryPhraseTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyType_Ready(&__pyx_type_5binpt_BinaryPhraseTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (__Pyx_SetAttrString(__pyx_m, "BinaryPhraseTable", (PyObject *)&__pyx_type_5binpt_BinaryPhraseTable) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_ptype_5binpt_BinaryPhraseTable = &__pyx_type_5binpt_BinaryPhraseTable;
/*--- Type import code ---*/
/*--- Variable import code ---*/
/*--- Function import code ---*/
/*--- Execution code ---*/
- /* "binpt.pyx":31
+ /* "binpt.pyx":3
+ * from libcpp.string cimport string
+ * from libcpp.vector cimport vector
+ * import os # <<<<<<<<<<<<<<
+ *
+ * cdef bytes as_str(data):
+ */
+ __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+ /* "binpt.pyx":32
*
* @property
* def words(self): # <<<<<<<<<<<<<<
* '''Tuple of words (as strings)'''
* return self._words
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_QueryResult, __pyx_n_s__words); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_QueryResult, __pyx_n_s__words); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_QueryResult->tp_dict, __pyx_n_s__words, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_QueryResult->tp_dict, __pyx_n_s__words, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_QueryResult);
- /* "binpt.pyx":36
+ /* "binpt.pyx":37
*
* @property
* def scores(self): # <<<<<<<<<<<<<<
* '''Tuple of scores (as floats)'''
* return self._scores
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_QueryResult, __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_QueryResult, __pyx_n_s__scores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_QueryResult->tp_dict, __pyx_n_s__scores, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_QueryResult->tp_dict, __pyx_n_s__scores, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_QueryResult);
- /* "binpt.pyx":41
+ /* "binpt.pyx":42
*
* @property
* def wa(self): # <<<<<<<<<<<<<<
* '''Word-alignment info (as string)'''
* return self._wa
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_QueryResult, __pyx_n_s__wa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_QueryResult, __pyx_n_s__wa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_QueryResult->tp_dict, __pyx_n_s__wa, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_QueryResult->tp_dict, __pyx_n_s__wa, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_QueryResult);
- /* "binpt.pyx":93
+ /* "binpt.pyx":97
+ *
+ * @staticmethod
+ * def isValidBinaryTable(stem, bint wa = False): # <<<<<<<<<<<<<<
+ * '''This sanity check was added to the constructor, but you can access it from outside this class
+ * to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ */
+ __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_5binpt_17BinaryPhraseTable_5isValidBinaryTable, NULL, __pyx_n_s__binpt); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__isValidBinaryTable, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ PyType_Modified(__pyx_ptype_5binpt_BinaryPhraseTable);
+
+ /* "binpt.pyx":96
+ * del self.__tree
+ *
+ * @staticmethod # <<<<<<<<<<<<<<
+ * def isValidBinaryTable(stem, bint wa = False):
+ * '''This sanity check was added to the constructor, but you can access it from outside this class
+ */
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__isValidBinaryTable); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_2);
+ PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+ __Pyx_GIVEREF(__pyx_t_1);
+ __pyx_t_1 = 0;
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_staticmethod, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_GOTREF(__pyx_t_1);
+ __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__isValidBinaryTable, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+ PyType_Modified(__pyx_ptype_5binpt_BinaryPhraseTable);
+
+ /* "binpt.pyx":114
*
* @property
* def path(self): # <<<<<<<<<<<<<<
* return self._path
*
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__path); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__path, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__path, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_BinaryPhraseTable);
- /* "binpt.pyx":97
+ /* "binpt.pyx":118
*
* @property
* def nscores(self): # <<<<<<<<<<<<<<
* return self._nscores
*
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__nscores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__nscores); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__nscores, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__nscores, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_BinaryPhraseTable);
- /* "binpt.pyx":101
+ /* "binpt.pyx":122
*
* @property
* def wa(self): # <<<<<<<<<<<<<<
* return self._wa
*
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__wa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__wa); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__wa, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__wa, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_BinaryPhraseTable);
- /* "binpt.pyx":105
+ /* "binpt.pyx":126
*
* @property
* def delimiter(self): # <<<<<<<<<<<<<<
* return self._delimiter
*
*/
- __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__delimiter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = __Pyx_GetName((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable, __pyx_n_s__delimiter); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
- __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
__Pyx_GIVEREF(__pyx_t_1);
__pyx_t_1 = 0;
- __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_1 = PyObject_Call(__pyx_builtin_property, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
- if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__delimiter, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ if (PyDict_SetItem((PyObject *)__pyx_ptype_5binpt_BinaryPhraseTable->tp_dict, __pyx_n_s__delimiter, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
PyType_Modified(__pyx_ptype_5binpt_BinaryPhraseTable);
/* "binpt.pyx":1
* from libcpp.string cimport string # <<<<<<<<<<<<<<
* from libcpp.vector cimport vector
- *
+ * import os
*/
__pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_1));
@@ -3170,6 +3864,75 @@ bad:
return -1;
}
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, long level) {
+ PyObject *py_import = 0;
+ PyObject *empty_list = 0;
+ PyObject *module = 0;
+ PyObject *global_dict = 0;
+ PyObject *empty_dict = 0;
+ PyObject *list;
+ py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
+ if (!py_import)
+ goto bad;
+ if (from_list)
+ list = from_list;
+ else {
+ empty_list = PyList_New(0);
+ if (!empty_list)
+ goto bad;
+ list = empty_list;
+ }
+ global_dict = PyModule_GetDict(__pyx_m);
+ if (!global_dict)
+ goto bad;
+ empty_dict = PyDict_New();
+ if (!empty_dict)
+ goto bad;
+ #if PY_VERSION_HEX >= 0x02050000
+ {
+ #if PY_MAJOR_VERSION >= 3
+ if (level == -1) {
+ if (strchr(__Pyx_MODULE_NAME, '.')) {
+ /* try package relative import first */
+ PyObject *py_level = PyInt_FromLong(1);
+ if (!py_level)
+ goto bad;
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, py_level, NULL);
+ Py_DECREF(py_level);
+ if (!module) {
+ if (!PyErr_ExceptionMatches(PyExc_ImportError))
+ goto bad;
+ PyErr_Clear();
+ }
+ }
+ level = 0; /* try absolute import on failure */
+ }
+ #endif
+ if (!module) {
+ PyObject *py_level = PyInt_FromLong(level);
+ if (!py_level)
+ goto bad;
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, py_level, NULL);
+ Py_DECREF(py_level);
+ }
+ }
+ #else
+ if (level>0) {
+ PyErr_SetString(PyExc_RuntimeError, "Relative import is not supported for Python <=2.4.");
+ goto bad;
+ }
+ module = PyObject_CallFunctionObjArgs(py_import,
+ name, global_dict, empty_dict, list, NULL);
+ #endif
+bad:
+ Py_XDECREF(empty_list);
+ Py_XDECREF(py_import);
+ Py_XDECREF(empty_dict);
+ return module;
+}
+
static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
const int is_unsigned = neg_one > const_zero;
diff --git a/contrib/python/binpt/binpt.pyx b/contrib/python/binpt/binpt.pyx
index 84c0f7366..0f8d06c42 100644
--- a/contrib/python/binpt/binpt.pyx
+++ b/contrib/python/binpt/binpt.pyx
@@ -1,5 +1,6 @@
from libcpp.string cimport string
from libcpp.vector cimport vector
+import os
cdef bytes as_str(data):
if isinstance(data, bytes):
@@ -78,6 +79,9 @@ cdef class BinaryPhraseTable(object):
Moses::PhraseDictionaryTree also needs to be aware of the number of scores (usually 5),
and whether or not there is word-alignment info in the table (usually not).
One can also specify the token delimiter, for Moses::Tokenize(text, delimiter), which is one space by default.'''
+
+ if not BinaryPhraseTable.isValidBinaryTable(path, wa):
+ raise ValueError, "'%s' doesn't seem a valid binary table." % path
self._path = path
self._nscores = nscores
self._wa = wa
@@ -89,6 +93,23 @@ cdef class BinaryPhraseTable(object):
def __dealloc__(self):
del self.__tree
+ @staticmethod
+ def isValidBinaryTable(stem, bint wa = False):
+ '''This sanity check was added to the constructor, but you can access it from outside this class
+ to determine whether or not you are providing a valid stem to BinaryPhraseTable.'''
+ if wa:
+ return os.path.isfile(stem + ".binphr.idx") \
+ and os.path.isfile(stem + ".binphr.srctree.wa") \
+ and os.path.isfile(stem + ".binphr.srcvoc") \
+ and os.path.isfile(stem + ".binphr.tgtdata.wa") \
+ and os.path.isfile(stem + ".binphr.tgtvoc")
+ else:
+ return os.path.isfile(stem + ".binphr.idx") \
+ and os.path.isfile(stem + ".binphr.srctree") \
+ and os.path.isfile(stem + ".binphr.srcvoc") \
+ and os.path.isfile(stem + ".binphr.tgtdata") \
+ and os.path.isfile(stem + ".binphr.tgtvoc")
+
@property
def path(self):
return self._path
diff --git a/contrib/python/examples/phrase-table.binphr.idx b/contrib/python/examples/phrase-table.binphr.idx
new file mode 100644
index 000000000..58adc514e
--- /dev/null
+++ b/contrib/python/examples/phrase-table.binphr.idx
Binary files differ
diff --git a/contrib/python/examples/phrase-table.binphr.srctree.wa b/contrib/python/examples/phrase-table.binphr.srctree.wa
new file mode 100644
index 000000000..a6da5e1bf
--- /dev/null
+++ b/contrib/python/examples/phrase-table.binphr.srctree.wa
Binary files differ
diff --git a/contrib/python/examples/phrase-table.binphr.srcvoc b/contrib/python/examples/phrase-table.binphr.srcvoc
new file mode 100644
index 000000000..d8656e003
--- /dev/null
+++ b/contrib/python/examples/phrase-table.binphr.srcvoc
@@ -0,0 +1,2 @@
+1 essa
+0 casa
diff --git a/contrib/python/examples/phrase-table.binphr.tgtdata.wa b/contrib/python/examples/phrase-table.binphr.tgtdata.wa
new file mode 100644
index 000000000..592874362
--- /dev/null
+++ b/contrib/python/examples/phrase-table.binphr.tgtdata.wa
Binary files differ
diff --git a/contrib/python/examples/phrase-table.binphr.tgtvoc b/contrib/python/examples/phrase-table.binphr.tgtvoc
new file mode 100644
index 000000000..71975c3c5
--- /dev/null
+++ b/contrib/python/examples/phrase-table.binphr.tgtvoc
@@ -0,0 +1,4 @@
+3 this
+2 location
+1 house
+0 building
diff --git a/contrib/python/examples/phrase-table.txt b/contrib/python/examples/phrase-table.txt
new file mode 100644
index 000000000..1b2a2630a
--- /dev/null
+++ b/contrib/python/examples/phrase-table.txt
@@ -0,0 +1,4 @@
+casa ||| building ||| 0.6 0.75 0.35 0.35 2.718 ||| 0-0 ||| 2 2
+casa ||| house ||| 0.7 0.75 0.35 0.35 2.718 ||| 0-0 ||| 2 2
+casa ||| location ||| 0.5 0.75 0.35 0.35 2.718 ||| 0-0 ||| 2 2
+essa casa ||| this house ||| 0.7 0.5 0.8 0.6 2.718 ||| 0-0 1-1 ||| 2 2
diff --git a/contrib/python/setup.py b/contrib/python/setup.py
index e211e0f34..66042fbc8 100644
--- a/contrib/python/setup.py
+++ b/contrib/python/setup.py
@@ -1,9 +1,15 @@
from distutils.core import setup
from distutils.extension import Extension
import os
+import sys
-#### Check if you agree with these settings
-with_cmph = True
+available_switches = ['--with-cmph']
+with_cmph = False
+
+while sys.argv[-1] in available_switches:
+ switch = sys.argv.pop()
+ if switch == '--with-cmph':
+ with_cmph = True
#### From here you probably don't need to change anything