Class: CharDet::SJISContextAnalysis

Inherits:
JapaneseContextAnalysis show all
Defined in:
lib/rchardet/jpcntx.rb

Instance Method Summary collapse

Methods inherited from JapaneseContextAnalysis

#feed, #get_confidence, #got_enough_data, #initialize, #reset

Constructor Details

This class inherits a constructor from CharDet::JapaneseContextAnalysis

Instance Method Details

#get_order(aStr) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/rchardet/jpcntx.rb', line 184

def get_order(aStr)
  return -1, 1 if aStr.nil? || aStr.empty?
  # find out current char's byte length
  first = aStr[0, 1]
  if ((first >= "\x81") and (first <= "\x9F")) or ((first >= "\xE0") and (first <= "\xFC"))
    charLen = 2
  else
    charLen = 1
  end
  # return its order if it is hiragana
  if aStr.length > 1
    second = aStr[1, 1]
    if (first == "\202") and (second >= "\x9F") and (second <= "\xF1")
      return aStr[1].ord - 0x9F, charLen
    end
  end

  return -1, charLen
end