2015-06-08 23:39:54 +00:00
|
|
|
from cymem.cymem cimport Pool
|
|
|
|
|
2020-07-30 21:30:54 +00:00
|
|
|
from ...structs cimport TokenC, SpanC
|
|
|
|
from ...typedefs cimport attr_t
|
2020-12-13 01:08:32 +00:00
|
|
|
from ...tokens.doc cimport Doc
|
2015-06-08 23:39:54 +00:00
|
|
|
|
2016-02-01 00:16:14 +00:00
|
|
|
from ._state cimport StateC
|
|
|
|
|
2015-06-08 23:39:54 +00:00
|
|
|
|
|
|
|
cdef class StateClass:
|
2016-02-01 00:16:14 +00:00
|
|
|
cdef StateC* c
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef readonly Doc doc
|
2017-11-14 01:11:40 +00:00
|
|
|
cdef int _borrowed
|
2015-06-08 23:39:54 +00:00
|
|
|
|
2015-06-10 02:20:23 +00:00
|
|
|
@staticmethod
|
2020-12-13 01:08:32 +00:00
|
|
|
cdef inline StateClass borrow(StateC* ptr, Doc doc):
|
2017-05-15 19:46:08 +00:00
|
|
|
cdef StateClass self = StateClass()
|
2017-11-14 01:11:40 +00:00
|
|
|
self.c = ptr
|
|
|
|
self._borrowed = 1
|
2020-12-13 01:08:32 +00:00
|
|
|
self.doc = doc
|
2017-11-14 01:11:40 +00:00
|
|
|
return self
|
|
|
|
|
2017-05-15 19:46:08 +00: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
|