Class | CharDet::Latin1Prober
In: | lib/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb
Parent: | CharSetProber

### Methods

feed get_charset_name get_confidence new reset

### Public Class methods

new()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb, line 95
        def initialize
          super
          reset()
        end

### Public Instance methods

feed(aBuf)

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb, line 110
        def feed(aBuf)
          aBuf = filter_with_english_letters(aBuf)
          aBuf.each_byte do |b|
            c = b.chr
            charClass = Latin1_CharToClass[c[0]]
            freq = Latin1ClassModel[(@_mLastCharClass * CLASS_NUM) + charClass]
            if freq == 0
              @_mState = ENotMe
              break
            end
            @_mFreqCounter[freq] += 1
            @_mLastCharClass = charClass
          end

          return get_state()
        end

get_charset_name()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb, line 106
        def get_charset_name
          return "windows-1252"
        end

get_confidence()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb, line 127
        def get_confidence
          if get_state() == ENotMe
            return 0.01
          end

          total = @_mFreqCounter.inject{|a,b| a+b}
          if total < 0.01
            confidence = 0.0
          else
            confidence = (@_mFreqCounter[3] / total) - (@_mFreqCounter[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

reset()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/latin1prober.rb, line 100
        def reset
          @_mLastCharClass = OTH
          @_mFreqCounter = [0] * FREQ_CAT_NUM
          super
        end

[Validate]