Re$.ddlmZmZmZddlmZmZmZddlm Z m Z m Z ddl m Z mZmZddlmZmZmZGddeZGdd eZGd d eZGd d eZGddeZGddeZGddeZdS))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_RATIOcBeZdZdZdZdZdZdZdZdZ dZ d Z d Z d S) CharDistributionAnalysisigGz?g{Gz?cd|_d|_d|_d|_d|_d|_|dSN)_char_to_freq_order _table_sizetypical_distribution_ratio_done _total_chars _freq_charsresetselfs /builddir/build/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_vendor/chardet/chardistribution.py__init__z!CharDistributionAnalysis.__init__.sF$(  +/'   c0d|_d|_d|_dS)zreset analyser, clear any stateFN)rrrrs r rzCharDistributionAnalysis.reset=s! r"c|dkr||}nd}|dkr>|xjdz c_||jkr%d|j|kr|xjdz c_dSdSdSdS)z"feed a character with known lengthr$riN) get_orderrrrr)rcharchar_lenorders r feedzCharDistributionAnalysis.feedFs q==NN4((EEE A::    "  t'''1%888$$)$$$$ :('88r"c|jdks|j|jkr|jS|j|jkr,|j|j|jz |jzz }||jkr|S|jS)z(return confidence based on existing datar$)rrMINIMUM_DATA_THRESHOLDSURE_NOrSURE_YES)rrs r get_confidencez'CharDistributionAnalysis.get_confidenceTs|   ! !T%59T%T%T<    0 0 0!d&7$:J&J2&34A4=  }r"c"|j|jkSr)rENOUGH_DATA_THRESHOLDrs r got_enough_dataz(CharDistributionAnalysis.got_enough_datads 4#===r"cdS)Nr')rbyte_strs r r(z"CharDistributionAnalysis.get_orderis rr"N) __name__ __module__ __qualname__r4r0r/r.r!rr,r2r5r(r7r"r rr(s HG    * * * >>> r"rc$eZdZfdZdZxZS)EUCTWDistributionAnalysisctt|t|_t |_t|_dSr) superr=r!rrrrrrr __class__s r r!z"EUCTWDistributionAnalysis.__init__r> '..77999#; +*J'''r"cJ|d}|dkrd|dz z|dzdz SdS)Nr$^rr'r7rr8 first_chars r r(z#EUCTWDistributionAnalysis.get_orderx; a[   d*+hqk9D@ @2r"r9r:r;r!r( __classcell__rAs@r r=r=qLKKKKK       r"r=c$eZdZfdZdZxZS)EUCKRDistributionAnalysisctt|t|_t |_t|_dSr) r?rOr!rrrrrrr@s r r!z"EUCKRDistributionAnalysis.__init__rBr"cJ|d}|dkrd|dz z|dzdz SdS)Nr$rErrFr'r7rGs r r(z#EUCKRDistributionAnalysis.get_orderrIr"rJrLs@r rOrOrMr"rOc$eZdZfdZdZxZS)GB2312DistributionAnalysisctt|t|_t |_t|_dSr) r?rTr!r rr rr rr@s r r!z#GB2312DistributionAnalysis.__init__s> ($//88:::#< ,*K'''r"cZ|d|d}}|dkr|dkrd|dz z|zdz SdS)Nr$rrRrFrEr'r7rr8rH second_chars r r(z$GB2312DistributionAnalysis.get_ordersI #+1+x{K $  [D%8%8d*+k9D@ @2r"rJrLs@r rTrTsLLLLLL       r"rTc$eZdZfdZdZxZS)Big5DistributionAnalysisctt|t|_t |_t|_dSr) r?rZr!r rr rrrr@s r r!z!Big5DistributionAnalysis.__init__s> &--66888#: **I'''r"c||d|d}}|dkr%|dkrd|dz z|zdz dzSd|dz z|zdz SdS) Nr$rrF?@r'r7rWs r r(z"Big5DistributionAnalysis.get_ordersi #+1+x{K   d""j4/0;>EJJj4/0;>EE2r"rJrLs@r rZrZsLJJJJJ       r"rZc$eZdZfdZdZxZS)SJISDistributionAnalysisctt|t|_t |_t|_dSr) r?rbr!rrrrrrr@s r r!z!SJISDistributionAnalysis.__init__s> &--66888#9 )*H'''r"c|d|d}}|dkr|dkr d|dz z}n|dkr|dkr d|dz dzz}nd S||zd z }|d krd }|S) Nr$rr'r`r7)rr8rHrXr+s r r(z"SJISDistributionAnalysis.get_orders #+1+x{K $  Z4%7%7:,-EED  zT'9'9:,r12EE2 #d*   E r"rJrLs@r rbrbsLIIIII r"rbc$eZdZfdZdZxZS)EUCJPDistributionAnalysisctt|t|_t |_t|_dSr) r?rmr!rrrrrrr@s r r!z"EUCJPDistributionAnalysis.__init__s> '..77999#9 )*H'''r"cJ|d}|dkrd|dz z|dzdz SdS)Nr$rErFrr'r7)rr8r)s r r(z#EUCJPDistributionAnalysis.get_orders8 { 4<<% 3d: :2r"rJrLs@r rmrmsLIIIII       r"rmN) euctwfreqrrr euckrfreqrrr gb2312freqr r r big5freqr r rjisfreqrrrobjectrr=rOrTrZrbrmr7r"r rws>8::::::::::::::::::::<<<<<<<<<<88888888886666666666FFFFFvFFFR 8& 8&!9&7,72 8r"