mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-28 02:46:35 +03:00
e2b70df012
* Use isort with Black profile * isort all the things * Fix import cycles as a result of import sorting * Add DOCBIN_ALL_ATTRS type definition * Add isort to requirements * Remove isort from build dependencies check * Typo
29 lines
743 B
Cython
29 lines
743 B
Cython
from cymem.cymem cimport Pool
|
|
|
|
from ...structs cimport SpanC, TokenC
|
|
from ...tokens.doc cimport Doc
|
|
from ...typedefs cimport attr_t
|
|
from ._state cimport StateC
|
|
|
|
|
|
cdef class StateClass:
|
|
cdef StateC* c
|
|
cdef readonly Doc doc
|
|
cdef int _borrowed
|
|
|
|
@staticmethod
|
|
cdef inline StateClass borrow(StateC* ptr, Doc doc):
|
|
cdef StateClass self = StateClass()
|
|
self.c = ptr
|
|
self._borrowed = 1
|
|
self.doc = doc
|
|
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
|