Exemple #1
0
def block(source):
    source.check()
    codeMap = CodeMap('Blockcode')
    count = 0
    blockLength = ceil(bb(len(source)))
    for symbol in source.sorted():
        codeMap.mapSymbol(symbol, _paddedBinary(count, blockLength))
        count += 1
    return codeMap
Exemple #2
0
def block(source):
    source.check()
    codeMap = CodeMap('Blockcode')
    count = 0
    blockLength = ceil(bb(len(source)))
    for symbol in source.sorted():
        codeMap.mapSymbol(symbol, _paddedBinary(count, blockLength))
        count += 1
    return codeMap
Exemple #3
0
 def addSymbol(self, symbol):
     self._symbols.append(symbol)
     self._entropy -= symbol.proba()*d(bb(symbol.proba()))