
    *pj/                        % S r SSKJr  SSKrSSKJr  SSKJr  0 S\" SS15      _S	\" S
S15      _S\" S15      _S\" S15      _S\" S15      _S\" SS15      _S\" SS15      _S\" S15      _S\" S15      _S\" S15      _S\" S15      _S\" S15      _S\" 1 Sk5      _S \" S!S"15      _S#\" S$15      _S%\" S15      _S&\" S'15      _\" S(15      \" S)15      \" S*15      \" S+15      \" S,15      \" S-15      \" S.S/15      \" S015      \" S015      \" S1S215      \" S315      \" S315      S4.Er	S5\
S6'   S7rS8\
S9'   S:rS8\
S;'   S< 4     SNS= jjr\" \5      rS5\
S>'   SOS? jr0 rS5\
S@'   \	R#                  5        HC  u  rr\" \5      =(       d    \r\" SA \ 5       5      r\R-                  \\" 5       5      \-  \\'   ME     \" \SB SC9rS5\
SD'   SPSE jrSPSF jrSQSG jr\" SHSI15      rSJ\
SK'   SRSL jr        SSSM jrg)Ta  Accuracy-evaluation tables and predicates.

Tools for asking *"is this detection acceptable, given what was expected?"*
Used by the test suite and by benchmarking/diagnostic scripts (e.g.,
``scripts/compare_detectors.py``, ``scripts/diagnose_accuracy.py``).

This module owns three kinds of tables:

1. **Directional supersets** (:data:`SUPERSETS`) -- detecting a superset
   encoding when the expected encoding is a subset is correct (e.g.,
   detecting UTF-8 when expected is ASCII), but not the reverse.

2. **Bidirectional encoding groups** (:data:`BIDIRECTIONAL_GROUPS`) --
   groups of encodings where any member is interchangeable with any other.

3. **Bidirectional language groups** (:data:`LANGUAGE_EQUIVALENCES`) --
   ISO 639-1 codes for languages that are nearly indistinguishable by
   statistical detection (e.g., Slovak/Czech, Malay/Indonesian).

The corresponding predicates are :func:`is_correct`,
:func:`is_equivalent_detection`, and :func:`is_language_equivalent`.
    )annotationsN)Callablelookup_encodingASCIIzutf-8cp1252zTIS-620z
iso8859-11cp874zISO-8859-11GB2312gb18030GBKBig5	big5hkscscp950	Shift_JIScp932shift_jis_2004zShift-JISX0213zEUC-JPeuc_jis_2004zEUC-JISX0213zEUC-KRcp949CP037cp1140zISO-2022-JP>   iso2022_jp_2iso2022_jp_extiso2022_jp_2004zISO2022-JP-1r   r   zISO2022-JP-3r   z
ISO-8859-1z
ISO-8859-2cp1250cp1251cp1256cp1253cp1255cp1254cp1257z	utf-16-lez	utf-16-bezutf-16z	utf-32-lez	utf-32-bezutf-32)z
ISO-8859-5z
ISO-8859-6z
ISO-8859-7z
ISO-8859-8z
ISO-8859-9zISO-8859-13zUTF-16z	UTF-16-LEz	UTF-16-BEzUTF-32z	UTF-32-LEz	UTF-32-BEdict[str, frozenset[str]]	SUPERSETS))r   r   r   tuple[tuple[str, ...], ...]BIDIRECTIONAL_GROUPS))skcs)ukrubgbe)msid)nodasvLANGUAGE_EQUIVALENCESc                    U $ N )xs    N/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/chardet/evaluation.py<lambda>r6   w   s        c                n   ^ 0 nU  H+  n[        U4S jU 5       5      nU H  nXBT" U5      '   M     M-     U$ )zJBuild a lookup: key -> frozenset of all equivalent keys in the same group.c              3  4   >#    U  H  nT" U5      v   M     g 7fr2   r3   ).0n	normalizes     r5   	<genexpr>%_build_group_index.<locals>.<genexpr>|   s     7A9Q<<s   )	frozenset)groupsr<   resultgroupnormednames    `    r5   _build_group_indexrE   u   sA    
 )+F777D&,9T?#   Mr7   _LANGUAGE_EQUIVc                V    X:X  a  g[         R                  U 5      nUSL=(       a    X;   $ )av  Check whether *detected* is an acceptable language for *expected*.

Returns ``True`` when *expected* and *detected* are the same ISO 639-1
code, or belong to the same equivalence group in
:data:`LANGUAGE_EQUIVALENCES`.

:param expected: Expected ISO 639-1 language code.
:param detected: Detected ISO 639-1 language code.
:returns: ``True`` if the languages are equivalent.
TN)rF   get)expecteddetectedrB   s      r5   is_language_equivalentrK      s0     )E2!22r7   _NORMALIZED_SUPERSETSc              #  J   #    U  H  n[        U5      =(       d    Uv   M     g 7fr2   r   )r:   ss     r5   r=   r=      s     DA*/a/s   !#c                *    [        U 5      =(       d    U $ r2   r   )r;   s    r5   r6   r6      s    oa.@.EA.Er7   )r<   _NORMALIZED_BIDIRc                    U c  USL $ Uc  g[        U 5      =(       d    U R                  5       n[        U5      =(       d    UR                  5       nX#:H  $ )a  Check whether *detected* names the very same encoding as *expected*.

Only alias and case differences are normalized away, so
``windows-1252`` matches ``cp1252``. Unlike :func:`is_correct`, this
credits neither supersets nor byte-order variants: detecting UTF-8
for an ASCII file is ``False`` here.

This is the stricter convention some other detectors score
themselves against. Reporting it alongside :func:`is_correct` makes
the two conventions directly comparable instead of leaving the
difference implicit.

:param expected: The expected encoding name, or ``None`` for binary files.
:param detected: The detected encoding name, or ``None``.
:returns: ``True`` if both names resolve to the same encoding.
NF)r   lowerrI   rJ   norm_expnorm_dets       r5   is_exact_matchrV      sS    " 4x(<HNN,<Hx(<HNN,<Hr7   c                *   U c  USL $ Uc  g[        X5      (       a  g[        U 5      =(       d    U R                  5       n[        U5      =(       d    UR                  5       nU[        ;   a  U[        U   ;   a  gU[        ;   =(       a    U[        U   ;   $ )a  Check whether *detected* is an acceptable answer for *expected*.

Acceptable means:

1. Exact match (after normalization), OR
2. Both belong to the same bidirectional byte-order group, OR
3. *detected* is a known superset of *expected*.

See :func:`is_exact_match` for the stricter exact-only predicate.

:param expected: The expected encoding name, or ``None`` for binary files.
:param detected: The detected encoding name, or ``None``.
:returns: ``True`` if the detection is acceptable.
NFT)rV   r   rR   rP   rL   rS   s       r5   
is_correctrX      s     4 h))x(<HNN,<Hx(<HNN,<H $$5Fx5P)P 	)) 	8-h77r7   c                `    [         R                  " SU 5      nSR                  S U 5       5      $ )z4NFKD-normalize *text* and strip all combining marks.NFKD c              3  `   #    U  H$  n[         R                  " U5      (       a  M   Uv   M&     g 7fr2   )unicodedata	combining)r:   cs     r5   r=   #_strip_combining.<locals>.<genexpr>   s     Cd+*?*?*B11ds   .	.)r]   r<   join)textnfkds     r5   _strip_combiningrd      s)      .D77CdCCCr7   )   ¤   €)rf   re   zfrozenset[tuple[str, str]]_EQUIVALENT_SYMBOL_PAIRSc                T    X:X  a  gX4[         ;   a  g[        U 5      [        U5      :H  $ )u   Return True if characters *a* and *b* are functionally equivalent.

Equivalent means:
- Same character, OR
- Same base letter after stripping combining marks, OR
- An explicitly listed symbol equivalence (e.g. ¤ ↔ €)
T)rg   rd   )abs     r5   _chars_equivalentrk      s0     	v	v))A"21"555r7   c           	        Uc  USL $ Uc  g[        U5      =(       d    UR                  5       n[        U5      =(       d    UR                  5       nX4:X  a  g U R                  U5      nU R                  U5      nXV:X  a  g[        U5      [        U5      :w  a  g[        S [        XVSS9 5       5      $ ! [        [        4 a     gf = f)uU  Check whether *detected* produces functionally identical text to *expected*.

Returns ``True`` when:

1. *detected* is not ``None`` and both encoding names normalize to the same
   codec, OR
2. Decoding *data* with both encodings yields identical strings, OR
3. Every differing character pair is functionally equivalent: same base
   letter after stripping combining marks, or an explicitly listed symbol
   equivalence (e.g. ¤ ↔ €).

Returns ``False`` if *detected* is ``None``, either encoding is unknown,
or either encoding cannot decode *data*.

:param data: The raw byte data that was detected.
:param expected: The expected encoding name, or ``None`` for binary files.
:param detected: The detected encoding name, or ``None``.
:returns: ``True`` if decoding with *detected* yields functionally identical
    text to decoding with *expected*.
NFTc              3  <   #    U  H  u  p[        X5      v   M     g 7fr2   )rk   )r:   ri   rj   s      r5   r=   *is_equivalent_detection.<locals>.<genexpr>4  s     X3W41 &&3Ws   )strict)r   rR   decodeUnicodeDecodeErrorLookupErrorlenallzip)datarI   rJ   rT   rU   text_exptext_dets          r5   is_equivalent_detectionry     s    . 4x(<HNN,<Hx(<HNN,<H;;x(;;x( 
8}H%X3xRV3WXXX , s   "B2 2CC)r@   r#   r<   zCallable[[str], str]returnr!   )rI   strrJ   r{   rz   bool)rI   
str | NonerJ   r}   rz   r|   )rb   r{   rz   r{   )ri   r{   rj   r{   rz   r|   )rv   bytesrI   r}   rJ   r}   rz   r|   )__doc__
__future__r   r]   collections.abcr   chardet.registryr   r?   r"   __annotations__r$   r0   rE   rF   rK   rL   items_subset
_supersets_key_normedrH   rP   rV   rX   rd   rg   rk   ry   r3   r7   r5   <module>r      sB  . #  $ ,+(Y*++(y,01+( 9gY'+( i$	+(
 
9i[!+( I{G,-+( G%567+( i!1 23+( i()+( I~./+( i	"+( Yz"+(. 9RS/+(0 I~/?@A1+(2 I0123+(6 )XJ'7+(8 )XJ'9+(: XJ'XJ'XJ'XJ'XJ'hZ( k23H:&H:&k23H:&H:&U+(	$ +h5 1 6 2 & '2
'
#
 
 .@@U-V* V3* 46 0 5$??,GZ7#.wDDDDG"7";";D)+"NQX"X$ - 0B$E0 , 
 4#LD 8A8 4 6 .Y
.Y%.Y1;.Y	.Yr7   