Class: CharDet::CharSetGroupProber

### Home Classes Methods

### In Files

- lib/tmail/vendor/rchardet-1.3/lib/rchardet/charsetgroupprober.rb

### Parent

CharSetProber

### Methods

- ::new
- #feed
- #get_charset_name
- #get_confidence
- #reset

### Files

- CHANGES
- LICENSE
- NOTES
- README
- Rakefile
- MANIFEST
- Makefile
- depend
- Makefile
- COPYING
- README

### Class/Module Index

Quicksearch

- TMail
- TMail::Address
- TMail::AddressGroup
- TMail::AddressHeader
- TMail::Attachment
- TMail::ContentDispositionHeader
- TMail::ContentTransferEncodingHeader
- TMail::ContentTypeHeader
- TMail::DateTimeHeader
- TMail::EncryptedHeader
- TMail::FilePort
- TMail::HeaderField
- TMail::KeywordsHeader
- TMail::Mail
- TMail::MailFlags
- TMail::Maildir
- TMail::MaildirLoader
- TMail::MaildirPort
- TMail::MboxLoader
- TMail::MessageIdHeader
- TMail::MhLoader
- TMail::MhMailbox
- TMail::MhPort
- TMail::MimeVersionHeader
- TMail::Parser
- TMail::Port
- TMail::ReceivedHeader
- TMail::ReferencesHeader
- TMail::ReturnPathHeader
- TMail::SingleAddressHeader
- TMail::StringPort
- TMail::StructuredHeader
- TMail::SyntaxError
- TMail::TMailScanner
- TMail::TextUtils
- TMail::UNIXMbox
- TMail::UnstructuredHeader
- CharDet
- CharDet::Big5DistributionAnalysis
- CharDet::Big5Prober
- CharDet::CharDistributionAnalysis
- CharDet::CharSetGroupProber
- CharDet::CharSetProber
- CharDet::CodingStateMachine
- CharDet::EUCJPContextAnalysis
- CharDet::EUCJPDistributionAnalysis
- CharDet::EUCJPProber
- CharDet::EUCKRDistributionAnalysis
- CharDet::EUCKRProber
- CharDet::EUCTWDistributionAnalysis
- CharDet::EUCTWProber
- CharDet::EscCharSetProber
- CharDet::GB2312DistributionAnalysis
- CharDet::GB2312Prober
- CharDet::HebrewProber
- CharDet::JapaneseContextAnalysis
- CharDet::Latin1Prober
- CharDet::MBCSGroupProber
- CharDet::MultiByteCharSetProber
- CharDet::SBCSGroupProber
- CharDet::SJISContextAnalysis
- CharDet::SJISDistributionAnalysis
- CharDet::SJISProber
- CharDet::SingleByteCharSetProber
- CharDet::UTF8Prober
- CharDet::UniversalDetector

No matching classes.

# CharDet::CharSetGroupProber

### Attributes

_mProbers[RW]

### Public Class Methods

new() click to toggle 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) click to toggle 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() click to toggle 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() click to toggle 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() click to toggle 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]

Generated with the Darkfish Rdoc Generator 2.