Class: UniversalDetector::EUCTWDistributionAnalysis
- Inherits:
-
CharDistributionAnalysis
- Object
- CharDistributionAnalysis
- UniversalDetector::EUCTWDistributionAnalysis
- 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
- #get_order(aStr) ⇒ Object
-
#initialize ⇒ EUCTWDistributionAnalysis
constructor
A new instance of EUCTWDistributionAnalysis.
Methods inherited from CharDistributionAnalysis
#feed, #get_confidence, #got_enough_data, #reset
Constructor Details
#initialize ⇒ EUCTWDistributionAnalysis
Returns a new instance of EUCTWDistributionAnalysis.
109 110 111 112 113 114 |
# File 'lib/CharDistributionAnalysis.rb', line 109 def initialize super @_mCharToFreqOrder = EUCTWCharToFreqOrder @_mTableSize = EUCTW_TABLE_SIZE @_mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO end |
Instance Method Details
#get_order(aStr) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/CharDistributionAnalysis.rb', line 116 def get_order(aStr) # for euc-TW encoding, we are interested # first byte range: 0xc4 -- 0xfe # second byte range: 0xa1 -- 0xfe # no validation needed here. State machine has done that if aStr[0] >= 0xC4 return 94 * (aStr[0] - 0xC4) + aStr[1] - 0xA1 else return -1 end end |