+
    WBi :                         R t ^ RIt^ RIt^ RIt^ RIHtHtHt ^RIH	t	 ^RI
Ht ^RIHtHtHt ^RIHt ^RIHt ^RIHt ^R	IHt ^R
IHt ^RIHt ^RIHt  ! R R4      tR# )a  
Module containing the UniversalDetector detector class, which is the primary
class a user of ``chardet`` should use.

:author: Mark Pilgrim (initial port to Python)
:author: Shy Shalom (original C code)
:author: Dan Blanchard (major refactoring for 3.0)
:author: Ian Cordasco
N)ListOptionalUnion)CharSetGroupProber)CharSetProber)
InputStateLanguageFilterProbingState)EscCharSetProber)Latin1Prober)MacRomanProber)MBCSGroupProber
ResultDict)SBCSGroupProber)UTF1632Proberc                     a  ] tR t^8t o RtRt]P                  ! R4      t]P                  ! R4      t	]P                  ! R4      t
RRRR	R
RRRRRRRRRRR/tRRRRRRRRRRRRRR/t]P                  R3V 3R  lR! llt]V 3R" lR# l4       t]V 3R$ lR% l4       t]V 3R& lR' l4       tV 3R( lR) ltV 3R* lR+ ltV 3R, lR- ltR.tV tR/# )0UniversalDetectoraI  
The ``UniversalDetector`` class underlies the ``chardet.detect`` function
and coordinates all of the different charset probers.

To get a ``dict`` containing an encoding and its confidence, you can simply
run:

.. code::

        u = UniversalDetector()
        u.feed(some_bytes)
        u.close()
        detected = u.result

g?s   [-]s   (|~{)s   [-]z
iso-8859-1zWindows-1252z
iso-8859-2zWindows-1250z
iso-8859-5zWindows-1251z
iso-8859-6zWindows-1256z
iso-8859-7zWindows-1253z
iso-8859-8zWindows-1255z
iso-8859-9zWindows-1254ziso-8859-13zWindows-1257asciiztis-620zISO-8859-11gb2312GB18030zeuc-krCP949zutf-16leUTF-16Fc                *   < V ^8  d   QhRS[ RS[RR/# )   lang_filtershould_rename_legacyreturnN)r   bool)format__classdict__s   ">/usr/lib/python3.14/site-packages/chardet/universaldetector.py__annotate__UniversalDetector.__annotate__d   s)      # # 
	    c                "   R V n         R V n        . V n        RR RRRR /V n        RV n        RV n        \        P                  V n        RV n	        Wn
        \        P                  ! \        4      V n        RV n        W n        V P#                  4        R # )Nencoding
confidence        languageFr$   )_esc_charset_prober_utf1632_prober_charset_probersresultdone	_got_datar   
PURE_ASCII_input_state
_last_charr   logging	getLogger__name__logger_has_win_bytesr   reset)selfr   r   s   &&&r!   __init__UniversalDetector.__init__d   s    
 @D 8<57##

 	&11&''1#$8!

r$   c                    < V ^8  d   QhRS[ /# r   r   )int)r   r    s   "r!   r"   r#   |   s     ! !S !r$   c                    V P                   # N)r1   r9   s   &r!   input_stateUniversalDetector.input_state{   s       r$   c                    < V ^8  d   QhRS[ /# r=   )r   )r   r    s   "r!   r"   r#      s     # #t #r$   c                    V P                   # r@   )r7   rA   s   &r!   has_win_bytesUniversalDetector.has_win_bytes   s    """r$   c                0   < V ^8  d   QhRS[ S[,          /# r=   )r   r   )r   r    s   "r!   r"   r#      s     % %m!4 %r$   c                    V P                   # r@   )r,   rA   s   &r!   charset_probers!UniversalDetector.charset_probers   s    $$$r$   c                   < V ^8  d   QhRR/# )r   r   N )r   r    s   "r!   r"   r#      s      t r$   c                x   RRRRRR/V n         RV n        RV n        RV n        \        P
                  V n        RV n        V P                  '       d   V P                  P                  4        V P                  '       d   V P                  P                  4        V P                   F  pVP                  4        K  	  R# )z
Reset the UniversalDetector and all of its probers back to their
initial states.  This is called by ``__init__``, so you only need to
call this directly in between analyses of different documents.
r&   Nr'   r(   r)   Fr$   )r-   r.   r/   r7   r   r0   r1   r2   r*   r8   r+   r,   )r9   probers   & r!   r8   UniversalDetector.reset   s     "4sJM	#&11###$$**,  &&(++FLLN ,r$   c                :   < V ^8  d   QhRS[ S[S[3,          RR/# )r   byte_strr   N)r   bytes	bytearray)r   r    s   "r!   r"   r#      s)     A+ A+U5)#34 A+ A+r$   c                
   V P                   '       d   R# V'       g   R# \        V\        4      '       g   \        V4      pV P                  '       Eg(   VP	                  \
        P                  4      '       d   RRRRRR/V n        MVP	                  \
        P                  \
        P                  34      '       d   RRRRRR/V n        MVP	                  R	4      '       d   RR
RRRR/V n        MgVP	                  R4      '       d   RRRRRR/V n        MBVP	                  \
        P                  \
        P                  34      '       d   RRRRRR/V n        RV n        V P                  R,          e
   RV n         R# V P                  \        P                  8X  d   V P                  P!                  V4      '       d   \        P"                  V n        MfV P                  \        P                  8X  dH   V P$                  P!                  V P&                  V,           4      '       d   \        P(                  V n        VRR V n        V P*                  '       g   \-        4       V n        V P*                  P.                  \0        P2                  8X  dq   V P*                  P5                  V4      \0        P6                  8X  dC   RV P*                  P8                  RV P*                  P;                  4       RR/V n        RV n         R# V P                  \        P(                  8X  d   V P<                  '       g   \?        V P@                  4      V n        V P<                  P5                  V4      \0        P6                  8X  dW   RV P<                  P8                  RV P<                  P;                  4       RV P<                  PB                  /V n        RV n         R# R# V P                  \        P"                  8X  EdY   V PD                  '       g   \G        V P@                  4      .V n"        V P@                  \H        PJ                  ,          '       d$   V PD                  PM                  \O        4       4       V PD                  PM                  \Q        4       4       V PD                  PM                  \S        4       4       V PD                   F_  pVP5                  V4      \0        P6                  8X  g   K)  RVP8                  RVP;                  4       RVPB                  /V n        RV n          M	  V PT                  P!                  V4      '       d
   RV n+        R# R# R# )a  
Takes a chunk of a document and feeds it through all of the relevant
charset probers.

After calling ``feed``, you can check the value of the ``done``
attribute to see if you need to continue feeding the
``UniversalDetector`` more data, or if it has made a prediction
(in the ``result`` attribute).

.. note::
   You should always call ``close`` when you're done feeding in your
   document if ``done`` is not already ``True``.
Nr&   z	UTF-8-SIGr'         ?r)    zUTF-32s     zX-ISO-10646-UCS-4-3412s     zX-ISO-10646-UCS-4-2143r   T),r.   
isinstancerT   r/   
startswithcodecsBOM_UTF8r-   BOM_UTF32_LEBOM_UTF32_BEBOM_LEBOM_BEr1   r   r0   HIGH_BYTE_DETECTORsearch	HIGH_BYTEESC_DETECTORr2   	ESC_ASCIIr+   r   stater	   	DETECTINGfeedFOUND_ITcharset_nameget_confidencer*   r
   r   r)   r,   r   r   NON_CJKappendr   r   r   WIN_BYTE_DETECTORr7   )r9   rR   rO   s   && r!   rh   UniversalDetector.feed   s-    999(I.. *H ~~~""6??33  #
 $$f&9&96;N;N%OPP  *8\3
TVW$$%899  8 #	 $$%899  8 #	 $$fmmV]]%CDD  *8\3
TVW!DN{{:&2 	 
 5 55&&--h77$.$8$8!!!Z%:%::%%,,T__x-GHH$.$8$8!"23- ####0?D %%)?)??##((2l6K6KK 4 4 A A $"6"6"E"E"G
 !	 
 4 44++++;D<L<L+M('',,X6,:O:OO 8 8 E E $":":"I"I"K 8 8 A A
 !	 P *"6"66((()89I9I)J(K%##n&<&<<<))001BC%%,,\^<%%,,^-=>//;;x(L,A,AA"F$7$7$f&;&;&="FOO#DK
 !%DI 0 %%,,X66&*# 7# 7r$   c                    < V ^8  d   QhRS[ /# r=   r   )r   r    s   "r!   r"   r#     s     M Mz Mr$   c           	        V P                   '       d   V P                  # RV n         V P                  '       g   V P                  P	                  R4       EMxV P
                  \        P                  8X  d   RRRRRR/V n        EMJV P
                  \        P                  8X  Ed+   R	pR
pR	pV P                   F)  pV'       g   K  VP                  4       pW8  g   K%  TpTpK+  	  V'       d   W P                  8  d   VP                  pVf   Q hVP                  4       pVP                  4       pVP                  R4      '       d.   V P                  '       d   V P                   P#                  We4      pV P$                  '       d5   V P&                  P#                  T;'       g    RP                  4       V4      pRVRVRVP(                  /V n        V P                  P+                  4       \,        P.                  8:  d   V P                  R,          f   V P                  P	                  R4       V P                   F  pV'       g   K  \1        V\2        4      '       dV   VP4                   FC  pV P                  P	                  RVP                  VP(                  VP                  4       4       KE  	  Kx  V P                  P	                  RVP                  VP(                  VP                  4       4       K  	  V P                  # )z
Stop analyzing the current document and come up with a final
prediction.

:returns:  The ``result`` attribute, a ``dict`` with the keys
           `encoding`, `confidence`, and `language`.
Tzno data received!r&   r   r'   rV   r)   rW   Nr(   ziso-8859z no probers hit minimum thresholdz%s %s confidence = %s)r.   r-   r/   r6   debugr1   r   r0   rc   r,   rk   MINIMUM_THRESHOLDrj   lowerrZ   r7   ISO_WIN_MAPgetr   
LEGACY_MAPr)   getEffectiveLevelr3   DEBUGrY   r   probers)	r9   prober_confidencemax_prober_confidence
max_proberrO   rj   lower_charset_namer'   group_probers	   &        r!   closeUniversalDetector.close  sy    999;;	~~~KK12 *"7"77%wc:rRDK *"6"66 $$'!J//$*$9$9$;!$<,=)!'J 0 47M7MM)66#///%1%7%7%9"'668
 &00<<***'+'7'7';';.( ,,,#'??#6#6%++224l$L  *
 3 3 ;;((*gmm;{{:&.!!"DE$($9$9L' !,0BCC&2&:&:F KK-- 7 & 3 3 & & 5 5 7	 '; ))3(55(11(779	 %:$ {{r$   )r,   r*   r/   r7   r1   r2   r+   r.   r   r6   r-   r   N)r5   
__module____qualname____firstlineno____doc__rs   recompilera   rd   rn   ru   rw   r   ALLr:   propertyrB   rF   rJ   r8   rh   r   __static_attributes____classdictcell__)r    s   @r!   r   r   8   s      N3::l+L

>2nnnnnnn~	K 	n=n)'HJ '5&8&8%* . ! ! # # % % &A+ A+FM Mr$   r   )r   r[   r3   r   typingr   r   r   charsetgroupproberr   charsetproberr   enumsr   r   r	   	escproberr
   latin1proberr   macromanproberr   mbcsgroupproberr   
resultdictr   sbcsgroupproberr   utf1632proberr   r   rM   r$   r!   <module>r      sH   8   	 ( ( 2 ( ; ; ' & * , " , (r rr$   