o
    ñ‘Ojˆ%  ã                   @   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 d dlmZ G dd„ dƒ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 )é   )Ú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                   @   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   g®Gáz®ï?g{®Gáz„?é   c                 C   s2   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©Úself© r   új/var/www/html/pharmsmart-cdr-gen/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   M   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    ÚfeedV   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_confidenced   s   ÿ
z'CharDistributionAnalysis.get_confidencec                 C   s   | j | jkS r   )r   ÚENOUGH_DATA_THRESHOLDr   r   r   r    Úgot_enough_datau   s   z(CharDistributionAnalysis.got_enough_datac                 C   s   dS )Nr$   r   )r   Ú_r   r   r    r%   z   s   z"CharDistributionAnalysis.get_orderN)Ú__name__Ú
__module__Ú__qualname__r/   r,   r+   r*   r!   r   r)   r.   r0   r%   r   r   r   r    r   8   s    	r   c                       ó$   e Zd Z‡ fdd„Zdd„ Z‡  ZS )ÚEUCTWDistributionAnalysisc                    ó    t ƒ  ¡  t| _t| _t| _d S r   )Úsuperr!   r   r   r	   r   r
   r   r   ©Ú	__class__r   r    r!   ƒ   ó   

z"EUCTWDistributionAnalysis.__init__c                 C   ó,   |d }|dkrd|d  |d  d S dS )Nr"   éÄ   é^   r   é¡   r$   r   ©r   Úbyte_strÚ
first_charr   r   r    r%   ‰   ó   z#EUCTWDistributionAnalysis.get_order©r2   r3   r4   r!   r%   Ú__classcell__r   r   r9   r    r6   ‚   ó    r6   c                       r5   )ÚEUCKRDistributionAnalysisc                    r7   r   ©r8   r!   r   r   r   r   r   r   r   r9   r   r    r!   •   r;   z"EUCKRDistributionAnalysis.__init__c                 C   r<   )Nr"   é°   r>   r   r?   r$   r   r@   r   r   r    r%   ›   rC   z#EUCKRDistributionAnalysis.get_orderrD   r   r   r9   r    rG   ”   rF   rG   c                       r5   )ÚJOHABDistributionAnalysisc                    r7   r   rH   r   r9   r   r    r!   §   r;   z"JOHABDistributionAnalysis.__init__c                 C   sB   |d }d|  krdk rn dS |d |d  }t  |d¡S dS )Nr"   éˆ   éÔ   é   r   r$   )r   Úget)r   rA   rB   Úcoder   r   r    r%   ­   s   þz#JOHABDistributionAnalysis.get_orderrD   r   r   r9   r    rJ   ¦   rF   rJ   c                       r5   )ÚGB2312DistributionAnalysisc                    r7   r   )r8   r!   r   r   r   r   r   r   r   r9   r   r    r!   ¶   r;   z#GB2312DistributionAnalysis.__init__c                 C   s:   |d |d }}|dkr|dkrd|d  | d S dS )Nr"   r   rI   r?   r>   r$   r   ©r   rA   rB   Úsecond_charr   r   r    r%   ¼   s   z$GB2312DistributionAnalysis.get_orderrD   r   r   r9   r    rP   µ   rF   rP   c                       r5   )ÚBig5DistributionAnalysisc                    r7   r   )r8   r!   r   r   r   r   r   r   r   r9   r   r    r!   È   r;   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   rQ   r   r   r    r%   Î   s   z"Big5DistributionAnalysis.get_orderrD   r   r   r9   r    rS   Ç   rF   rS   c                       r5   )ÚSJISDistributionAnalysisc                    r7   r   ©r8   r!   r   r   r   r   r   r   r   r9   r   r    r!   Ü   r;   z!SJISDistributionAnalysis.__init__c                 C   s„   |d |d }}d|  krdkrn nd|d  }nd|  kr&dkr2n d	S d|d d  }nd	S || d
 }|dkr@d	}|S )Nr"   r   é�   éŸ   é¼   éà   éï   é   r$   rW   é   r   )r   rA   rB   rR   r(   r   r   r    r%   â   s   þz"SJISDistributionAnalysis.get_orderrD   r   r   r9   r    rX   Û   rF   rX   c                       r5   )ÚEUCJPDistributionAnalysisc                    r7   r   rY   r   r9   r   r    r!   õ   r;   z"EUCJPDistributionAnalysis.__init__c                 C   s,   |d }|dkrd|d  |d  d S dS )Nr"   é    r>   r?   r   r$   r   )r   rA   r&   r   r   r    r%   û   rC   z#EUCJPDistributionAnalysis.get_orderrD   r   r   r9   r    ra   ô   rF   ra   N)Úbig5freqr   r   r   Ú	euckrfreqr   r   r   Ú	euctwfreqr   r	   r
   Ú
gb2312freqr   r   r   Újisfreqr   r   r   Ú	johabfreqr   r   r6   rG   rJ   rP   rS   rX   ra   r   r   r   r    Ú<module>   s   J