spaCy/spacy/syntax/stateclass.pxd

142 lines
3.7 KiB
Cython
Raw Normal View History

from libc.string cimport memcpy, memset
from cymem.cymem cimport Pool
cimport cython
from ..structs cimport TokenC, SpanC
2017-05-28 19:09:27 +03:00
from ..typedefs cimport attr_t
from ..vocab cimport EMPTY_LEXEME
from ._state cimport StateC
cdef class StateClass:
cdef Pool mem
cdef StateC* c
2017-11-14 04:11:40 +03:00
cdef int _borrowed
@staticmethod
cdef inline StateClass init(const TokenC* sent, int length):
cdef StateClass self = StateClass()
self.c = new StateC(sent, length)
return self
2017-11-14 04:11:40 +03:00
@staticmethod
cdef inline StateClass borrow(StateC* ptr):
cdef StateClass self = StateClass()
del self.c
self.c = ptr
self._borrowed = 1
return self
@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:
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-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-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-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-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-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-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-29 02:06:28 +03:00
cdef inline bint stack_is_connected(self) nogil:
return False
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-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-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()
2016-02-01 04:37:08 +03:00
cdef inline void push(self) nogil:
self.c.push()
2016-02-01 04:37:08 +03:00
cdef inline void pop(self) nogil:
self.c.pop()
2016-02-01 04:37:08 +03:00
cdef inline void unshift(self) nogil:
self.c.unshift()
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)
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)
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)
2016-02-01 04:37:08 +03:00
cdef inline void close_ent(self) nogil:
self.c.close_ent()
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)
2016-02-01 04:37:08 +03:00
cdef inline void set_break(self, int i) nogil:
self.c.set_break(i)
2016-02-01 04:37:08 +03:00
cdef inline void clone(self, StateClass src) nogil:
self.c.clone(src.c)
2016-02-01 04:37:08 +03:00
cdef inline void fast_forward(self) nogil:
self.c.fast_forward()