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