mirror of
https://github.com/explosion/spaCy.git
synced 2024-11-14 13:47:13 +03:00
8656a08777
* Get basic beam tests working * Get basic beam tests working * Compile _beam_utils * Remove prints * Test beam density * Beam parser seems to train * Draft beam NER * Upd beam * Add hypothesis as dev dependency * Implement missing is-gold-parse method * Implement early update * Fix state hashing * Fix test * Fix test * Default to non-beam in parser constructor * Improve oracle for beam * Start refactoring beam * Update test * Refactor beam * Update nn * Refactor beam and weight by cost * Update ner beam settings * Update test * Add __init__.pxd * Upd test * Fix test * Upd test * Fix test * Remove ring buffer history from StateC * WIP change arc-eager transitions * Add state tests * Support ternary sent start values * Fix arc eager * Fix NER * Pass oracle cut size for beam * Fix ner test * Fix beam * Improve StateC.clone * Improve StateClass.borrow * Work directly with StateC, not StateClass * Remove print statements * Fix state copy * Improve state class * Refactor parser oracles * Fix arc eager oracle * Fix arc eager oracle * Use a vector to implement the stack * Refactor state data structure * Fix alignment of sent start * Add get_aligned_sent_starts method * Add test for ae oracle when bad sentence starts * Fix sentence segment handling * Avoid Reduce that inserts illegal sentence * Update preset SBD test * Fix test * Remove prints * Fix sent starts in Example * Improve python API of StateClass * Tweak comments and debug output of arc eager * Upd test * Fix state test * Fix state test
30 lines
744 B
Cython
30 lines
744 B
Cython
from cymem.cymem cimport Pool
|
|
|
|
from ...structs cimport TokenC, SpanC
|
|
from ...typedefs cimport attr_t
|
|
from ...tokens.doc cimport Doc
|
|
|
|
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
|