* Give codec loading back to Vocab.

This commit is contained in:
Matthew Honnibal 2015-07-16 17:45:42 +02:00
parent 8bf0f65f1c
commit 2a5d050134

View File

@ -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')