class CharDet::CodingStateMachine
def get_coding_state_machine
def get_coding_state_machine return @model['name'] end
def get_current_charlen
def get_current_charlen return @currentCharLen end
def initialize(sm)
def initialize(sm) @model = sm @currentBytePos = 0 @currentCharLen = 0 reset() end
def next_state(c)
def next_state(c) # for each byte we get its class # if it is first byte, we also get byte length b = c.bytes.first byteCls = @model['classTable'][b] if @currentState == EStart @currentBytePos = 0 @currentCharLen = @model['charLenTable'][byteCls] end # from byte's class and stateTable, we get its next state @currentState = @model['stateTable'][@currentState * @model['classFactor'] + byteCls] @currentBytePos += 1 return @currentState end
def reset
def reset @currentState = EStart end