2015-07-13 11:54:51 +00:00
|
|
|
from libcpp.vector cimport vector
|
|
|
|
from libc.stdint cimport uint32_t
|
|
|
|
from libc.stdint cimport int64_t
|
|
|
|
from libc.stdint cimport int32_t
|
|
|
|
from libc.stdint cimport uint64_t
|
|
|
|
|
2015-07-16 17:55:47 +00:00
|
|
|
from .vocab cimport Vocab
|
|
|
|
|
2015-07-13 11:54:51 +00:00
|
|
|
|
|
|
|
cdef struct Node:
|
|
|
|
float prob
|
|
|
|
int32_t left
|
|
|
|
int32_t right
|
|
|
|
|
|
|
|
|
|
|
|
cdef struct Code:
|
|
|
|
uint64_t bits
|
|
|
|
char length
|
|
|
|
|
|
|
|
|
2015-07-16 09:22:35 +00:00
|
|
|
cdef class Serializer:
|
|
|
|
cdef list codecs
|
2015-07-16 17:55:47 +00:00
|
|
|
cdef Vocab vocab
|
2015-07-16 09:22:35 +00:00
|
|
|
|
|
|
|
|
2015-07-13 11:54:51 +00:00
|
|
|
cdef class HuffmanCodec:
|
|
|
|
cdef vector[Node] nodes
|
|
|
|
cdef vector[Code] codes
|
|
|
|
cdef uint32_t eol
|
2015-07-16 09:22:35 +00:00
|
|
|
cdef int id
|
2015-07-13 11:54:51 +00:00
|
|
|
|