Class: CharDet::EUCKRDistributionAnalysis
- Inherits:
-
CharDistributionAnalysis
- Object
- CharDistributionAnalysis
- CharDet::EUCKRDistributionAnalysis
- Defined in:
- lib/rchardet/chardistribution.rb
Instance Method Summary collapse
- #get_order(aStr) ⇒ Object
-
#initialize ⇒ EUCKRDistributionAnalysis
constructor
A new instance of EUCKRDistributionAnalysis.
Methods inherited from CharDistributionAnalysis
#feed, #get_confidence, #got_enough_data, #reset
Constructor Details
#initialize ⇒ EUCKRDistributionAnalysis
Returns a new instance of EUCKRDistributionAnalysis.
131 132 133 134 135 136 |
# File 'lib/rchardet/chardistribution.rb', line 131 def initialize super() @charToFreqOrder = EUCKRCharToFreqOrder @tableSize = EUCKR_TABLE_SIZE @typicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO end |
Instance Method Details
#get_order(aStr) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rchardet/chardistribution.rb', line 138 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, 1] >= "\xB0" bytes = aStr.bytes.to_a return 94 * (bytes[0] - 0xB0) + bytes[1] - 0xA1 else return -1 end end |