Class: UniversalDetector::EUCKRDistributionAnalysis

Inherits:
CharDistributionAnalysis show all
Defined in:
lib/CharDistributionAnalysis.rb

Constant Summary

Constants inherited from CharDistributionAnalysis

CharDistributionAnalysis::ENOUGH_DATA_THRESHOLD, CharDistributionAnalysis::SURE_NO, CharDistributionAnalysis::SURE_YES

Instance Method Summary collapse

Methods inherited from CharDistributionAnalysis

#feed, #get_confidence, #got_enough_data, #reset

Constructor Details

#initializeEUCKRDistributionAnalysis

Returns a new instance of EUCKRDistributionAnalysis.



130
131
132
133
134
135
# File 'lib/CharDistributionAnalysis.rb', line 130

def initialize
    super
    @_mCharToFreqOrder = EUCKRCharToFreqOrder
    @_mTableSize = EUCKR_TABLE_SIZE
    @_mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO
end

Instance Method Details

#get_order(aStr) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/CharDistributionAnalysis.rb', line 137

def get_order(aStr)
    # for euc-KR encoding, we are interested 
    #   first  byte range: 0xb0 -- 0xfe
    #   second byte range: 0xa1 -- 0xfe
    # no validation needed here. State machine has done that
    if aStr[0] >= 0xB0
        return 94 * (aStr[0] - 0xB0) + aStr[1] - 0xA1
    else
        return -1;
    end
end