
    @[h%                     T   d dl mZmZmZ d dlmZmZmZ d dlm	Z	m
Z
mZ d dlmZmZmZ d dlmZmZmZ d dlmZ  G d d          Z G d	 d
e          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )   )BIG5_CHAR_TO_FREQ_ORDERBIG5_TABLE_SIZEBIG5_TYPICAL_DISTRIBUTION_RATIO)EUCKR_CHAR_TO_FREQ_ORDEREUCKR_TABLE_SIZE EUCKR_TYPICAL_DISTRIBUTION_RATIO)EUCTW_CHAR_TO_FREQ_ORDEREUCTW_TABLE_SIZE EUCTW_TYPICAL_DISTRIBUTION_RATIO)GB2312_CHAR_TO_FREQ_ORDERGB2312_TABLE_SIZE!GB2312_TYPICAL_DISTRIBUTION_RATIO)JIS_CHAR_TO_FREQ_ORDERJIS_TABLE_SIZEJIS_TYPICAL_DISTRIBUTION_RATIO)JOHAB_TO_EUCKR_ORDER_TABLEc                   B    e Zd ZdZdZdZdZd Zd Zd Z	d Z
d	 Zd
 ZdS )CharDistributionAnalysisi   gGz?g{Gz?   c                     t                      | _        d | _        d | _        d | _        d | _        d | _        |                                  d S N)tuple_char_to_freq_order_table_sizetypical_distribution_ratio_done_total_chars_freq_charsresetselfs    s/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/pip/_vendor/chardet/chardistribution.py__init__z!CharDistributionAnalysis.__init__>   sJ     $)77 
 +/'
 

    c                 0    d| _         d| _        d| _        dS )zreset analyser, clear any stateF    N)r   r   r   r    s    r"   r   zCharDistributionAnalysis.resetM   s!     
r$   c                     |dk    r|                      |          }nd}|dk    r>| xj        dz  c_        || j        k     r%d| j        |         k    r| xj        dz  c_        dS dS dS dS )z"feed a character with known length   r&   r   i   N)	get_orderr   r   r   r   )r!   charchar_lenorders       r"   feedzCharDistributionAnalysis.feedV   s    q==NN4((EEEA::"t'''1%888$$)$$$$ : ('88r$   c                     | j         dk    s| j        | j        k    r| j        S | j         | j        k    r,| j        | j         | j        z
  | j        z  z  }|| j        k     r|S | j        S )z(return confidence based on existing datar&   )r   r   MINIMUM_DATA_THRESHOLDSURE_NOr   SURE_YES)r!   rs     r"   get_confidencez'CharDistributionAnalysis.get_confidenced   s|     !!T%59T%T%T< 000 "T%559XXA 4=   }r$   c                 "    | j         | j        k    S r   )r   ENOUGH_DATA_THRESHOLDr    s    r"   got_enough_dataz(CharDistributionAnalysis.got_enough_datau   s      4#===r$   c                     dS )Nr)    )r!   _s     r"   r*   z"CharDistributionAnalysis.get_orderz   s	    
 rr$   N)__name__
__module____qualname__r6   r2   r1   r0   r#   r   r.   r4   r7   r*   r9   r$   r"   r   r   8   s         HG    * * *  "> > >
    r$   r   c                   $     e Zd Z fdZd Z xZS )EUCTWDistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   )superr#   r	   r   r
   r   r   r   r!   	__class__s    r"   r#   z"EUCTWDistributionAnalysis.__init__   7    #; +*J'''r$   c                 J    |d         }|dk    rd|dz
  z  |d         z   dz
  S dS )Nr&      ^   r      r)   r9   r!   byte_str
first_chars      r"   r*   z#EUCTWDistributionAnalysis.get_order   ;    
 a[
d*+hqk9D@@rr$   r;   r<   r=   r#   r*   __classcell__rC   s   @r"   r?   r?      L        K K K K K      r$   r?   c                   $     e Zd Z fdZd Z xZS )EUCKRDistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   rA   r#   r   r   r   r   r   r   rB   s    r"   r#   z"EUCKRDistributionAnalysis.__init__   rD   r$   c                 J    |d         }|dk    rd|dz
  z  |d         z   dz
  S dS )Nr&      rG   r   rH   r)   r9   rI   s      r"   r*   z#EUCKRDistributionAnalysis.get_order   rL   r$   rM   rO   s   @r"   rR   rR      rP   r$   rR   c                   $     e Zd Z fdZd Z xZS )JOHABDistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   rT   rB   s    r"   r#   z"JOHABDistributionAnalysis.__init__   rD   r$   c                 |    |d         }d|cxk    rdk     r&n n#|dz  |d         z   }t          j        |d          S dS )Nr&            r   r)   )r   get)r!   rJ   rK   codes       r"   r*   z#JOHABDistributionAnalysis.get_order   sX    a[
:$$$$$$$$$#hqk1D-1$;;;rr$   rM   rO   s   @r"   rX   rX      sL        K K K K K      r$   rX   c                   $     e Zd Z fdZd Z xZS )GB2312DistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   )rA   r#   r   r   r   r   r   r   rB   s    r"   r#   z#GB2312DistributionAnalysis.__init__   s7    #< ,*K'''r$   c                 Z    |d         |d         }}|dk    r|dk    rd|dz
  z  |z   dz
  S dS )Nr&   r   rV   rH   rG   r)   r9   r!   rJ   rK   second_chars       r"   r*   z$GB2312DistributionAnalysis.get_order   sI    
 #+1+x{K
$[D%8%8d*+k9D@@rr$   rM   rO   s   @r"   ra   ra      sL        L L L L L      r$   ra   c                   $     e Zd Z fdZd Z xZS )Big5DistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   )rA   r#   r   r   r   r   r   r   rB   s    r"   r#   z!Big5DistributionAnalysis.__init__   s7    #: **I'''r$   c                 |    |d         |d         }}|dk    r%|dk    rd|dz
  z  |z   dz
  dz   S d|dz
  z  |z   dz
  S dS )	Nr&   r      rH      ?   @   r)   r9   rd   s       r"   r*   z"Big5DistributionAnalysis.get_order   si    
 #+1+x{K
d""j4/0;>EJJ*t+,{:TAArr$   rM   rO   s   @r"   rg   rg      sL        J J J J J
 
 
 
 
 
 
r$   rg   c                   $     e Zd Z fdZd Z xZS )SJISDistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   rA   r#   r   r   r   r   r   r   rB   s    r"   r#   z!SJISDistributionAnalysis.__init__   7    #9 )*H'''r$   c                     |d         |d         }}d|cxk    rdk    rn n	d|dz
  z  }nd|cxk    rdk    rn nd|dz
  dz   z  }nd	S ||z   d
z
  }|dk    rd	}|S )Nr&   r                     r)   rm      r9   )r!   rJ   rK   re   r-   s        r"   r*   z"SJISDistributionAnalysis.get_order   s    
 #+1+x{K
:%%%%%%%%%:,-EEZ''''4''''':,r12EE2#d*Er$   rM   rO   s   @r"   ro   ro      sL        I I I I I      r$   ro   c                   $     e Zd Z fdZd Z xZS )EUCJPDistributionAnalysisc                     t                                                       t          | _        t          | _        t          | _        d S r   rq   rB   s    r"   r#   z"EUCJPDistributionAnalysis.__init__   rr   r$   c                 J    |d         }|dk    rd|dz
  z  |d         z   dz
  S dS )Nr&      rG   rH   r   r)   r9   )r!   rJ   r+   s      r"   r*   z#EUCJPDistributionAnalysis.get_order   s8    
 {4<<%3d::rr$   rM   rO   s   @r"   r|   r|      sL        I I I I I      r$   r|   N)big5freqr   r   r   	euckrfreqr   r   r   	euctwfreqr	   r
   r   
gb2312freqr   r   r   jisfreqr   r   r   	johabfreqr   r   r?   rR   rX   ra   rg   ro   r|   r9   r$   r"   <module>r      s{  8         
         
         
         
         
 2 1 1 1 1 1G G G G G G G GT     8   $     8   $     8       !9   $    7   (    7   2     8     r$   