class CharDet::Latin1Prober

def feed(aBuf)

def feed(aBuf)
  aBuf = filter_with_english_letters(aBuf)
  aBuf.each_byte do |b|
    c = b.chr
    charClass = Latin1_CharToClass[c.bytes.first]
    freq = Latin1ClassModel[(@lastCharClass * CLASS_NUM) + charClass]
    if freq == 0
      @state = ENotMe
      break
    end
    @freqCounter[freq] += 1
    @lastCharClass = charClass
  end
  return get_state()
end

def get_charset_name

def get_charset_name
  return "windows-1252"
end

def get_confidence

def get_confidence
  if get_state() == ENotMe
    return 0.01
  end
  total = @freqCounter.inject{|a,b| a+b} 
  if total < 0.01
    confidence = 0.0
  else
    confidence = (@freqCounter[3] / total) - (@freqCounter[1] * 20.0 / total)
  end
  if confidence < 0.0
    confidence = 0.0
  end
  # lower the confidence of latin1 so that other more accurate detector 
  # can take priority.
  confidence = confidence * 0.5
  return confidence
end

def initialize

def initialize
  super
  reset()
end

def reset

def reset
  @lastCharClass = OTH
  @freqCounter = [0] * FREQ_CAT_NUM
  super
end