mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 10:26:35 +03:00
* Move context functions to header, inlining them.
This commit is contained in:
parent
91e8d9ea1c
commit
5fe5e6e66b
|
@ -46,4 +46,19 @@ cpdef enum:
|
||||||
N_FIELDS
|
N_FIELDS
|
||||||
|
|
||||||
|
|
||||||
cdef int fill_context(atom_t[N_FIELDS] context, const int i, TokenC* tokens) except -1
|
cdef inline void fill_context(atom_t* context, const int i, const TokenC* tokens) nogil:
|
||||||
|
_fill_from_token(&context[P2_sic], &tokens[i-2])
|
||||||
|
_fill_from_token(&context[P1_sic], &tokens[i-1])
|
||||||
|
_fill_from_token(&context[W_sic], &tokens[i])
|
||||||
|
_fill_from_token(&context[N1_sic], &tokens[i+1])
|
||||||
|
_fill_from_token(&context[N2_sic], &tokens[i+2])
|
||||||
|
|
||||||
|
|
||||||
|
cdef inline void _fill_from_token(atom_t* context, const TokenC* t) nogil:
|
||||||
|
context[0] = t.lex.sic
|
||||||
|
context[1] = t.lex.cluster
|
||||||
|
context[2] = t.lex.shape
|
||||||
|
context[3] = t.lex.prefix
|
||||||
|
context[4] = t.lex.suffix
|
||||||
|
context[5] = t.pos
|
||||||
|
context[6] = t.sense
|
||||||
|
|
|
@ -1,16 +1 @@
|
||||||
cdef int fill_context(atom_t[N_FIELDS] context, const int i, TokenC* tokens) except -1:
|
|
||||||
_fill_from_token(&context[P2_sic], &tokens[i-2])
|
|
||||||
_fill_from_token(&context[P1_sic], &tokens[i-1])
|
|
||||||
_fill_from_token(&context[W_sic], &tokens[i])
|
|
||||||
_fill_from_token(&context[N1_sic], &tokens[i+1])
|
|
||||||
_fill_from_token(&context[N2_sic], &tokens[i+2])
|
|
||||||
|
|
||||||
|
|
||||||
cdef inline void _fill_from_token(atom_t[N_FIELDS] context, const TokenC* t) nogil:
|
|
||||||
context[0] = t.lex.sic
|
|
||||||
context[1] = t.lex.cluster
|
|
||||||
context[2] = t.lex.shape
|
|
||||||
context[3] = t.lex.prefix
|
|
||||||
context[4] = t.lex.suffix
|
|
||||||
context[5] = t.pos
|
|
||||||
context[6] = t.sense
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user