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

### Methods

feed get_charset_name get_confidence new reset

### Attributes

_mProbers | [RW] |

### Public Class methods

new()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb, line 32
        def initialize
          super
          @_mActiveNum = 0
          @_mProbers = []
          @_mBestGuessProber = nil
        end

### Public Instance methods

feed(aBuf)

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb, line 62
        def feed(aBuf)
          for prober in @_mProbers
            next unless prober
            next unless prober.active
            st = prober.feed(aBuf)
            next unless st
            if st == EFoundIt
              @_mBestGuessProber = prober
              return get_state()
            elsif st == ENotMe
              prober.active = false
              @_mActiveNum -= 1
              if @_mActiveNum <= 0
                @_mState = ENotMe
                return get_state()
              end
            end
          end
          return get_state()
        end

get_charset_name()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb, line 53
        def get_charset_name
          if not @_mBestGuessProber
            get_confidence()
            return nil unless @_mBestGuessProber
            #                self._mBestGuessProber = self._mProbers[0]
          end
          return @_mBestGuessProber.get_charset_name()
        end

get_confidence()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb, line 83
        def get_confidence()
          st = get_state()
          if st == EFoundIt
            return 0.99
          elsif st == ENotMe
            return 0.01
          end
          bestConf = 0.0
          @_mBestGuessProber = nil
          for prober in @_mProbers
            next unless prober
            unless prober.active
              $stderr << "#{prober.get_charset_name()} not active\n" if $debug
              next
            end
            cf = prober.get_confidence()
            $stderr << "#{prober.get_charset_name} confidence = #{cf}\n" if $debug
            if bestConf < cf
              bestConf = cf
              @_mBestGuessProber = prober
            end
          end
          return 0.0 unless @_mBestGuessProber
          return bestConf
          #        else
          #            self._mBestGuessProber = self._mProbers[0]
          #            return self._mBestGuessProber.get_confidence()
        end

reset()

[Source]

    # File lib/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb, line 39
        def reset
          super
          @_mActiveNum = 0

          for prober in @_mProbers
            if prober
              prober.reset()
              prober.active = true
              @_mActiveNum += 1
            end
          end
          @_mBestGuessProber = nil
        end

[Validate]