2015-06-09 02:39:54 +03:00
|
|
|
from libc.string cimport memcpy, memset
|
|
|
|
|
|
|
|
from cymem.cymem cimport Pool
|
2017-05-06 15:22:20 +03:00
|
|
|
cimport cython
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-10 00:23:28 +03:00
|
|
|
from ..structs cimport TokenC, Entity
|
2017-05-28 19:09:27 +03:00
|
|
|
from ..typedefs cimport attr_t
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-09 22:20:14 +03:00
|
|
|
from ..vocab cimport EMPTY_LEXEME
|
2016-02-01 03:16:14 +03:00
|
|
|
from ._state cimport StateC
|
|
|
|
|
2015-06-09 02:39:54 +03:00
|
|
|
|
|
|
|
cdef class StateClass:
|
|
|
|
cdef Pool mem
|
2016-02-01 03:16:14 +03:00
|
|
|
cdef StateC* c
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-10 05:20:23 +03:00
|
|
|
@staticmethod
|
|
|
|
cdef inline StateClass init(const TokenC* sent, int length):
|
2017-05-15 22:46:08 +03:00
|
|
|
cdef StateClass self = StateClass()
|
2016-02-01 03:16:14 +03:00
|
|
|
self.c = new StateC(sent, length)
|
2015-06-10 05:20:23 +03:00
|
|
|
return self
|
|
|
|
|
2017-05-15 22:46:08 +03:00
|
|
|
@staticmethod
|
|
|
|
cdef inline StateClass init_offset(const TokenC* sent, int length, int
|
|
|
|
offset):
|
|
|
|
cdef StateClass self = StateClass()
|
|
|
|
self.c = new StateC(sent, length)
|
|
|
|
self.c.offset = offset
|
|
|
|
return self
|
|
|
|
|
2015-06-10 08:22:33 +03:00
|
|
|
cdef inline int S(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.S(i)
|
2015-06-10 08:22:33 +03:00
|
|
|
|
|
|
|
cdef inline int B(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.B(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* S_(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.S_(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* B_(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.B_(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* H_(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.H_(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* E_(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.E_(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* L_(self, int i, int idx) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.L_(i, idx)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* R_(self, int i, int idx) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.R_(i, idx)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline const TokenC* safe_get(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.safe_get(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
|
|
|
cdef inline int H(self, int i) nogil:
|
2016-02-01 04:22:21 +03:00
|
|
|
return self.c.H(i)
|
2016-02-01 04:37:08 +03:00
|
|
|
|
|
|
|
cdef inline int E(self, int i) nogil:
|
|
|
|
return self.c.E(i)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline int L(self, int i, int idx) nogil:
|
|
|
|
return self.c.L(i, idx)
|
2015-06-29 02:06:28 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline int R(self, int i, int idx) nogil:
|
|
|
|
return self.c.R(i, idx)
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline bint empty(self) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.empty()
|
2015-06-09 22:20:14 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline bint eol(self) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.eol()
|
2015-06-09 22:20:14 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline bint at_break(self) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.at_break()
|
2015-06-09 22:20:14 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline bint has_head(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.has_head(i)
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline int n_L(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.n_L(i)
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline int n_R(self, int i) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.n_R(i)
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline bint stack_is_connected(self) nogil:
|
|
|
|
return False
|
2015-06-09 22:20:14 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline bint entity_is_open(self) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.entity_is_open()
|
2015-06-09 22:20:14 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline int stack_depth(self) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.stack_depth()
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2015-06-29 02:06:28 +03:00
|
|
|
cdef inline int buffer_length(self) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
return self.c.buffer_length()
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void push(self) nogil:
|
|
|
|
self.c.push()
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void pop(self) nogil:
|
|
|
|
self.c.pop()
|
2017-05-15 22:46:08 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void unshift(self) nogil:
|
|
|
|
self.c.unshift()
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2017-05-28 19:09:27 +03:00
|
|
|
cdef inline void add_arc(self, int head, int child, attr_t label) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
self.c.add_arc(head, child, label)
|
2017-05-15 22:46:08 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void del_arc(self, int head, int child) nogil:
|
|
|
|
self.c.del_arc(head, child)
|
2015-08-06 01:35:40 +03:00
|
|
|
|
2017-05-28 19:09:27 +03:00
|
|
|
cdef inline void open_ent(self, attr_t label) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
self.c.open_ent(label)
|
2017-05-15 22:46:08 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void close_ent(self) nogil:
|
|
|
|
self.c.close_ent()
|
2017-05-15 22:46:08 +03:00
|
|
|
|
2017-05-28 19:09:27 +03:00
|
|
|
cdef inline void set_ent_tag(self, int i, int ent_iob, attr_t ent_type) nogil:
|
2016-02-01 04:37:08 +03:00
|
|
|
self.c.set_ent_tag(i, ent_iob, ent_type)
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void set_break(self, int i) nogil:
|
|
|
|
self.c.set_break(i)
|
2015-06-09 02:39:54 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void clone(self, StateClass src) nogil:
|
|
|
|
self.c.clone(src.c)
|
2015-06-10 15:08:30 +03:00
|
|
|
|
2016-02-01 04:37:08 +03:00
|
|
|
cdef inline void fast_forward(self) nogil:
|
|
|
|
self.c.fast_forward()
|