zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
U
L±d,ã@sLddlZddlZddlmZmZddlmZmZe d¡Z    Gdd„dƒZ
dS)éN)ÚOptionalÚUnioné)ÚLanguageFilterÚ ProbingStates%[a-zA-Z]*[€-ÿ]+[a-zA-Z]*[^a-zA-Z€-ÿ]?c@sìeZdZdZejfeddœdd„Zddœdd„Zee    e
dœd    d
„ƒZ ee    e
dœd d „ƒZ e eefed œdd„Zeedœdd„ƒZedœdd„Zee eefedœdd„ƒZee eefedœdd„ƒZee eefedœdd„ƒZdS)Ú CharSetProbergffffffî?N)Ú lang_filterÚreturncCs$tj|_d|_||_t t¡|_dS)NT)    rÚ    DETECTINGÚ_stateÚactiverÚloggingÚ    getLoggerÚ__name__Úlogger)Úselfr©rúLd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\chardet/charsetprober.pyÚ__init__,szCharSetProber.__init__)r    cCs tj|_dS©N)rr
r ©rrrrÚreset2szCharSetProber.resetcCsdSrrrrrrÚ charset_name5szCharSetProber.charset_namecCst‚dSr©ÚNotImplementedErrorrrrrÚlanguage9szCharSetProber.language)Úbyte_strr    cCst‚dSrr)rrrrrÚfeed=szCharSetProber.feedcCs|jSr)r rrrrÚstate@szCharSetProber.statecCsdS)NgrrrrrÚget_confidenceDszCharSetProber.get_confidence)Úbufr    cCst dd|¡}|S)Ns([-])+ó )ÚreÚsub)r rrrÚfilter_high_byte_onlyGsz#CharSetProber.filter_high_byte_onlycCsZtƒ}t |¡}|D]@}| |dd…¡|dd…}| ¡sJ|dkrJd}| |¡q|S)u7
        We define three types of bytes:
        alphabet: english alphabets [a-zA-Z]
        international: international characters [€-ÿ]
        marker: everything else [^a-zA-Z€-ÿ]
        The input buffer can be thought to contain a series of words delimited
        by markers. This function works to filter all words that contain at
        least one international character. All contiguous sequences of markers
        are replaced by a single space ascii character.
        This filter applies to all scripts which do not use English characters.
        Néÿÿÿÿó€r!)Ú    bytearrayÚINTERNATIONAL_WORDS_PATTERNÚfindallÚextendÚisalpha)r ÚfilteredÚwordsÚwordÚ    last_charrrrÚfilter_international_wordsLs 
  z(CharSetProber.filter_international_wordscCs’tƒ}d}d}t|ƒ d¡}t|ƒD]R\}}|dkrB|d}d}q$|dkr$||krr|sr| |||…¡| d¡d}q$|sŽ| ||d    …¡|S)
a[
        Returns a copy of ``buf`` that retains only the sequences of English
        alphabet and high byte characters that are not between <> characters.
        This filter can be applied to all scripts which contain both English
        characters and extended ASCII characters, but is currently only used by
        ``Latin1Prober``.
        FrÚcó>ró<r!TN)r'Ú
memoryviewÚcastÚ    enumerater*)r r,Úin_tagÚprevÚcurrÚbuf_charrrrÚremove_xml_tagsns      
zCharSetProber.remove_xml_tags)rÚ
__module__Ú __qualname__ÚSHORTCUT_THRESHOLDrÚNONErrÚpropertyrÚstrrrrÚbytesr'rrrÚfloatrÚ staticmethodr$r0r;rrrrr(s"!r) r r"ÚtypingrrÚenumsrrÚcompiler(rrrrrÚ<module>sÿ