mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 17:06:29 +03:00
* Give codec loading back to Vocab.
This commit is contained in:
parent
8bf0f65f1c
commit
2a5d050134
|
@ -227,6 +227,22 @@ cdef class Vocab:
|
|||
lex.repvec = EMPTY_VEC
|
||||
return vec_len
|
||||
|
||||
property codec:
|
||||
def __get__(self):
|
||||
cdef Address mem
|
||||
cdef int i
|
||||
cdef float[:] cv_probs
|
||||
if self._codec is not None:
|
||||
return self._codec
|
||||
else:
|
||||
mem = Address(len(self), sizeof(float))
|
||||
probs = <float*>mem.ptr
|
||||
for i in range(len(self)):
|
||||
probs[i] = <float>c_exp(self.lexemes[i].prob)
|
||||
cv_probs = <float[:len(self)]>probs
|
||||
self._codec = HuffmanCodec(cv_probs, 0)
|
||||
return self._codec
|
||||
|
||||
|
||||
def write_binary_vectors(in_loc, out_loc):
|
||||
cdef _CFile out_file = _CFile(out_loc, 'wb')
|
||||
|
|
Loading…
Reference in New Issue
Block a user