관리-도구
편집 파일: chardistribution.cpython-36.pyc
3 �Pf�$ � @ s� d dl mZmZmZ d dlmZmZmZ d dlm Z m Z mZ d dlm Z mZmZ d dlmZmZmZ G dd� de�ZG dd � d e�ZG d d� de�ZG dd � d e�ZG dd� de�ZG dd� de�ZG dd� 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 @ sL e Zd ZdZdZdZdZdd� Zdd� Zd d � Z dd� Z d d� Zdd� ZdS )�CharDistributionAnalysisi g�G�z��?g{�G�z�?� c C s0 d | _ d | _d | _d | _d | _d | _| j� d S )N)�_char_to_freq_order�_table_size�typical_distribution_ratio�_done�_total_chars�_freq_chars�reset)�self� r �&/usr/lib/python3.6/chardistribution.py�__init__. s z!CharDistributionAnalysis.__init__c C s d| _ d| _d| _dS )zreset analyser, clear any stateF� N)r r r )r r r r r = s zCharDistributionAnalysis.resetc C sX |dkr| j |�}nd}|dkrT| jd7 _|| jk rTd| j| krT| jd7 _dS )z"feed a character with known length� r r i N���)� get_orderr r r r )r �charZchar_len�orderr r r �feedF s zCharDistributionAnalysis.feedc C sT | j dks| j| jkr| jS | j | jkrN| j| j | j | j }|| jk rN|S | jS )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 | jkS )N)r �ENOUGH_DATA_THRESHOLD)r r r r �got_enough_datad s z(CharDistributionAnalysis.got_enough_datac C s dS )Nr r r )r �byte_strr r r r! i s z"CharDistributionAnalysis.get_orderN) �__name__� __module__�__qualname__r* r'