Class: UniversalDetector::EUCJPDistributionAnalysis

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

#initializeEUCJPDistributionAnalysis

Returns a new instance of EUCJPDistributionAnalysis.



225
226
227
228
229
230
# File 'lib/CharDistributionAnalysis.rb', line 225

def initialize
    super
    @_mCharToFreqOrder = JISCharToFreqOrder
    @_mTableSize = JIS_TABLE_SIZE
    @_mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO
end

Instance Method Details

#get_order(aStr) ⇒ Object



232
233
234
235
236
237
238
239
240
241
242
# File 'lib/CharDistributionAnalysis.rb', line 232

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