U Ɛd_$@sddlmZmZmZddlmZmZmZddlm Z m Z m Z ddl m Z mZmZddlmZmZmZGdddeZGdd d eZGd d d eZGd d d eZGdddeZGdddeZGdddeZdS))EUCTW_CHAR_TO_FREQ_ORDEREUCTW_TABLE_SIZE EUCTW_TYPICAL_DISTRIBUTION_RATIO)EUCKR_CHAR_TO_FREQ_ORDEREUCKR_TABLE_SIZE EUCKR_TYPICAL_DISTRIBUTION_RATIO)GB2312_CHAR_TO_FREQ_ORDERGB2312_TABLE_SIZE!GB2312_TYPICAL_DISTRIBUTION_RATIO)BIG5_CHAR_TO_FREQ_ORDERBIG5_TABLE_SIZEBIG5_TYPICAL_DISTRIBUTION_RATIO)JIS_CHAR_TO_FREQ_ORDERJIS_TABLE_SIZEJIS_TYPICAL_DISTRIBUTION_RATIOc@sLeZdZdZdZdZdZddZddZd d Z d d Z d dZ ddZ dS)CharDistributionAnalysisigGz?g{Gz?cCs0d|_d|_d|_d|_d|_d|_|dSN)_char_to_freq_order _table_sizetypical_distribution_ratio_done _total_chars _freq_charsresetselfr_C:\Users\aemmanux\AppData\Local\Temp\pip-target-bnng1y30\lib\python\chardet/chardistribution.py__init__.sz!CharDistributionAnalysis.__init__cCsd|_d|_d|_dS)zreset analyser, clear any stateFN)rrrrrrrr=szCharDistributionAnalysis.resetcCsX|dkr||}nd}|dkrT|jd7_||jkrTd|j|krT|jd7_dS)z"feed a character with known lengthr riN) get_orderrrrr)rcharchar_lenorderrrrfeedFs  zCharDistributionAnalysis.feedcCsT|jdks|j|jkr|jS|j|jkrN|j|j|j|j}||jkrN|S|jS)z(return confidence based on existing datar )rrMINIMUM_DATA_THRESHOLDSURE_NOrSURE_YES)rrrrrget_confidenceTs  z'CharDistributionAnalysis.get_confidencecCs |j|jkSr)rENOUGH_DATA_THRESHOLDrrrrgot_enough_datadsz(CharDistributionAnalysis.got_enough_datacCsdS)Nr"r)rbyte_strrrrr#isz"CharDistributionAnalysis.get_orderN) __name__ __module__ __qualname__r-r*r)r(rrr'r,r.r#rrrrr(s rcs$eZdZfddZddZZS)EUCTWDistributionAnalysiscs$tt|t|_t|_t|_dSr) superr3rrrrrrrr __class__rrrrsz"EUCTWDistributionAnalysis.__init__cCs0|d}|dkr(d|d|ddSdSdS)Nr ^rr"rrr/ first_charrrrr#xsz#EUCTWDistributionAnalysis.get_orderr0r1r2rr# __classcell__rrr5rr3qs r3cs$eZdZfddZddZZS)EUCKRDistributionAnalysiscs$tt|t|_t|_t|_dSr) r4r>rrrrrrrrr5rrrsz"EUCKRDistributionAnalysis.__init__cCs0|d}|dkr(d|d|ddSdSdS)Nr r8rr9r"rr:rrrr#sz#EUCKRDistributionAnalysis.get_orderr<rrr5rr>s r>cs$eZdZfddZddZZS)GB2312DistributionAnalysiscs$tt|t|_t|_t|_dSr) r4r@rrrr rr rrr5rrrsz#GB2312DistributionAnalysis.__init__cCs>|d|d}}|dkr6|dkr6d|d|dSdSdS)Nr rr?r9r8r"rrr/r; second_charrrrr#sz$GB2312DistributionAnalysis.get_orderr<rrr5rr@s r@cs$eZdZfddZddZZS)Big5DistributionAnalysiscs$tt|t|_t|_t|_dSr) r4rCrr rr rr rrr5rrrsz!Big5DistributionAnalysis.__init__cCsX|d|d}}|dkrP|dkr:d|d|ddSd|d|dSndSdS) Nr rr9?@r"rrArrrr#s z"Big5DistributionAnalysis.get_orderr<rrr5rrCs rCcs$eZdZfddZddZZS)SJISDistributionAnalysiscs$tt|t|_t|_t|_dSr) r4rHrrrrrrrrr5rrrsz!SJISDistributionAnalysis.__init__cCsr|d|d}}|dkr0|dkr0d|d}n&|dkrR|dkrRd|dd}nd S||d }|d krnd }|S) Nr rr"rGr)rr/r;rBr&rrrr#s z"SJISDistributionAnalysis.get_orderr<rrr5rrHs rHcs$eZdZfddZddZZS)EUCJPDistributionAnalysiscs$tt|t|_t|_t|_dSr) r4rPrrrrrrrrr5rrrsz"EUCJPDistributionAnalysis.__init__cCs0|d}|dkr(d|d|ddSdSdS)Nr r8r9rr"r)rr/r$rrrr#sz#EUCJPDistributionAnalysis.get_orderr<rrr5rrPs rPN) euctwfreqrrr euckrfreqrrr gb2312freqrr r big5freqr r r jisfreqrrrobjectrr3r>r@rCrHrPrrrrsI