* Work on greedy parsing. Scoring about 91.2

This commit is contained in:
Matthew Honnibal 2014-12-18 02:42:55 +11:00
parent 87e9487d76
commit 4448a840f7
8 changed files with 539 additions and 229 deletions

View File

@ -459,9 +459,9 @@ static const char *__pyx_f[] = {
"spacy/utf8string.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/bool.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/complex.pxd",
"cache.pxd",
"features.pxd",
"learner.pxd",
".env/lib/python2.7/site-packages/thinc/cache.pxd",
".env/lib/python2.7/site-packages/thinc/features.pxd",
".env/lib/python2.7/site-packages/thinc/learner.pxd",
"spacy/tagger.pxd",
"spacy/morphology.pxd",
"spacy/lang.pxd",
@ -2363,6 +2363,7 @@ static CYTHON_INLINE struct __pyx_t_5spacy_6tokens_TokenC *__pyx_f_5spacy_6synta
static struct __pyx_t_5spacy_6tokens_TokenC const *(*__pyx_f_5spacy_6syntax_6_state_get_right)(struct __pyx_t_5spacy_6syntax_6_state_State const *, struct __pyx_t_5spacy_6tokens_TokenC const *, int const ); /*proto*/
static struct __pyx_t_5spacy_6tokens_TokenC const *(*__pyx_f_5spacy_6syntax_6_state_get_left)(struct __pyx_t_5spacy_6syntax_6_state_State const *, struct __pyx_t_5spacy_6tokens_TokenC const *, int const ); /*proto*/
static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_at_eol(struct __pyx_t_5spacy_6syntax_6_state_State const *); /*proto*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__popcount(uint32_t); /*proto*/
/* Module declarations from 'spacy.syntax._parse_features' */
static CYTHON_INLINE void __pyx_f_5spacy_6syntax_15_parse_features_fill_token(__pyx_t_5thinc_8typedefs_atom_t *, struct __pyx_t_5spacy_6tokens_TokenC const *); /*proto*/
@ -3576,7 +3577,150 @@ static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_is_final(struct __pyx_t_
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":83
/* "spacy/syntax/_state.pxd":82
*
*
* cdef inline int count_left_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.l_kids)
*
*/
static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_count_left_kids(struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_v_head) {
int __pyx_r;
/* "spacy/syntax/_state.pxd":83
*
* cdef inline int count_left_kids(const TokenC* head) nogil:
* return _popcount(head.l_kids) # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_f_5spacy_6syntax_6_state__popcount(__pyx_v_head->l_kids);
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":82
*
*
* cdef inline int count_left_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.l_kids)
*
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":86
*
*
* cdef inline int count_right_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.r_kids)
*
*/
static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_count_right_kids(struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_v_head) {
int __pyx_r;
/* "spacy/syntax/_state.pxd":87
*
* cdef inline int count_right_kids(const TokenC* head) nogil:
* return _popcount(head.r_kids) # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_f_5spacy_6syntax_6_state__popcount(__pyx_v_head->r_kids);
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":86
*
*
* cdef inline int count_right_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.r_kids)
*
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":91
*
* # From https://en.wikipedia.org/wiki/Hamming_weight
* cdef inline uint32_t _popcount(uint32_t x) nogil: # <<<<<<<<<<<<<<
* """Find number of non-zero bits."""
* cdef int count = 0
*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__popcount(uint32_t __pyx_v_x) {
int __pyx_v_count;
uint32_t __pyx_r;
int __pyx_t_1;
/* "spacy/syntax/_state.pxd":93
* cdef inline uint32_t _popcount(uint32_t x) nogil:
* """Find number of non-zero bits."""
* cdef int count = 0 # <<<<<<<<<<<<<<
* while x != 0:
* x &= x - 1
*/
__pyx_v_count = 0;
/* "spacy/syntax/_state.pxd":94
* """Find number of non-zero bits."""
* cdef int count = 0
* while x != 0: # <<<<<<<<<<<<<<
* x &= x - 1
* count += 1
*/
while (1) {
__pyx_t_1 = ((__pyx_v_x != 0) != 0);
if (!__pyx_t_1) break;
/* "spacy/syntax/_state.pxd":95
* cdef int count = 0
* while x != 0:
* x &= x - 1 # <<<<<<<<<<<<<<
* count += 1
* return count
*/
__pyx_v_x = (__pyx_v_x & (__pyx_v_x - 1));
/* "spacy/syntax/_state.pxd":96
* while x != 0:
* x &= x - 1
* count += 1 # <<<<<<<<<<<<<<
* return count
*
*/
__pyx_v_count = (__pyx_v_count + 1);
}
/* "spacy/syntax/_state.pxd":97
* x &= x - 1
* count += 1
* return count # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_count;
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":91
*
* # From https://en.wikipedia.org/wiki/Hamming_weight
* cdef inline uint32_t _popcount(uint32_t x) nogil: # <<<<<<<<<<<<<<
* """Find number of non-zero bits."""
* cdef int count = 0
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":100
*
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
@ -3590,7 +3734,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
int __pyx_t_1;
int __pyx_t_2;
/* "spacy/syntax/_state.pxd":85
/* "spacy/syntax/_state.pxd":102
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil:
* cdef int i
* for i in range(32): # <<<<<<<<<<<<<<
@ -3600,7 +3744,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
for (__pyx_t_1 = 0; __pyx_t_1 < 32; __pyx_t_1+=1) {
__pyx_v_i = __pyx_t_1;
/* "spacy/syntax/_state.pxd":86
/* "spacy/syntax/_state.pxd":103
* cdef int i
* for i in range(32):
* if bits & (1 << i): # <<<<<<<<<<<<<<
@ -3610,7 +3754,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_t_2 = ((__pyx_v_bits & (1 << __pyx_v_i)) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pxd":87
/* "spacy/syntax/_state.pxd":104
* for i in range(32):
* if bits & (1 << i):
* n -= 1 # <<<<<<<<<<<<<<
@ -3619,7 +3763,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
*/
__pyx_v_n = (__pyx_v_n - 1);
/* "spacy/syntax/_state.pxd":88
/* "spacy/syntax/_state.pxd":105
* if bits & (1 << i):
* n -= 1
* if n < 1: # <<<<<<<<<<<<<<
@ -3629,7 +3773,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_t_2 = ((__pyx_v_n < 1) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pxd":89
/* "spacy/syntax/_state.pxd":106
* n -= 1
* if n < 1:
* return i # <<<<<<<<<<<<<<
@ -3643,7 +3787,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_L5:;
}
/* "spacy/syntax/_state.pxd":90
/* "spacy/syntax/_state.pxd":107
* if n < 1:
* return i
* return 0 # <<<<<<<<<<<<<<
@ -3651,7 +3795,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_r = 0;
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":83
/* "spacy/syntax/_state.pxd":100
*
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
@ -6076,7 +6220,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;

View File

@ -459,9 +459,9 @@ static const char *__pyx_f[] = {
"spacy/utf8string.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/bool.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/complex.pxd",
"cache.pxd",
"features.pxd",
"learner.pxd",
".env/lib/python2.7/site-packages/thinc/cache.pxd",
".env/lib/python2.7/site-packages/thinc/features.pxd",
".env/lib/python2.7/site-packages/thinc/learner.pxd",
"spacy/tagger.pxd",
"spacy/morphology.pxd",
"spacy/lang.pxd",
@ -2227,6 +2227,7 @@ static PyTypeObject *__pyx_ptype_5spacy_6tokens_Token = 0;
/* Module declarations from 'spacy.syntax._state' */
static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_at_eol(struct __pyx_t_5spacy_6syntax_6_state_State const *); /*proto*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__popcount(uint32_t); /*proto*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bit(uint32_t, int); /*proto*/
#define __Pyx_MODULE_NAME "spacy.syntax._state"
int __pyx_module_is_main_spacy__syntax___state = 0;
@ -2291,11 +2292,12 @@ static PyObject *__pyx_tuple__6;
*
*
* cdef int add_dep(State *s, int head, int child, int label) except -1: # <<<<<<<<<<<<<<
* s.sent[child].head = head - child
* s.sent[child].dep_tag = label
* cdef int dist = head - child
* s.sent[child].head = dist
*/
static int __pyx_f_5spacy_6syntax_6_state_add_dep(struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_v_s, int __pyx_v_head, int __pyx_v_child, int __pyx_v_label) {
int __pyx_v_dist;
int __pyx_r;
__Pyx_RefNannyDeclarations
int __pyx_t_1;
@ -2307,53 +2309,62 @@ static int __pyx_f_5spacy_6syntax_6_state_add_dep(struct __pyx_t_5spacy_6syntax_
/* "spacy/syntax/_state.pyx":9
*
* cdef int add_dep(State *s, int head, int child, int label) except -1:
* s.sent[child].head = head - child # <<<<<<<<<<<<<<
* cdef int dist = head - child # <<<<<<<<<<<<<<
* s.sent[child].head = dist
* s.sent[child].dep_tag = label
* # Keep a bit-vector tracking child dependencies. If a word has a child at
*/
(__pyx_v_s->sent[__pyx_v_child]).head = (__pyx_v_head - __pyx_v_child);
__pyx_v_dist = (__pyx_v_head - __pyx_v_child);
/* "spacy/syntax/_state.pyx":10
* cdef int add_dep(State *s, int head, int child, int label) except -1:
* s.sent[child].head = head - child
* cdef int dist = head - child
* s.sent[child].head = dist # <<<<<<<<<<<<<<
* s.sent[child].dep_tag = label
* # Keep a bit-vector tracking child dependencies. If a word has a child at
*/
(__pyx_v_s->sent[__pyx_v_child]).head = __pyx_v_dist;
/* "spacy/syntax/_state.pyx":11
* cdef int dist = head - child
* s.sent[child].head = dist
* s.sent[child].dep_tag = label # <<<<<<<<<<<<<<
* # Keep a bit-vector tracking child dependencies. If a word has a child at
* # offset i from it, set that bit (tracking left and right separately)
*/
(__pyx_v_s->sent[__pyx_v_child]).dep_tag = __pyx_v_label;
/* "spacy/syntax/_state.pyx":13
/* "spacy/syntax/_state.pyx":14
* # Keep a bit-vector tracking child dependencies. If a word has a child at
* # offset i from it, set that bit (tracking left and right separately)
* if child > head: # <<<<<<<<<<<<<<
* s.sent[head].r_kids |= 1 << (-s.sent[child].head)
* s.sent[head].r_kids |= 1 << (-dist)
* else:
*/
__pyx_t_1 = ((__pyx_v_child > __pyx_v_head) != 0);
if (__pyx_t_1) {
/* "spacy/syntax/_state.pyx":14
/* "spacy/syntax/_state.pyx":15
* # offset i from it, set that bit (tracking left and right separately)
* if child > head:
* s.sent[head].r_kids |= 1 << (-s.sent[child].head) # <<<<<<<<<<<<<<
* s.sent[head].r_kids |= 1 << (-dist) # <<<<<<<<<<<<<<
* else:
* s.sent[head].l_kids |= 1 << s.sent[child].head
* s.sent[head].l_kids |= 1 << dist
*/
__pyx_t_2 = __pyx_v_head;
(__pyx_v_s->sent[__pyx_t_2]).r_kids = ((__pyx_v_s->sent[__pyx_t_2]).r_kids | (1 << (-(__pyx_v_s->sent[__pyx_v_child]).head)));
(__pyx_v_s->sent[__pyx_t_2]).r_kids = ((__pyx_v_s->sent[__pyx_t_2]).r_kids | (1 << (-__pyx_v_dist)));
goto __pyx_L3;
}
/*else*/ {
/* "spacy/syntax/_state.pyx":16
* s.sent[head].r_kids |= 1 << (-s.sent[child].head)
/* "spacy/syntax/_state.pyx":17
* s.sent[head].r_kids |= 1 << (-dist)
* else:
* s.sent[head].l_kids |= 1 << s.sent[child].head # <<<<<<<<<<<<<<
* s.sent[head].l_kids |= 1 << dist # <<<<<<<<<<<<<<
*
*
*/
__pyx_t_2 = __pyx_v_head;
(__pyx_v_s->sent[__pyx_t_2]).l_kids = ((__pyx_v_s->sent[__pyx_t_2]).l_kids | (1 << (__pyx_v_s->sent[__pyx_v_child]).head));
(__pyx_v_s->sent[__pyx_t_2]).l_kids = ((__pyx_v_s->sent[__pyx_t_2]).l_kids | (1 << __pyx_v_dist));
}
__pyx_L3:;
@ -2361,8 +2372,8 @@ static int __pyx_f_5spacy_6syntax_6_state_add_dep(struct __pyx_t_5spacy_6syntax_
*
*
* cdef int add_dep(State *s, int head, int child, int label) except -1: # <<<<<<<<<<<<<<
* s.sent[child].head = head - child
* s.sent[child].dep_tag = label
* cdef int dist = head - child
* s.sent[child].head = dist
*/
/* function exit code */
@ -2372,7 +2383,7 @@ static int __pyx_f_5spacy_6syntax_6_state_add_dep(struct __pyx_t_5spacy_6syntax_
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":19
/* "spacy/syntax/_state.pyx":20
*
*
* cdef int pop_stack(State *s) except -1: # <<<<<<<<<<<<<<
@ -2388,9 +2399,9 @@ static int __pyx_f_5spacy_6syntax_6_state_pop_stack(struct __pyx_t_5spacy_6synta
int __pyx_clineno = 0;
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("pop_stack", 0);
__Pyx_TraceCall("pop_stack", __pyx_f[1], 19);
__Pyx_TraceCall("pop_stack", __pyx_f[1], 20);
/* "spacy/syntax/_state.pyx":20
/* "spacy/syntax/_state.pyx":21
*
* cdef int pop_stack(State *s) except -1:
* assert s.stack_len >= 1 # <<<<<<<<<<<<<<
@ -2401,12 +2412,12 @@ static int __pyx_f_5spacy_6syntax_6_state_pop_stack(struct __pyx_t_5spacy_6synta
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_v_s->stack_len >= 1) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "spacy/syntax/_state.pyx":21
/* "spacy/syntax/_state.pyx":22
* cdef int pop_stack(State *s) except -1:
* assert s.stack_len >= 1
* s.stack_len -= 1 # <<<<<<<<<<<<<<
@ -2415,7 +2426,7 @@ static int __pyx_f_5spacy_6syntax_6_state_pop_stack(struct __pyx_t_5spacy_6synta
*/
__pyx_v_s->stack_len = (__pyx_v_s->stack_len - 1);
/* "spacy/syntax/_state.pyx":22
/* "spacy/syntax/_state.pyx":23
* assert s.stack_len >= 1
* s.stack_len -= 1
* s.stack -= 1 # <<<<<<<<<<<<<<
@ -2424,7 +2435,7 @@ static int __pyx_f_5spacy_6syntax_6_state_pop_stack(struct __pyx_t_5spacy_6synta
*/
__pyx_v_s->stack = (__pyx_v_s->stack - 1);
/* "spacy/syntax/_state.pyx":19
/* "spacy/syntax/_state.pyx":20
*
*
* cdef int pop_stack(State *s) except -1: # <<<<<<<<<<<<<<
@ -2444,7 +2455,7 @@ static int __pyx_f_5spacy_6syntax_6_state_pop_stack(struct __pyx_t_5spacy_6synta
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":25
/* "spacy/syntax/_state.pyx":26
*
*
* cdef int push_stack(State *s) except -1: # <<<<<<<<<<<<<<
@ -2461,9 +2472,9 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
int __pyx_clineno = 0;
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("push_stack", 0);
__Pyx_TraceCall("push_stack", __pyx_f[1], 25);
__Pyx_TraceCall("push_stack", __pyx_f[1], 26);
/* "spacy/syntax/_state.pyx":26
/* "spacy/syntax/_state.pyx":27
*
* cdef int push_stack(State *s) except -1:
* assert s.i < s.sent_len # <<<<<<<<<<<<<<
@ -2474,12 +2485,12 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!((__pyx_v_s->i < __pyx_v_s->sent_len) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "spacy/syntax/_state.pyx":27
/* "spacy/syntax/_state.pyx":28
* cdef int push_stack(State *s) except -1:
* assert s.i < s.sent_len
* s.stack += 1 # <<<<<<<<<<<<<<
@ -2488,7 +2499,7 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
*/
__pyx_v_s->stack = (__pyx_v_s->stack + 1);
/* "spacy/syntax/_state.pyx":28
/* "spacy/syntax/_state.pyx":29
* assert s.i < s.sent_len
* s.stack += 1
* s.stack[0] = s.i # <<<<<<<<<<<<<<
@ -2498,7 +2509,7 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
__pyx_t_1 = __pyx_v_s->i;
(__pyx_v_s->stack[0]) = __pyx_t_1;
/* "spacy/syntax/_state.pyx":29
/* "spacy/syntax/_state.pyx":30
* s.stack += 1
* s.stack[0] = s.i
* s.stack_len += 1 # <<<<<<<<<<<<<<
@ -2507,7 +2518,7 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
*/
__pyx_v_s->stack_len = (__pyx_v_s->stack_len + 1);
/* "spacy/syntax/_state.pyx":30
/* "spacy/syntax/_state.pyx":31
* s.stack[0] = s.i
* s.stack_len += 1
* s.i += 1 # <<<<<<<<<<<<<<
@ -2516,7 +2527,7 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
*/
__pyx_v_s->i = (__pyx_v_s->i + 1);
/* "spacy/syntax/_state.pyx":25
/* "spacy/syntax/_state.pyx":26
*
*
* cdef int push_stack(State *s) except -1: # <<<<<<<<<<<<<<
@ -2536,7 +2547,7 @@ static int __pyx_f_5spacy_6syntax_6_state_push_stack(struct __pyx_t_5spacy_6synt
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":33
/* "spacy/syntax/_state.pyx":34
*
*
* cdef int children_in_buffer(const State *s, int head, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2554,9 +2565,9 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
int __pyx_t_3;
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("children_in_buffer", 0);
__Pyx_TraceCall("children_in_buffer", __pyx_f[1], 33);
__Pyx_TraceCall("children_in_buffer", __pyx_f[1], 34);
/* "spacy/syntax/_state.pyx":38
/* "spacy/syntax/_state.pyx":39
* # our target
* cdef int i
* cdef int n = 0 # <<<<<<<<<<<<<<
@ -2565,7 +2576,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
*/
__pyx_v_n = 0;
/* "spacy/syntax/_state.pyx":39
/* "spacy/syntax/_state.pyx":40
* cdef int i
* cdef int n = 0
* for i in range(s.i, s.sent_len): # <<<<<<<<<<<<<<
@ -2576,7 +2587,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
for (__pyx_t_2 = __pyx_v_s->i; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
/* "spacy/syntax/_state.pyx":40
/* "spacy/syntax/_state.pyx":41
* cdef int n = 0
* for i in range(s.i, s.sent_len):
* if gold[i] == head: # <<<<<<<<<<<<<<
@ -2586,7 +2597,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
__pyx_t_3 = (((__pyx_v_gold[__pyx_v_i]) == __pyx_v_head) != 0);
if (__pyx_t_3) {
/* "spacy/syntax/_state.pyx":41
/* "spacy/syntax/_state.pyx":42
* for i in range(s.i, s.sent_len):
* if gold[i] == head:
* n += 1 # <<<<<<<<<<<<<<
@ -2599,7 +2610,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
__pyx_L5:;
}
/* "spacy/syntax/_state.pyx":42
/* "spacy/syntax/_state.pyx":43
* if gold[i] == head:
* n += 1
* return n # <<<<<<<<<<<<<<
@ -2609,7 +2620,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
__pyx_r = __pyx_v_n;
goto __pyx_L0;
/* "spacy/syntax/_state.pyx":33
/* "spacy/syntax/_state.pyx":34
*
*
* cdef int children_in_buffer(const State *s, int head, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2624,7 +2635,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_buffer(struct __pyx_t_5spa
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":45
/* "spacy/syntax/_state.pyx":46
*
*
* cdef int head_in_buffer(const State *s, const int child, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2637,9 +2648,9 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_buffer(struct __pyx_t_5spacy_6
__Pyx_RefNannyDeclarations
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("head_in_buffer", 0);
__Pyx_TraceCall("head_in_buffer", __pyx_f[1], 45);
__Pyx_TraceCall("head_in_buffer", __pyx_f[1], 46);
/* "spacy/syntax/_state.pyx":46
/* "spacy/syntax/_state.pyx":47
*
* cdef int head_in_buffer(const State *s, const int child, int* gold) except -1:
* return gold[child] >= s.i # <<<<<<<<<<<<<<
@ -2649,7 +2660,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_buffer(struct __pyx_t_5spacy_6
__pyx_r = ((__pyx_v_gold[__pyx_v_child]) >= __pyx_v_s->i);
goto __pyx_L0;
/* "spacy/syntax/_state.pyx":45
/* "spacy/syntax/_state.pyx":46
*
*
* cdef int head_in_buffer(const State *s, const int child, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2664,7 +2675,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_buffer(struct __pyx_t_5spacy_6
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":49
/* "spacy/syntax/_state.pyx":50
*
*
* cdef int children_in_stack(const State *s, const int head, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2682,9 +2693,9 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
int __pyx_t_3;
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("children_in_stack", 0);
__Pyx_TraceCall("children_in_stack", __pyx_f[1], 49);
__Pyx_TraceCall("children_in_stack", __pyx_f[1], 50);
/* "spacy/syntax/_state.pyx":51
/* "spacy/syntax/_state.pyx":52
* cdef int children_in_stack(const State *s, const int head, int* gold) except -1:
* cdef int i
* cdef int n = 0 # <<<<<<<<<<<<<<
@ -2693,7 +2704,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
*/
__pyx_v_n = 0;
/* "spacy/syntax/_state.pyx":52
/* "spacy/syntax/_state.pyx":53
* cdef int i
* cdef int n = 0
* for i in range(s.stack_len): # <<<<<<<<<<<<<<
@ -2704,7 +2715,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
/* "spacy/syntax/_state.pyx":53
/* "spacy/syntax/_state.pyx":54
* cdef int n = 0
* for i in range(s.stack_len):
* if gold[s.stack[-i]] == head: # <<<<<<<<<<<<<<
@ -2714,7 +2725,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
__pyx_t_3 = (((__pyx_v_gold[(__pyx_v_s->stack[(-__pyx_v_i)])]) == __pyx_v_head) != 0);
if (__pyx_t_3) {
/* "spacy/syntax/_state.pyx":54
/* "spacy/syntax/_state.pyx":55
* for i in range(s.stack_len):
* if gold[s.stack[-i]] == head:
* n += 1 # <<<<<<<<<<<<<<
@ -2727,7 +2738,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
__pyx_L5:;
}
/* "spacy/syntax/_state.pyx":55
/* "spacy/syntax/_state.pyx":56
* if gold[s.stack[-i]] == head:
* n += 1
* return n # <<<<<<<<<<<<<<
@ -2737,7 +2748,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
__pyx_r = __pyx_v_n;
goto __pyx_L0;
/* "spacy/syntax/_state.pyx":49
/* "spacy/syntax/_state.pyx":50
*
*
* cdef int children_in_stack(const State *s, const int head, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2752,7 +2763,7 @@ static int __pyx_f_5spacy_6syntax_6_state_children_in_stack(struct __pyx_t_5spac
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":58
/* "spacy/syntax/_state.pyx":59
*
*
* cdef int head_in_stack(const State *s, const int child, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2769,9 +2780,9 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_stack(struct __pyx_t_5spacy_6s
int __pyx_t_3;
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("head_in_stack", 0);
__Pyx_TraceCall("head_in_stack", __pyx_f[1], 58);
__Pyx_TraceCall("head_in_stack", __pyx_f[1], 59);
/* "spacy/syntax/_state.pyx":60
/* "spacy/syntax/_state.pyx":61
* cdef int head_in_stack(const State *s, const int child, int* gold) except -1:
* cdef int i
* for i in range(s.stack_len): # <<<<<<<<<<<<<<
@ -2782,7 +2793,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_stack(struct __pyx_t_5spacy_6s
for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
/* "spacy/syntax/_state.pyx":61
/* "spacy/syntax/_state.pyx":62
* cdef int i
* for i in range(s.stack_len):
* if gold[child] == s.stack[-i]: # <<<<<<<<<<<<<<
@ -2792,7 +2803,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_stack(struct __pyx_t_5spacy_6s
__pyx_t_3 = (((__pyx_v_gold[__pyx_v_child]) == (__pyx_v_s->stack[(-__pyx_v_i)])) != 0);
if (__pyx_t_3) {
/* "spacy/syntax/_state.pyx":62
/* "spacy/syntax/_state.pyx":63
* for i in range(s.stack_len):
* if gold[child] == s.stack[-i]:
* return 1 # <<<<<<<<<<<<<<
@ -2804,7 +2815,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_stack(struct __pyx_t_5spacy_6s
}
}
/* "spacy/syntax/_state.pyx":63
/* "spacy/syntax/_state.pyx":64
* if gold[child] == s.stack[-i]:
* return 1
* return 0 # <<<<<<<<<<<<<<
@ -2814,7 +2825,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_stack(struct __pyx_t_5spacy_6s
__pyx_r = 0;
goto __pyx_L0;
/* "spacy/syntax/_state.pyx":58
/* "spacy/syntax/_state.pyx":59
*
*
* cdef int head_in_stack(const State *s, const int child, int* gold) except -1: # <<<<<<<<<<<<<<
@ -2829,7 +2840,7 @@ static int __pyx_f_5spacy_6syntax_6_state_head_in_stack(struct __pyx_t_5spacy_6s
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":66
/* "spacy/syntax/_state.pyx":67
*
*
* cdef const TokenC* get_left(const State* s, const TokenC* head, const int idx) nogil: # <<<<<<<<<<<<<<
@ -2845,7 +2856,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
uint32_t __pyx_t_1;
int __pyx_t_2;
/* "spacy/syntax/_state.pyx":67
/* "spacy/syntax/_state.pyx":68
*
* cdef const TokenC* get_left(const State* s, const TokenC* head, const int idx) nogil:
* cdef uint32_t kids = head.l_kids # <<<<<<<<<<<<<<
@ -2855,7 +2866,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
__pyx_t_1 = __pyx_v_head->l_kids;
__pyx_v_kids = __pyx_t_1;
/* "spacy/syntax/_state.pyx":68
/* "spacy/syntax/_state.pyx":69
* cdef const TokenC* get_left(const State* s, const TokenC* head, const int idx) nogil:
* cdef uint32_t kids = head.l_kids
* if kids == 0: # <<<<<<<<<<<<<<
@ -2865,7 +2876,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
__pyx_t_2 = ((__pyx_v_kids == 0) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pyx":69
/* "spacy/syntax/_state.pyx":70
* cdef uint32_t kids = head.l_kids
* if kids == 0:
* return NULL # <<<<<<<<<<<<<<
@ -2876,7 +2887,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
goto __pyx_L0;
}
/* "spacy/syntax/_state.pyx":70
/* "spacy/syntax/_state.pyx":71
* if kids == 0:
* return NULL
* cdef int offset = _nth_significant_bit(kids, idx) # <<<<<<<<<<<<<<
@ -2885,7 +2896,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
*/
__pyx_v_offset = __pyx_f_5spacy_6syntax_6_state__nth_significant_bit(__pyx_v_kids, __pyx_v_idx);
/* "spacy/syntax/_state.pyx":71
/* "spacy/syntax/_state.pyx":72
* return NULL
* cdef int offset = _nth_significant_bit(kids, idx)
* cdef const TokenC* child = head - offset # <<<<<<<<<<<<<<
@ -2894,7 +2905,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
*/
__pyx_v_child = (__pyx_v_head - __pyx_v_offset);
/* "spacy/syntax/_state.pyx":72
/* "spacy/syntax/_state.pyx":73
* cdef int offset = _nth_significant_bit(kids, idx)
* cdef const TokenC* child = head - offset
* if child >= s.sent: # <<<<<<<<<<<<<<
@ -2904,30 +2915,30 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
__pyx_t_2 = ((__pyx_v_child >= __pyx_v_s->sent) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pyx":73
/* "spacy/syntax/_state.pyx":74
* cdef const TokenC* child = head - offset
* if child >= s.sent:
* return child # <<<<<<<<<<<<<<
* else:
* return s.sent - 1
* return NULL
*/
__pyx_r = __pyx_v_child;
goto __pyx_L0;
}
/*else*/ {
/* "spacy/syntax/_state.pyx":75
/* "spacy/syntax/_state.pyx":76
* return child
* else:
* return s.sent - 1 # <<<<<<<<<<<<<<
* return NULL # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = (__pyx_v_s->sent - 1);
__pyx_r = NULL;
goto __pyx_L0;
}
/* "spacy/syntax/_state.pyx":66
/* "spacy/syntax/_state.pyx":67
*
*
* cdef const TokenC* get_left(const State* s, const TokenC* head, const int idx) nogil: # <<<<<<<<<<<<<<
@ -2940,7 +2951,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":78
/* "spacy/syntax/_state.pyx":79
*
*
* cdef const TokenC* get_right(const State* s, const TokenC* head, const int idx) nogil: # <<<<<<<<<<<<<<
@ -2956,7 +2967,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
uint32_t __pyx_t_1;
int __pyx_t_2;
/* "spacy/syntax/_state.pyx":79
/* "spacy/syntax/_state.pyx":80
*
* cdef const TokenC* get_right(const State* s, const TokenC* head, const int idx) nogil:
* cdef uint32_t kids = head.r_kids # <<<<<<<<<<<<<<
@ -2966,7 +2977,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
__pyx_t_1 = __pyx_v_head->r_kids;
__pyx_v_kids = __pyx_t_1;
/* "spacy/syntax/_state.pyx":80
/* "spacy/syntax/_state.pyx":81
* cdef const TokenC* get_right(const State* s, const TokenC* head, const int idx) nogil:
* cdef uint32_t kids = head.r_kids
* if kids == 0: # <<<<<<<<<<<<<<
@ -2976,7 +2987,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
__pyx_t_2 = ((__pyx_v_kids == 0) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pyx":81
/* "spacy/syntax/_state.pyx":82
* cdef uint32_t kids = head.r_kids
* if kids == 0:
* return NULL # <<<<<<<<<<<<<<
@ -2987,7 +2998,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
goto __pyx_L0;
}
/* "spacy/syntax/_state.pyx":82
/* "spacy/syntax/_state.pyx":83
* if kids == 0:
* return NULL
* cdef int offset = _nth_significant_bit(kids, idx) # <<<<<<<<<<<<<<
@ -2996,7 +3007,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
*/
__pyx_v_offset = __pyx_f_5spacy_6syntax_6_state__nth_significant_bit(__pyx_v_kids, __pyx_v_idx);
/* "spacy/syntax/_state.pyx":83
/* "spacy/syntax/_state.pyx":84
* return NULL
* cdef int offset = _nth_significant_bit(kids, idx)
* cdef const TokenC* child = head + offset # <<<<<<<<<<<<<<
@ -3005,7 +3016,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
*/
__pyx_v_child = (__pyx_v_head + __pyx_v_offset);
/* "spacy/syntax/_state.pyx":84
/* "spacy/syntax/_state.pyx":85
* cdef int offset = _nth_significant_bit(kids, idx)
* cdef const TokenC* child = head + offset
* if child < (s.sent + s.sent_len): # <<<<<<<<<<<<<<
@ -3015,30 +3026,30 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
__pyx_t_2 = ((__pyx_v_child < (__pyx_v_s->sent + __pyx_v_s->sent_len)) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pyx":85
/* "spacy/syntax/_state.pyx":86
* cdef const TokenC* child = head + offset
* if child < (s.sent + s.sent_len):
* return child # <<<<<<<<<<<<<<
* else:
* return s.sent - 1
* return NULL
*/
__pyx_r = __pyx_v_child;
goto __pyx_L0;
}
/*else*/ {
/* "spacy/syntax/_state.pyx":87
/* "spacy/syntax/_state.pyx":88
* return child
* else:
* return s.sent - 1 # <<<<<<<<<<<<<<
* return NULL # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = (__pyx_v_s->sent - 1);
__pyx_r = NULL;
goto __pyx_L0;
}
/* "spacy/syntax/_state.pyx":78
/* "spacy/syntax/_state.pyx":79
*
*
* cdef const TokenC* get_right(const State* s, const TokenC* head, const int idx) nogil: # <<<<<<<<<<<<<<
@ -3051,7 +3062,7 @@ static struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_f_5spacy_6syntax_6_stat
return __pyx_r;
}
/* "spacy/syntax/_state.pyx":93
/* "spacy/syntax/_state.pyx":94
*
*
* cdef State* init_state(Pool mem, TokenC* sent, const int sent_length) except NULL: # <<<<<<<<<<<<<<
@ -3072,9 +3083,9 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
int __pyx_clineno = 0;
__Pyx_TraceDeclarations
__Pyx_RefNannySetupContext("init_state", 0);
__Pyx_TraceCall("init_state", __pyx_f[1], 93);
__Pyx_TraceCall("init_state", __pyx_f[1], 94);
/* "spacy/syntax/_state.pyx":94
/* "spacy/syntax/_state.pyx":95
*
* cdef State* init_state(Pool mem, TokenC* sent, const int sent_length) except NULL:
* cdef int padded_len = sent_length + PADDING + PADDING # <<<<<<<<<<<<<<
@ -3083,27 +3094,27 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
*/
__pyx_v_padded_len = ((__pyx_v_sent_length + 5) + 5);
/* "spacy/syntax/_state.pyx":95
/* "spacy/syntax/_state.pyx":96
* cdef State* init_state(Pool mem, TokenC* sent, const int sent_length) except NULL:
* cdef int padded_len = sent_length + PADDING + PADDING
* cdef State* s = <State*>mem.alloc(1, sizeof(State)) # <<<<<<<<<<<<<<
* s.stack = <int*>mem.alloc(padded_len, sizeof(int))
* for i in range(PADDING):
*/
__pyx_t_1 = ((struct __pyx_vtabstruct_5cymem_5cymem_Pool *)__pyx_v_mem->__pyx_vtab)->alloc(__pyx_v_mem, 1, (sizeof(struct __pyx_t_5spacy_6syntax_6_state_State))); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = ((struct __pyx_vtabstruct_5cymem_5cymem_Pool *)__pyx_v_mem->__pyx_vtab)->alloc(__pyx_v_mem, 1, (sizeof(struct __pyx_t_5spacy_6syntax_6_state_State))); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_s = ((struct __pyx_t_5spacy_6syntax_6_state_State *)__pyx_t_1);
/* "spacy/syntax/_state.pyx":96
/* "spacy/syntax/_state.pyx":97
* cdef int padded_len = sent_length + PADDING + PADDING
* cdef State* s = <State*>mem.alloc(1, sizeof(State))
* s.stack = <int*>mem.alloc(padded_len, sizeof(int)) # <<<<<<<<<<<<<<
* for i in range(PADDING):
* s.stack[i] = -1
*/
__pyx_t_1 = ((struct __pyx_vtabstruct_5cymem_5cymem_Pool *)__pyx_v_mem->__pyx_vtab)->alloc(__pyx_v_mem, __pyx_v_padded_len, (sizeof(int))); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_1 = ((struct __pyx_vtabstruct_5cymem_5cymem_Pool *)__pyx_v_mem->__pyx_vtab)->alloc(__pyx_v_mem, __pyx_v_padded_len, (sizeof(int))); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_v_s->stack = ((int *)__pyx_t_1);
/* "spacy/syntax/_state.pyx":97
/* "spacy/syntax/_state.pyx":98
* cdef State* s = <State*>mem.alloc(1, sizeof(State))
* s.stack = <int*>mem.alloc(padded_len, sizeof(int))
* for i in range(PADDING): # <<<<<<<<<<<<<<
@ -3113,7 +3124,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
for (__pyx_t_2 = 0; __pyx_t_2 < 5; __pyx_t_2+=1) {
__pyx_v_i = __pyx_t_2;
/* "spacy/syntax/_state.pyx":98
/* "spacy/syntax/_state.pyx":99
* s.stack = <int*>mem.alloc(padded_len, sizeof(int))
* for i in range(PADDING):
* s.stack[i] = -1 # <<<<<<<<<<<<<<
@ -3123,7 +3134,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
(__pyx_v_s->stack[__pyx_v_i]) = -1;
}
/* "spacy/syntax/_state.pyx":99
/* "spacy/syntax/_state.pyx":100
* for i in range(PADDING):
* s.stack[i] = -1
* s.stack += (PADDING - 1) # <<<<<<<<<<<<<<
@ -3132,7 +3143,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
*/
__pyx_v_s->stack = (__pyx_v_s->stack + 4);
/* "spacy/syntax/_state.pyx":100
/* "spacy/syntax/_state.pyx":101
* s.stack[i] = -1
* s.stack += (PADDING - 1)
* assert s.stack[0] == -1 # <<<<<<<<<<<<<<
@ -3143,12 +3154,12 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
if (unlikely(!Py_OptimizeFlag)) {
if (unlikely(!(((__pyx_v_s->stack[0]) == -1) != 0))) {
PyErr_SetNone(PyExc_AssertionError);
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
{__pyx_filename = __pyx_f[1]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
}
}
#endif
/* "spacy/syntax/_state.pyx":101
/* "spacy/syntax/_state.pyx":102
* s.stack += (PADDING - 1)
* assert s.stack[0] == -1
* s.sent = sent # <<<<<<<<<<<<<<
@ -3157,7 +3168,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
*/
__pyx_v_s->sent = __pyx_v_sent;
/* "spacy/syntax/_state.pyx":102
/* "spacy/syntax/_state.pyx":103
* assert s.stack[0] == -1
* s.sent = sent
* s.stack_len = 0 # <<<<<<<<<<<<<<
@ -3166,7 +3177,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
*/
__pyx_v_s->stack_len = 0;
/* "spacy/syntax/_state.pyx":103
/* "spacy/syntax/_state.pyx":104
* s.sent = sent
* s.stack_len = 0
* s.i = 0 # <<<<<<<<<<<<<<
@ -3175,7 +3186,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
*/
__pyx_v_s->i = 0;
/* "spacy/syntax/_state.pyx":104
/* "spacy/syntax/_state.pyx":105
* s.stack_len = 0
* s.i = 0
* s.sent_len = sent_length # <<<<<<<<<<<<<<
@ -3183,7 +3194,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
*/
__pyx_v_s->sent_len = __pyx_v_sent_length;
/* "spacy/syntax/_state.pyx":105
/* "spacy/syntax/_state.pyx":106
* s.i = 0
* s.sent_len = sent_length
* return s # <<<<<<<<<<<<<<
@ -3191,7 +3202,7 @@ static struct __pyx_t_5spacy_6syntax_6_state_State *__pyx_f_5spacy_6syntax_6_sta
__pyx_r = __pyx_v_s;
goto __pyx_L0;
/* "spacy/syntax/_state.pyx":93
/* "spacy/syntax/_state.pyx":94
*
*
* cdef State* init_state(Pool mem, TokenC* sent, const int sent_length) except NULL: # <<<<<<<<<<<<<<
@ -3597,7 +3608,150 @@ static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_is_final(struct __pyx_t_
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":83
/* "spacy/syntax/_state.pxd":82
*
*
* cdef inline int count_left_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.l_kids)
*
*/
static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_count_left_kids(struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_v_head) {
int __pyx_r;
/* "spacy/syntax/_state.pxd":83
*
* cdef inline int count_left_kids(const TokenC* head) nogil:
* return _popcount(head.l_kids) # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_f_5spacy_6syntax_6_state__popcount(__pyx_v_head->l_kids);
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":82
*
*
* cdef inline int count_left_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.l_kids)
*
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":86
*
*
* cdef inline int count_right_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.r_kids)
*
*/
static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_count_right_kids(struct __pyx_t_5spacy_6tokens_TokenC const *__pyx_v_head) {
int __pyx_r;
/* "spacy/syntax/_state.pxd":87
*
* cdef inline int count_right_kids(const TokenC* head) nogil:
* return _popcount(head.r_kids) # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_f_5spacy_6syntax_6_state__popcount(__pyx_v_head->r_kids);
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":86
*
*
* cdef inline int count_right_kids(const TokenC* head) nogil: # <<<<<<<<<<<<<<
* return _popcount(head.r_kids)
*
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":91
*
* # From https://en.wikipedia.org/wiki/Hamming_weight
* cdef inline uint32_t _popcount(uint32_t x) nogil: # <<<<<<<<<<<<<<
* """Find number of non-zero bits."""
* cdef int count = 0
*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__popcount(uint32_t __pyx_v_x) {
int __pyx_v_count;
uint32_t __pyx_r;
int __pyx_t_1;
/* "spacy/syntax/_state.pxd":93
* cdef inline uint32_t _popcount(uint32_t x) nogil:
* """Find number of non-zero bits."""
* cdef int count = 0 # <<<<<<<<<<<<<<
* while x != 0:
* x &= x - 1
*/
__pyx_v_count = 0;
/* "spacy/syntax/_state.pxd":94
* """Find number of non-zero bits."""
* cdef int count = 0
* while x != 0: # <<<<<<<<<<<<<<
* x &= x - 1
* count += 1
*/
while (1) {
__pyx_t_1 = ((__pyx_v_x != 0) != 0);
if (!__pyx_t_1) break;
/* "spacy/syntax/_state.pxd":95
* cdef int count = 0
* while x != 0:
* x &= x - 1 # <<<<<<<<<<<<<<
* count += 1
* return count
*/
__pyx_v_x = (__pyx_v_x & (__pyx_v_x - 1));
/* "spacy/syntax/_state.pxd":96
* while x != 0:
* x &= x - 1
* count += 1 # <<<<<<<<<<<<<<
* return count
*
*/
__pyx_v_count = (__pyx_v_count + 1);
}
/* "spacy/syntax/_state.pxd":97
* x &= x - 1
* count += 1
* return count # <<<<<<<<<<<<<<
*
*
*/
__pyx_r = __pyx_v_count;
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":91
*
* # From https://en.wikipedia.org/wiki/Hamming_weight
* cdef inline uint32_t _popcount(uint32_t x) nogil: # <<<<<<<<<<<<<<
* """Find number of non-zero bits."""
* cdef int count = 0
*/
/* function exit code */
__pyx_L0:;
return __pyx_r;
}
/* "spacy/syntax/_state.pxd":100
*
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
@ -3611,7 +3765,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
int __pyx_t_1;
int __pyx_t_2;
/* "spacy/syntax/_state.pxd":85
/* "spacy/syntax/_state.pxd":102
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil:
* cdef int i
* for i in range(32): # <<<<<<<<<<<<<<
@ -3621,7 +3775,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
for (__pyx_t_1 = 0; __pyx_t_1 < 32; __pyx_t_1+=1) {
__pyx_v_i = __pyx_t_1;
/* "spacy/syntax/_state.pxd":86
/* "spacy/syntax/_state.pxd":103
* cdef int i
* for i in range(32):
* if bits & (1 << i): # <<<<<<<<<<<<<<
@ -3631,7 +3785,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_t_2 = ((__pyx_v_bits & (1 << __pyx_v_i)) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pxd":87
/* "spacy/syntax/_state.pxd":104
* for i in range(32):
* if bits & (1 << i):
* n -= 1 # <<<<<<<<<<<<<<
@ -3640,7 +3794,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
*/
__pyx_v_n = (__pyx_v_n - 1);
/* "spacy/syntax/_state.pxd":88
/* "spacy/syntax/_state.pxd":105
* if bits & (1 << i):
* n -= 1
* if n < 1: # <<<<<<<<<<<<<<
@ -3650,7 +3804,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_t_2 = ((__pyx_v_n < 1) != 0);
if (__pyx_t_2) {
/* "spacy/syntax/_state.pxd":89
/* "spacy/syntax/_state.pxd":106
* n -= 1
* if n < 1:
* return i # <<<<<<<<<<<<<<
@ -3664,7 +3818,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_L5:;
}
/* "spacy/syntax/_state.pxd":90
/* "spacy/syntax/_state.pxd":107
* if n < 1:
* return i
* return 0 # <<<<<<<<<<<<<<
@ -3672,7 +3826,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
__pyx_r = 0;
goto __pyx_L0;
/* "spacy/syntax/_state.pxd":83
/* "spacy/syntax/_state.pxd":100
*
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
@ -6079,7 +6233,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{0, 0, 0, 0, 0, 0, 0}
};
static int __Pyx_InitCachedBuiltins(void) {
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
return 0;

View File

@ -79,6 +79,23 @@ cdef int head_in_stack(const State *s, const int child, int* gold) except -1
cdef State* init_state(Pool mem, TokenC* sent, const int sent_length) except NULL
cdef inline int count_left_kids(const TokenC* head) nogil:
return _popcount(head.l_kids)
cdef inline int count_right_kids(const TokenC* head) nogil:
return _popcount(head.r_kids)
# From https://en.wikipedia.org/wiki/Hamming_weight
cdef inline uint32_t _popcount(uint32_t x) nogil:
"""Find number of non-zero bits."""
cdef int count = 0
while x != 0:
x &= x - 1
count += 1
return count
cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil:
cdef int i

View File

@ -6,14 +6,15 @@ from ..lexeme cimport EMPTY_LEXEME
cdef int add_dep(State *s, int head, int child, int label) except -1:
s.sent[child].head = head - child
cdef int dist = head - child
s.sent[child].head = dist
s.sent[child].dep_tag = label
# Keep a bit-vector tracking child dependencies. If a word has a child at
# offset i from it, set that bit (tracking left and right separately)
if child > head:
s.sent[head].r_kids |= 1 << (-s.sent[child].head)
s.sent[head].r_kids |= 1 << (-dist)
else:
s.sent[head].l_kids |= 1 << s.sent[child].head
s.sent[head].l_kids |= 1 << dist
cdef int pop_stack(State *s) except -1:
@ -72,7 +73,7 @@ cdef const TokenC* get_left(const State* s, const TokenC* head, const int idx) n
if child >= s.sent:
return child
else:
return s.sent - 1
return NULL
cdef const TokenC* get_right(const State* s, const TokenC* head, const int idx) nogil:
@ -84,7 +85,7 @@ cdef const TokenC* get_right(const State* s, const TokenC* head, const int idx)
if child < (s.sent + s.sent_len):
return child
else:
return s.sent - 1
return NULL
DEF PADDING = 5

View File

@ -459,9 +459,9 @@ static const char *__pyx_f[] = {
"spacy/utf8string.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/bool.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/complex.pxd",
"cache.pxd",
"features.pxd",
"learner.pxd",
".env/lib/python2.7/site-packages/thinc/cache.pxd",
".env/lib/python2.7/site-packages/thinc/features.pxd",
".env/lib/python2.7/site-packages/thinc/learner.pxd",
"spacy/tagger.pxd",
"spacy/morphology.pxd",
"spacy/lang.pxd",
@ -3975,8 +3975,8 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
int __pyx_t_2;
int __pyx_t_3;
int __pyx_t_4;
PyObject *__pyx_t_5 = NULL;
int __pyx_t_6;
int __pyx_t_5;
PyObject *__pyx_t_6 = NULL;
PyObject *__pyx_t_7 = NULL;
PyObject *__pyx_t_8 = NULL;
PyObject *__pyx_t_9 = NULL;
@ -4111,7 +4111,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* else:
* cost = 0
* elif move == RIGHT: # <<<<<<<<<<<<<<
* if gold_heads[s.i] == s.stack[0]:
* if gold_heads[s.i] == s.stack[0] and gold_labels[s.i] != -1:
* cost = label != gold_labels[s.i]
*/
switch (__pyx_v_move) {
@ -4131,7 +4131,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* if move == SHIFT or move == REDUCE:
* cost = 0 # <<<<<<<<<<<<<<
* elif move == LEFT:
* if gold_heads[s.stack[0]] == s.i:
* if gold_heads[s.stack[0]] == s.i and gold_labels[s.stack[0]] != -1:
*/
__pyx_v_cost = 0;
break;
@ -4140,7 +4140,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* if move == SHIFT or move == REDUCE:
* cost = 0
* elif move == LEFT: # <<<<<<<<<<<<<<
* if gold_heads[s.stack[0]] == s.i:
* if gold_heads[s.stack[0]] == s.i and gold_labels[s.stack[0]] != -1:
* cost = label != gold_labels[s.stack[0]]
*/
case __pyx_e_5spacy_6syntax_9arc_eager_LEFT:
@ -4148,16 +4148,24 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
/* "spacy/syntax/arc_eager.pyx":154
* cost = 0
* elif move == LEFT:
* if gold_heads[s.stack[0]] == s.i: # <<<<<<<<<<<<<<
* if gold_heads[s.stack[0]] == s.i and gold_labels[s.stack[0]] != -1: # <<<<<<<<<<<<<<
* cost = label != gold_labels[s.stack[0]]
* else:
*/
__pyx_t_4 = (((__pyx_v_gold_heads[(__pyx_v_s->stack[0])]) == __pyx_v_s->i) != 0);
__pyx_t_5 = (((__pyx_v_gold_heads[(__pyx_v_s->stack[0])]) == __pyx_v_s->i) != 0);
if (__pyx_t_5) {
} else {
__pyx_t_4 = __pyx_t_5;
goto __pyx_L7_bool_binop_done;
}
__pyx_t_5 = (((__pyx_v_gold_labels[(__pyx_v_s->stack[0])]) != -1) != 0);
__pyx_t_4 = __pyx_t_5;
__pyx_L7_bool_binop_done:;
if (__pyx_t_4) {
/* "spacy/syntax/arc_eager.pyx":155
* elif move == LEFT:
* if gold_heads[s.stack[0]] == s.i:
* if gold_heads[s.stack[0]] == s.i and gold_labels[s.stack[0]] != -1:
* cost = label != gold_labels[s.stack[0]] # <<<<<<<<<<<<<<
* else:
* cost = 0
@ -4172,7 +4180,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* else:
* cost = 0 # <<<<<<<<<<<<<<
* elif move == RIGHT:
* if gold_heads[s.i] == s.stack[0]:
* if gold_heads[s.i] == s.stack[0] and gold_labels[s.i] != -1:
*/
__pyx_v_cost = 0;
}
@ -4183,7 +4191,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* else:
* cost = 0
* elif move == RIGHT: # <<<<<<<<<<<<<<
* if gold_heads[s.i] == s.stack[0]:
* if gold_heads[s.i] == s.stack[0] and gold_labels[s.i] != -1:
* cost = label != gold_labels[s.i]
*/
case __pyx_e_5spacy_6syntax_9arc_eager_RIGHT:
@ -4191,22 +4199,30 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
/* "spacy/syntax/arc_eager.pyx":159
* cost = 0
* elif move == RIGHT:
* if gold_heads[s.i] == s.stack[0]: # <<<<<<<<<<<<<<
* if gold_heads[s.i] == s.stack[0] and gold_labels[s.i] != -1: # <<<<<<<<<<<<<<
* cost = label != gold_labels[s.i]
* else:
*/
__pyx_t_4 = (((__pyx_v_gold_heads[__pyx_v_s->i]) == (__pyx_v_s->stack[0])) != 0);
__pyx_t_5 = (((__pyx_v_gold_heads[__pyx_v_s->i]) == (__pyx_v_s->stack[0])) != 0);
if (__pyx_t_5) {
} else {
__pyx_t_4 = __pyx_t_5;
goto __pyx_L10_bool_binop_done;
}
__pyx_t_5 = (((__pyx_v_gold_labels[__pyx_v_s->i]) != -1) != 0);
__pyx_t_4 = __pyx_t_5;
__pyx_L10_bool_binop_done:;
if (__pyx_t_4) {
/* "spacy/syntax/arc_eager.pyx":160
* elif move == RIGHT:
* if gold_heads[s.i] == s.stack[0]:
* if gold_heads[s.i] == s.stack[0] and gold_labels[s.i] != -1:
* cost = label != gold_labels[s.i] # <<<<<<<<<<<<<<
* else:
* cost = 0
*/
__pyx_v_cost = (__pyx_v_label != (__pyx_v_gold_labels[__pyx_v_s->i]));
goto __pyx_L7;
goto __pyx_L9;
}
/*else*/ {
@ -4219,7 +4235,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
*/
__pyx_v_cost = 0;
}
__pyx_L7:;
__pyx_L9:;
break;
default:
@ -4230,10 +4246,10 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* if cost == 0 and (best == -1 or scores[i] > score):
* best = i
*/
__pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_StandardError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__Pyx_Raise(__pyx_t_5, 0, 0, 0);
__Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
__pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_StandardError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__Pyx_Raise(__pyx_t_6, 0, 0, 0);
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
{__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
break;
}
@ -4245,21 +4261,21 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* best = i
* score = scores[i]
*/
__pyx_t_6 = ((__pyx_v_cost == 0) != 0);
if (__pyx_t_6) {
__pyx_t_5 = ((__pyx_v_cost == 0) != 0);
if (__pyx_t_5) {
} else {
__pyx_t_4 = __pyx_t_6;
goto __pyx_L9_bool_binop_done;
__pyx_t_4 = __pyx_t_5;
goto __pyx_L13_bool_binop_done;
}
__pyx_t_6 = ((__pyx_v_best == -1) != 0);
if (!__pyx_t_6) {
__pyx_t_5 = ((__pyx_v_best == -1) != 0);
if (!__pyx_t_5) {
} else {
__pyx_t_4 = __pyx_t_6;
goto __pyx_L9_bool_binop_done;
__pyx_t_4 = __pyx_t_5;
goto __pyx_L13_bool_binop_done;
}
__pyx_t_6 = (((__pyx_v_scores[__pyx_v_i]) > __pyx_v_score) != 0);
__pyx_t_4 = __pyx_t_6;
__pyx_L9_bool_binop_done:;
__pyx_t_5 = (((__pyx_v_scores[__pyx_v_i]) > __pyx_v_score) != 0);
__pyx_t_4 = __pyx_t_5;
__pyx_L13_bool_binop_done:;
if (__pyx_t_4) {
/* "spacy/syntax/arc_eager.pyx":166
@ -4279,9 +4295,9 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* if best < 0:
*/
__pyx_v_score = (__pyx_v_scores[__pyx_v_i]);
goto __pyx_L8;
goto __pyx_L12;
}
__pyx_L8:;
__pyx_L12:;
goto __pyx_L5;
}
__pyx_L5:;
@ -4304,8 +4320,8 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
* print s.stack_len
* print has_head(get_s0(s))
*/
__pyx_t_5 = __Pyx_PyInt_From_int((__pyx_v_unl_costs[__pyx_e_5spacy_6syntax_9arc_eager_SHIFT])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_5);
__pyx_t_6 = __Pyx_PyInt_From_int((__pyx_v_unl_costs[__pyx_e_5spacy_6syntax_9arc_eager_SHIFT])); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_6);
__pyx_t_7 = __Pyx_PyInt_From_int((__pyx_v_unl_costs[__pyx_e_5spacy_6syntax_9arc_eager_REDUCE])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);
__pyx_t_8 = __Pyx_PyInt_From_int((__pyx_v_unl_costs[__pyx_e_5spacy_6syntax_9arc_eager_LEFT])); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@ -4314,15 +4330,15 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
__Pyx_GOTREF(__pyx_t_9);
__pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_10);
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_5);
__Pyx_GIVEREF(__pyx_t_5);
PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_6);
__Pyx_GIVEREF(__pyx_t_6);
PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_7);
__Pyx_GIVEREF(__pyx_t_7);
PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_8);
__Pyx_GIVEREF(__pyx_t_8);
PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_9);
__Pyx_GIVEREF(__pyx_t_9);
__pyx_t_5 = 0;
__pyx_t_6 = 0;
__pyx_t_7 = 0;
__pyx_t_8 = 0;
__pyx_t_9 = 0;
@ -4475,7 +4491,7 @@ static int __pyx_f_5spacy_6syntax_9arc_eager_16TransitionSystem_best_gold(struct
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_5);
__Pyx_XDECREF(__pyx_t_6);
__Pyx_XDECREF(__pyx_t_7);
__Pyx_XDECREF(__pyx_t_8);
__Pyx_XDECREF(__pyx_t_9);
@ -4931,7 +4947,7 @@ static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_is_final(struct __pyx_t_
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
* cdef int i
* for i in range(32):
* for i in range(33, -1, -1):
*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bit(uint32_t __pyx_v_bits, int __pyx_v_n) {
@ -4943,16 +4959,16 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
/* "spacy/syntax/_state.pxd":85
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil:
* cdef int i
* for i in range(32): # <<<<<<<<<<<<<<
* for i in range(33, -1, -1): # <<<<<<<<<<<<<<
* if bits & (1 << i):
* n -= 1
*/
for (__pyx_t_1 = 0; __pyx_t_1 < 32; __pyx_t_1+=1) {
for (__pyx_t_1 = 33; __pyx_t_1 > -1; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "spacy/syntax/_state.pxd":86
* cdef int i
* for i in range(32):
* for i in range(33, -1, -1):
* if bits & (1 << i): # <<<<<<<<<<<<<<
* n -= 1
* if n < 1:
@ -4961,7 +4977,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
if (__pyx_t_2) {
/* "spacy/syntax/_state.pxd":87
* for i in range(32):
* for i in range(33, -1, -1):
* if bits & (1 << i):
* n -= 1 # <<<<<<<<<<<<<<
* if n < 1:
@ -5006,7 +5022,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
* cdef int i
* for i in range(32):
* for i in range(33, -1, -1):
*/
/* function exit code */

View File

@ -147,16 +147,16 @@ cdef class TransitionSystem:
for i in range(self.n_moves):
move = self._moves[i].move
label = self._moves[i].label
if unl_costs[move] == 0:
if unl_costs[move] == 0:
if move == SHIFT or move == REDUCE:
cost = 0
elif move == LEFT:
if gold_heads[s.stack[0]] == s.i:
if gold_heads[s.stack[0]] == s.i and gold_labels[s.stack[0]] != -1:
cost = label != gold_labels[s.stack[0]]
else:
cost = 0
elif move == RIGHT:
if gold_heads[s.i] == s.stack[0]:
if gold_heads[s.i] == s.stack[0] and gold_labels[s.i] != -1:
cost = label != gold_labels[s.i]
else:
cost = 0

View File

@ -454,10 +454,10 @@ static const char *__pyx_f[] = {
"spacy/syntax/parser.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/numpy/__init__.pxd",
".env/lib/python2.7/site-packages/cymem/cymem.pxd",
"features.pxd",
".env/lib/python2.7/site-packages/thinc/features.pxd",
".env/lib/python2.7/site-packages/preshed/maps.pxd",
"cache.pxd",
"learner.pxd",
".env/lib/python2.7/site-packages/thinc/cache.pxd",
".env/lib/python2.7/site-packages/thinc/learner.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/type.pxd",
"spacy/utf8string.pxd",
".env/lib/python2.7/site-packages/Cython/Includes/cpython/bool.pxd",
@ -2574,12 +2574,10 @@ static char __pyx_k_model_dir[] = "model_dir";
static char __pyx_k_set_debug[] = "set_debug";
static char __pyx_k_ValueError[] = "ValueError";
static char __pyx_k_gold_heads[] = "gold_heads";
static char __pyx_k_label_sets[] = "label_sets";
static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
static char __pyx_k_gold_labels[] = "gold_labels";
static char __pyx_k_left_labels[] = "left_labels";
static char __pyx_k_RuntimeError[] = "RuntimeError";
static char __pyx_k_extra_labels[] = "extra_labels";
static char __pyx_k_right_labels[] = "right_labels";
static char __pyx_k_get_templates[] = "get_templates";
static char __pyx_k_parse_features[] = "_parse_features";
@ -2607,7 +2605,6 @@ static PyObject *__pyx_n_s__9;
static PyObject *__pyx_n_s_arc_eager;
static PyObject *__pyx_n_u_config;
static PyObject *__pyx_n_s_exists;
static PyObject *__pyx_n_s_extra_labels;
static PyObject *__pyx_n_s_features;
static PyObject *__pyx_n_s_get_templates;
static PyObject *__pyx_n_s_gold_heads;
@ -2616,7 +2613,6 @@ static PyObject *__pyx_n_s_import;
static PyObject *__pyx_n_s_isdir;
static PyObject *__pyx_n_s_join;
static PyObject *__pyx_n_s_json;
static PyObject *__pyx_n_s_label_sets;
static PyObject *__pyx_n_s_left_labels;
static PyObject *__pyx_n_s_load;
static PyObject *__pyx_n_s_main;
@ -2885,7 +2881,7 @@ static PyObject *__pyx_f_5spacy_6syntax_6parser_print_state(struct __pyx_t_5spac
*
* def get_templates(name): # <<<<<<<<<<<<<<
* pf = _parse_features
* return pf.arc_eager + pf.extra_labels + pf.label_sets
* return pf.arc_eager
*/
/* Python wrapper */
@ -2907,8 +2903,6 @@ static PyObject *__pyx_pf_5spacy_6syntax_6parser_2get_templates(CYTHON_UNUSED Py
PyObject *__pyx_r = NULL;
__Pyx_RefNannyDeclarations
PyObject *__pyx_t_1 = NULL;
PyObject *__pyx_t_2 = NULL;
PyObject *__pyx_t_3 = NULL;
int __pyx_lineno = 0;
const char *__pyx_filename = NULL;
int __pyx_clineno = 0;
@ -2920,7 +2914,7 @@ static PyObject *__pyx_pf_5spacy_6syntax_6parser_2get_templates(CYTHON_UNUSED Py
*
* def get_templates(name):
* pf = _parse_features # <<<<<<<<<<<<<<
* return pf.arc_eager + pf.extra_labels + pf.label_sets
* return pf.arc_eager
*
*/
__pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_parse_features); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@ -2931,25 +2925,13 @@ static PyObject *__pyx_pf_5spacy_6syntax_6parser_2get_templates(CYTHON_UNUSED Py
/* "spacy/syntax/parser.pyx":52
* def get_templates(name):
* pf = _parse_features
* return pf.arc_eager + pf.extra_labels + pf.label_sets # <<<<<<<<<<<<<<
* return pf.arc_eager # <<<<<<<<<<<<<<
*
*
*/
__Pyx_XDECREF(__pyx_r);
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_pf, __pyx_n_s_arc_eager); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pf, __pyx_n_s_extra_labels); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_3);
__Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_pf, __pyx_n_s_label_sets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
__pyx_t_1 = PyNumber_Add(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_1);
__Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
__Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
__pyx_r = __pyx_t_1;
__pyx_t_1 = 0;
goto __pyx_L0;
@ -2959,14 +2941,12 @@ static PyObject *__pyx_pf_5spacy_6syntax_6parser_2get_templates(CYTHON_UNUSED Py
*
* def get_templates(name): # <<<<<<<<<<<<<<
* pf = _parse_features
* return pf.arc_eager + pf.extra_labels + pf.label_sets
* return pf.arc_eager
*/
/* function exit code */
__pyx_L1_error:;
__Pyx_XDECREF(__pyx_t_1);
__Pyx_XDECREF(__pyx_t_2);
__Pyx_XDECREF(__pyx_t_3);
__Pyx_AddTraceback("spacy.syntax.parser.get_templates", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = NULL;
__pyx_L0:;
@ -3250,7 +3230,7 @@ static int __pyx_pf_5spacy_6syntax_6parser_12GreedyParser___init__(struct __pyx_
* self.extractor = Extractor(get_templates(self.cfg.features))
* self.moves = TransitionSystem(self.cfg.left_labels, self.cfg.right_labels) # <<<<<<<<<<<<<<
*
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ + 10000)
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ)
*/
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->cfg, __pyx_n_s_left_labels); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
@ -3276,13 +3256,13 @@ static int __pyx_pf_5spacy_6syntax_6parser_12GreedyParser___init__(struct __pyx_
/* "spacy/syntax/parser.pyx":62
* self.moves = TransitionSystem(self.cfg.left_labels, self.cfg.right_labels)
*
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ + 10000) # <<<<<<<<<<<<<<
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ) # <<<<<<<<<<<<<<
* if os.path.exists(pjoin(model_dir, 'model')):
* self.model.load(pjoin(model_dir, 'model'))
*/
__pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_self->moves->n_moves); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_4);
__pyx_t_8 = __Pyx_PyInt_From_long((__pyx_v_self->extractor->n_templ + 10000)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_self->extractor->n_templ); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_8);
__pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_2);
@ -3303,7 +3283,7 @@ static int __pyx_pf_5spacy_6syntax_6parser_12GreedyParser___init__(struct __pyx_
/* "spacy/syntax/parser.pyx":63
*
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ + 10000)
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ)
* if os.path.exists(pjoin(model_dir, 'model')): # <<<<<<<<<<<<<<
* self.model.load(pjoin(model_dir, 'model'))
*
@ -3376,7 +3356,7 @@ static int __pyx_pf_5spacy_6syntax_6parser_12GreedyParser___init__(struct __pyx_
if (__pyx_t_1) {
/* "spacy/syntax/parser.pyx":64
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ + 10000)
* self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ)
* if os.path.exists(pjoin(model_dir, 'model')):
* self.model.load(pjoin(model_dir, 'model')) # <<<<<<<<<<<<<<
*
@ -4784,7 +4764,7 @@ static CYTHON_INLINE int __pyx_f_5spacy_6syntax_6_state_is_final(struct __pyx_t_
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
* cdef int i
* for i in range(32):
* for i in range(33, -1, -1):
*/
static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bit(uint32_t __pyx_v_bits, int __pyx_v_n) {
@ -4796,16 +4776,16 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
/* "spacy/syntax/_state.pxd":85
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil:
* cdef int i
* for i in range(32): # <<<<<<<<<<<<<<
* for i in range(33, -1, -1): # <<<<<<<<<<<<<<
* if bits & (1 << i):
* n -= 1
*/
for (__pyx_t_1 = 0; __pyx_t_1 < 32; __pyx_t_1+=1) {
for (__pyx_t_1 = 33; __pyx_t_1 > -1; __pyx_t_1-=1) {
__pyx_v_i = __pyx_t_1;
/* "spacy/syntax/_state.pxd":86
* cdef int i
* for i in range(32):
* for i in range(33, -1, -1):
* if bits & (1 << i): # <<<<<<<<<<<<<<
* n -= 1
* if n < 1:
@ -4814,7 +4794,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
if (__pyx_t_2) {
/* "spacy/syntax/_state.pxd":87
* for i in range(32):
* for i in range(33, -1, -1):
* if bits & (1 << i):
* n -= 1 # <<<<<<<<<<<<<<
* if n < 1:
@ -4859,7 +4839,7 @@ static CYTHON_INLINE uint32_t __pyx_f_5spacy_6syntax_6_state__nth_significant_bi
*
* cdef inline uint32_t _nth_significant_bit(uint32_t bits, int n) nogil: # <<<<<<<<<<<<<<
* cdef int i
* for i in range(32):
* for i in range(33, -1, -1):
*/
/* function exit code */
@ -7402,7 +7382,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_arc_eager, __pyx_k_arc_eager, sizeof(__pyx_k_arc_eager), 0, 0, 1, 1},
{&__pyx_n_u_config, __pyx_k_config, sizeof(__pyx_k_config), 0, 1, 0, 1},
{&__pyx_n_s_exists, __pyx_k_exists, sizeof(__pyx_k_exists), 0, 0, 1, 1},
{&__pyx_n_s_extra_labels, __pyx_k_extra_labels, sizeof(__pyx_k_extra_labels), 0, 0, 1, 1},
{&__pyx_n_s_features, __pyx_k_features, sizeof(__pyx_k_features), 0, 0, 1, 1},
{&__pyx_n_s_get_templates, __pyx_k_get_templates, sizeof(__pyx_k_get_templates), 0, 0, 1, 1},
{&__pyx_n_s_gold_heads, __pyx_k_gold_heads, sizeof(__pyx_k_gold_heads), 0, 0, 1, 1},
@ -7411,7 +7390,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
{&__pyx_n_s_isdir, __pyx_k_isdir, sizeof(__pyx_k_isdir), 0, 0, 1, 1},
{&__pyx_n_s_join, __pyx_k_join, sizeof(__pyx_k_join), 0, 0, 1, 1},
{&__pyx_n_s_json, __pyx_k_json, sizeof(__pyx_k_json), 0, 0, 1, 1},
{&__pyx_n_s_label_sets, __pyx_k_label_sets, sizeof(__pyx_k_label_sets), 0, 0, 1, 1},
{&__pyx_n_s_left_labels, __pyx_k_left_labels, sizeof(__pyx_k_left_labels), 0, 0, 1, 1},
{&__pyx_n_s_load, __pyx_k_load, sizeof(__pyx_k_load), 0, 0, 1, 1},
{&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
@ -7538,7 +7516,7 @@ static int __Pyx_InitCachedConstants(void) {
*
* def get_templates(name): # <<<<<<<<<<<<<<
* pf = _parse_features
* return pf.arc_eager + pf.extra_labels + pf.label_sets
* return pf.arc_eager
*/
__pyx_tuple__12 = PyTuple_Pack(2, __pyx_n_s_name, __pyx_n_s_pf); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_tuple__12);
@ -7854,7 +7832,7 @@ PyMODINIT_FUNC PyInit_parser(void)
*
* def get_templates(name): # <<<<<<<<<<<<<<
* pf = _parse_features
* return pf.arc_eager + pf.extra_labels + pf.label_sets
* return pf.arc_eager
*/
__pyx_t_7 = PyCFunction_NewEx(&__pyx_mdef_5spacy_6syntax_6parser_3get_templates, NULL, __pyx_n_s_spacy_syntax_parser); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(__pyx_t_7);

View File

@ -49,7 +49,7 @@ cdef unicode print_state(State* s, list words):
def get_templates(name):
pf = _parse_features
return pf.arc_eager + pf.extra_labels + pf.label_sets
return pf.arc_eager
cdef class GreedyParser:
@ -59,7 +59,7 @@ cdef class GreedyParser:
self.extractor = Extractor(get_templates(self.cfg.features))
self.moves = TransitionSystem(self.cfg.left_labels, self.cfg.right_labels)
self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ + 10000)
self.model = LinearModel(self.moves.n_moves, self.extractor.n_templ)
if os.path.exists(pjoin(model_dir, 'model')):
self.model.load(pjoin(model_dir, 'model'))
@ -110,7 +110,7 @@ cdef class GreedyParser:
self.moves.transition(state, guess)
cdef int n_corr = 0
for i in range(tokens.length):
n_corr += (i + state.sent[i].head) == gold_heads[i]
n_corr += (i + state.sent[i].head) == heads_array[i]
return n_corr