2015-06-08 23:39:54 +00:00
|
|
|
from libc.string cimport memcpy, memset
|
|
|
|
|
|
|
|
from cymem.cymem cimport Pool
|
|
|
|
|
2015-06-09 19:20:14 +00:00
|
|
|
from ..structs cimport TokenC
|
2015-06-08 23:39:54 +00:00
|
|
|
|
2015-06-09 19:20:14 +00:00
|
|
|
from ._state cimport State
|
2015-06-08 23:39:54 +00:00
|
|
|
|
2015-06-09 19:20:14 +00:00
|
|
|
from ..vocab cimport EMPTY_LEXEME
|
2015-06-08 23:39:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
cdef class StateClass:
|
|
|
|
cdef Pool mem
|
|
|
|
cdef int* _stack
|
|
|
|
cdef int* _buffer
|
|
|
|
cdef TokenC* _sent
|
2015-06-09 19:20:14 +00:00
|
|
|
cdef TokenC _empty_token
|
2015-06-08 23:39:54 +00:00
|
|
|
cdef int length
|
|
|
|
cdef int _s_i
|
|
|
|
cdef int _b_i
|
|
|
|
|
2015-06-09 19:20:14 +00:00
|
|
|
cdef int from_struct(self, const State* state) except -1
|
2015-06-08 23:39:54 +00:00
|
|
|
|
|
|
|
cdef int S(self, int i) nogil
|
|
|
|
cdef int B(self, int i) nogil
|
|
|
|
|
|
|
|
cdef int H(self, int i) nogil
|
|
|
|
|
|
|
|
cdef int L(self, int i, int idx) nogil
|
|
|
|
cdef int R(self, int i, int idx) nogil
|
|
|
|
|
2015-06-09 19:20:14 +00:00
|
|
|
cdef const TokenC* S_(self, int i) nogil
|
|
|
|
cdef const TokenC* B_(self, int i) nogil
|
|
|
|
|
|
|
|
cdef const TokenC* H_(self, int i) nogil
|
|
|
|
|
|
|
|
cdef const TokenC* L_(self, int i, int idx) nogil
|
|
|
|
cdef const TokenC* R_(self, int i, int idx) nogil
|
|
|
|
|
|
|
|
cdef const TokenC* safe_get(self, int i) nogil
|
|
|
|
|
2015-06-08 23:39:54 +00:00
|
|
|
cdef bint empty(self) nogil
|
|
|
|
|
|
|
|
cdef bint eol(self) nogil
|
|
|
|
|
|
|
|
cdef bint is_final(self) nogil
|
|
|
|
|
|
|
|
cdef bint has_head(self, int i) nogil
|
|
|
|
|
2015-06-09 19:20:14 +00:00
|
|
|
cdef int n_L(self, int i) nogil
|
|
|
|
|
|
|
|
cdef int n_R(self, int i) nogil
|
|
|
|
|
2015-06-08 23:39:54 +00:00
|
|
|
cdef bint stack_is_connected(self) nogil
|
|
|
|
|
|
|
|
cdef int stack_depth(self) nogil
|
|
|
|
|
|
|
|
cdef int buffer_length(self) nogil
|
|
|
|
|
|
|
|
cdef void push(self) nogil
|
|
|
|
|
|
|
|
cdef void pop(self) nogil
|
|
|
|
|
|
|
|
cdef void add_arc(self, int head, int child, int label) nogil
|
|
|
|
|
|
|
|
cdef void del_arc(self, int head, int child) nogil
|
|
|
|
|
|
|
|
cdef void set_sent_end(self, int i) nogil
|
|
|
|
|
|
|
|
cdef void clone(self, StateClass src) nogil
|
|
|
|
|
|
|
|
|