Class: CharDet::Big5DistributionAnalysis
- Inherits:
-
CharDistributionAnalysis
- Object
- CharDistributionAnalysis
- CharDet::Big5DistributionAnalysis
- Defined in:
- lib/rchardet/chardistribution.rb
Instance Method Summary collapse
-
#initialize ⇒ Big5DistributionAnalysis
constructor
A new instance of Big5DistributionAnalysis.
- #order(aStr) ⇒ Object
Methods inherited from CharDistributionAnalysis
#confidence, #feed, #got_enough_data, #reset
Constructor Details
#initialize ⇒ Big5DistributionAnalysis
Returns a new instance of Big5DistributionAnalysis.
164 165 166 167 168 169 |
# File 'lib/rchardet/chardistribution.rb', line 164 def initialize super @_mCharToFreqOrder = Big5CharToFreqOrder @_mTableSize = BIG5_TABLE_SIZE @_mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO end |
Instance Method Details
#order(aStr) ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/rchardet/chardistribution.rb', line 171 def order(aStr) # for big5 encoding, we are interested # first byte range: 0xa4 -- 0xfe # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe # no validation needed here. State machine has done that if aStr[0] >= "\xA4" if aStr[1] >= "\xA1" return 157 * (aStr[0].ord - 0xA4) + aStr[1].ord - 0xA1 + 63 else return 157 * (aStr[0].ord - 0xA4) + aStr[1].ord - 0x40 end else return -1 end end |