o ÕH´_Ã$ã@sØddlmZmZmZddlmZmZmZddlm Z m Z m Z ddl m Z mZmZddlmZmZmZGdd„deƒZGdd „d eƒZGd d „d eƒZGd d „d eƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)é)ÚEUCTW_CHAR_TO_FREQ_ORDERÚEUCTW_TABLE_SIZEÚ EUCTW_TYPICAL_DISTRIBUTION_RATIO)ÚEUCKR_CHAR_TO_FREQ_ORDERÚEUCKR_TABLE_SIZEÚ EUCKR_TYPICAL_DISTRIBUTION_RATIO)ÚGB2312_CHAR_TO_FREQ_ORDERÚGB2312_TABLE_SIZEÚ!GB2312_TYPICAL_DISTRIBUTION_RATIO)ÚBIG5_CHAR_TO_FREQ_ORDERÚBIG5_TABLE_SIZEÚBIG5_TYPICAL_DISTRIBUTION_RATIO)ÚJIS_CHAR_TO_FREQ_ORDERÚJIS_TABLE_SIZEÚJIS_TYPICAL_DISTRIBUTION_RATIOc@sLeZdZdZdZdZdZdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dS)ÚCharDistributionAnalysisig®Gáz®ï?g{®Gáz„?écCs0d|_d|_d|_d|_d|_d|_| ¡dS©N)Ú_char_to_freq_orderÚ _table_sizeÚtypical_distribution_ratioÚ_doneÚ _total_charsÚ _freq_charsÚreset©Úself©rú:/usr/lib/python3/dist-packages/chardet/chardistribution.pyÚ__init__.s z!CharDistributionAnalysis.__init__cCsd|_d|_d|_dS)zreset analyser, clear any stateFéN)rrrrrrrr=s zCharDistributionAnalysis.resetcCsd|dkr | |¡}nd}|dkr,|jd7_||jkr.d|j|kr0|jd7_dSdSdSdS)z"feed a character with known lengthééÿÿÿÿr riN)Ú get_orderrrrr)rÚcharÚchar_lenÚorderrrrÚfeedFs  ûzCharDistributionAnalysis.feedcCsT|jdks |j|jkr|jS|j|jkr'|j|j|j|j}||jkr'|S|jS)z(return confidence based on existing datar )rrÚMINIMUM_DATA_THRESHOLDÚSURE_NOrÚSURE_YES)rÚrrrrÚget_confidenceTs ÿ z'CharDistributionAnalysis.get_confidencecCs |j|jkSr)rÚENOUGH_DATA_THRESHOLDrrrrÚgot_enough_datads z(CharDistributionAnalysis.got_enough_datacCsdS)Nr"r)rÚbyte_strrrrr#isz"CharDistributionAnalysis.get_orderN) Ú__name__Ú __module__Ú __qualname__r-r*r)r(rrr'r,r.r#rrrrr(s  rcó$eZdZ‡fdd„Zdd„Z‡ZS)ÚEUCTWDistributionAnalysiscó$tt|ƒ ¡t|_t|_t|_dSr) Úsuperr4rrrrrrrr©Ú __class__rrrró z"EUCTWDistributionAnalysis.__init__cCó,|d}|dkrd|d|ddSdS)Nr éÄé^ré¡r"r©rr/Ú first_charrrrr#xóz#EUCTWDistributionAnalysis.get_order©r0r1r2rr#Ú __classcell__rrr7rr4qó r4cr3)ÚEUCKRDistributionAnalysiscr5r) r6rDrrrrrrrrr7rrr…r9z"EUCKRDistributionAnalysis.__init__cCr:)Nr é°r<rr=r"rr>rrrr#‹r@z#EUCKRDistributionAnalysis.get_orderrArrr7rrD„rCrDcr3)ÚGB2312DistributionAnalysiscr5r) r6rFrrrr rr rrr7rrr˜r9z#GB2312DistributionAnalysis.__init__cCs:|d|d}}|dkr|dkrd|d|dSdS)Nr rrEr=r<r"r©rr/r?Ú second_charrrrr#žsz$GB2312DistributionAnalysis.get_orderrArrr7rrF—rCrFcr3)ÚBig5DistributionAnalysiscr5r) r6rIrr rr rr rrr7rrr«r9z!Big5DistributionAnalysis.__init__cCsR|d|d}}|dkr'|dkrd|d|ddSd|d|dSdS) Nr ré¤r=éé?é@r"rrGrrrr#±s z"Big5DistributionAnalysis.get_orderrArrr7rrIªrCrIcr3)ÚSJISDistributionAnalysiscr5r) r6rNrrrrrrrrr7rrrÁr9z!SJISDistributionAnalysis.__init__cCsr|d|d}}|dkr|dkrd|d}n|dkr)|dkr)d|dd}nd S||d }|d kr7d }|S) Nr rééŸé¼éàéïér"rMér)rr/r?rHr&rrrr#Çs z"SJISDistributionAnalysis.get_orderrArrr7rrNÀrCrNcr3)ÚEUCJPDistributionAnalysiscr5r) r6rVrrrrrrrrr7rrrÚr9z"EUCJPDistributionAnalysis.__init__cCs,|d}|dkrd|d|ddSdS)Nr é r<r=rr"r)rr/r$rrrr#àr@z#EUCJPDistributionAnalysis.get_orderrArrr7rrVÙrCrVN)Ú euctwfreqrrrÚ euckrfreqrrrÚ gb2312freqrr r Úbig5freqr r r ÚjisfreqrrrÚobjectrr4rDrFrIrNrVrrrrÚsI