o
    g$                     @   s   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 G dd deZG dd	 d	eZG d
d deZG dd deZG dd deZG dd deZG dd deZdS )   )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                   @   sL   e Zd ZdZdZdZdZdd Zdd Zd	d
 Z	dd Z
dd Zdd ZdS )CharDistributionAnalysisi   gGz?g{Gz?   c                 C   s0   d | _ d | _d | _d | _d | _d | _|   d S N)_char_to_freq_order_table_sizetypical_distribution_ratio_done_total_chars_freq_charsresetself r   b/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pip/_vendor/chardet/chardistribution.py__init__.   s   z!CharDistributionAnalysis.__init__c                 C   s   d| _ d| _d| _dS )zreset analyser, clear any stateF    N)r   r   r   r   r   r   r   r   =   s   
zCharDistributionAnalysis.resetc                 C   sd   |dkr
|  |}nd}|dkr,|  jd7  _|| jk r.d| j| kr0|  jd7  _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orderr   r   r   feedF   s   
zCharDistributionAnalysis.feedc                 C   sT   | j dks| j| jkr| jS | j | jkr'| j| j | j | j  }|| jk r'|S | jS )z(return confidence based on existing datar    )r   r   MINIMUM_DATA_THRESHOLDSURE_NOr   SURE_YES)r   rr   r   r   get_confidenceT   s   
z'CharDistributionAnalysis.get_confidencec                 C   s   | j | jkS r   )r   ENOUGH_DATA_THRESHOLDr   r   r   r   got_enough_datad   s   z(CharDistributionAnalysis.got_enough_datac                 C   s   dS )Nr"   r   )r   byte_strr   r   r   r#   i   s   z"CharDistributionAnalysis.get_orderN)__name__
__module____qualname__r-   r*   r)   r(   r   r   r'   r,   r.   r#   r   r   r   r   r   (   s    	r   c                       $   e Zd Z fddZdd Z  ZS )EUCTWDistributionAnalysisc                    $   t t|   t| _t| _t| _d S r   )	superr4   r   r   r   r   r   r   r   r   	__class__r   r   r   r      
z"EUCTWDistributionAnalysis.__init__c                 C   ,   |d }|dkrd|d  |d  d S dS )Nr       ^   r      r"   r   r   r/   
first_charr   r   r   r#   x      z#EUCTWDistributionAnalysis.get_orderr0   r1   r2   r   r#   __classcell__r   r   r7   r   r4   q       r4   c                       r3   )EUCKRDistributionAnalysisc                    r5   r   )	r6   rD   r   r   r   r   r   r   r   r   r7   r   r   r      r9   z"EUCKRDistributionAnalysis.__init__c                 C   r:   )Nr       r<   r   r=   r"   r   r>   r   r   r   r#      r@   z#EUCKRDistributionAnalysis.get_orderrA   r   r   r7   r   rD      rC   rD   c                       r3   )GB2312DistributionAnalysisc                    r5   r   )	r6   rF   r   r   r   r	   r   r
   r   r   r7   r   r   r      r9   z#GB2312DistributionAnalysis.__init__c                 C   s:   |d |d }}|dkr|dkrd|d  | d S dS )Nr    r   rE   r=   r<   r"   r   r   r/   r?   second_charr   r   r   r#      s   z$GB2312DistributionAnalysis.get_orderrA   r   r   r7   r   rF      rC   rF   c                       r3   )Big5DistributionAnalysisc                    r5   r   )	r6   rI   r   r   r   r   r   r   r   r   r7   r   r   r      r9   z!Big5DistributionAnalysis.__init__c                 C   sR   |d |d }}|dkr'|dkrd|d  | d d S d|d  | d S dS )	Nr    r      r=      ?   @   r"   r   rG   r   r   r   r#      s   z"Big5DistributionAnalysis.get_orderrA   r   r   r7   r   rI      rC   rI   c                       r3   )SJISDistributionAnalysisc                    r5   r   )	r6   rN   r   r   r   r   r   r   r   r   r7   r   r   r      r9   z!SJISDistributionAnalysis.__init__c                 C   sr   |d |d }}|dkr|dkrd|d  }n|dkr)|dkr)d|d d  }nd	S || d
 }|dkr7d	}|S )Nr    r                     r"   rM      r   )r   r/   r?   rH   r&   r   r   r   r#      s   z"SJISDistributionAnalysis.get_orderrA   r   r   r7   r   rN      rC   rN   c                       r3   )EUCJPDistributionAnalysisc                    r5   r   )	r6   rV   r   r   r   r   r   r   r   r   r7   r   r   r      r9   z"EUCJPDistributionAnalysis.__init__c                 C   s,   |d }|dkrd|d  |d  d S dS )Nr       r<   r=   r   r"   r   )r   r/   r$   r   r   r   r#      r@   z#EUCJPDistributionAnalysis.get_orderrA   r   r   r7   r   rV      rC   rV   N)	euctwfreqr   r   r   	euckrfreqr   r   r   
gb2312freqr   r	   r
   big5freqr   r   r   jisfreqr   r   r   objectr   r4   rD   rF   rI   rN   rV   r   r   r   r   <module>   s   I