mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
* Pad buffers in state
This commit is contained in:
parent
53be72387c
commit
b06962f18b
|
@ -8,17 +8,22 @@ from ..structs cimport Entity
|
||||||
cdef class StateClass:
|
cdef class StateClass:
|
||||||
def __init__(self, int length):
|
def __init__(self, int length):
|
||||||
cdef Pool mem = Pool()
|
cdef Pool mem = Pool()
|
||||||
PADDING = 5
|
cdef int PADDING = 5
|
||||||
self._buffer = <int*>mem.alloc(length + PADDING, sizeof(int))
|
self._buffer = <int*>mem.alloc(length + (PADDING * 2), sizeof(int))
|
||||||
self._stack = <int*>mem.alloc(length + PADDING, sizeof(int))
|
self._stack = <int*>mem.alloc(length + (PADDING * 2), sizeof(int))
|
||||||
self.shifted = <bint*>mem.alloc(length + PADDING, sizeof(bint))
|
self.shifted = <bint*>mem.alloc(length + (PADDING * 2), sizeof(bint))
|
||||||
self._sent = <TokenC*>mem.alloc(length + PADDING, sizeof(TokenC))
|
self._sent = <TokenC*>mem.alloc(length + (PADDING * 2), sizeof(TokenC))
|
||||||
self._ents = <Entity*>mem.alloc(length + PADDING, sizeof(Entity))
|
self._ents = <Entity*>mem.alloc(length + (PADDING * 2), sizeof(Entity))
|
||||||
cdef int i
|
cdef int i
|
||||||
for i in range(length):
|
for i in range(length + (PADDING * 2)):
|
||||||
self._ents[i].end = -1
|
self._ents[i].end = -1
|
||||||
for i in range(length, length + PADDING):
|
for i in range(length, length + (PADDING * 2)):
|
||||||
self._sent[i].lex = &EMPTY_LEXEME
|
self._sent[i].lex = &EMPTY_LEXEME
|
||||||
|
self._sent += PADDING
|
||||||
|
self._ents += PADDING
|
||||||
|
self._buffer += PADDING
|
||||||
|
self._stack += PADDING
|
||||||
|
self.shifted += PADDING
|
||||||
self.mem = mem
|
self.mem = mem
|
||||||
self.length = length
|
self.length = length
|
||||||
self._break = -1
|
self._break = -1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user