2022-01-12 15:38:52 +03:00
|
|
|
from libcpp.memory cimport shared_ptr
|
2016-10-14 04:24:13 +03:00
|
|
|
cimport numpy as np
|
|
|
|
|
2015-07-13 21:20:58 +03:00
|
|
|
from .doc cimport Doc
|
2017-05-28 19:09:27 +03:00
|
|
|
from ..typedefs cimport attr_t
|
2021-01-14 09:30:41 +03:00
|
|
|
from ..structs cimport SpanC
|
2015-07-13 21:20:58 +03:00
|
|
|
|
|
|
|
|
|
|
|
cdef class Span:
|
2015-09-29 16:03:55 +03:00
|
|
|
cdef readonly Doc doc
|
2022-01-12 15:38:52 +03:00
|
|
|
cdef shared_ptr[SpanC] c
|
2015-09-17 04:50:11 +03:00
|
|
|
cdef public _vector
|
|
|
|
cdef public _vector_norm
|
2015-11-07 00:56:49 +03:00
|
|
|
|
2021-01-14 09:30:41 +03:00
|
|
|
@staticmethod
|
2022-01-12 15:38:52 +03:00
|
|
|
cdef inline Span cinit(Doc doc, const shared_ptr[SpanC] &span):
|
2021-01-14 09:30:41 +03:00
|
|
|
cdef Span self = Span.__new__(
|
|
|
|
Span,
|
|
|
|
doc,
|
2022-01-12 15:38:52 +03:00
|
|
|
start=span.get().start,
|
|
|
|
end=span.get().end
|
2021-01-14 09:30:41 +03:00
|
|
|
)
|
|
|
|
self.c = span
|
|
|
|
return self
|
|
|
|
|
2017-08-19 13:20:45 +03:00
|
|
|
cpdef np.ndarray to_array(self, object features)
|
2022-01-12 15:38:52 +03:00
|
|
|
|
|
|
|
cdef SpanC* span_c(self)
|