§
    |Øj$  ã                   ó€   — d Z ddlmZmZmZmZmZmZ ddlm	Z	 dZ
dedededz  fd	„Zded
ee	         dee	         fd„ZdS )aß  Three-tier language detection for filling DetectionResult languages.

Tier 1: hardcoded mapping for single-language encodings (e.g. Big5 -> Chinese).
Tier 2: statistical bigram scoring against the encoding's language-model variants.
Tier 3: decode to UTF-8 and score against the UTF-8 byte-level language models.

Note: ``from __future__ import annotations`` is intentionally omitted because
this module is compiled with mypyc, which does not support PEP 563 string
annotations.
é    )Ú_THIN_RARE_MAX_BYTESÚRARE_LANGUAGESÚBigramProfileÚhas_model_variantsÚinfer_languageÚscore_best_language)ÚDetectionResulti   ÚdataÚencodingÚreturnNc                 ó¨   — |dk    r| S 	 |                       |d¬¦  «                             dd¬¦  «        S # t          t          t          f$ r Y dS w xY w)aP  Decode data from encoding and re-encode as UTF-8 for language scoring.

    Returns None if the encoding is unknown. For UTF-8, returns data as-is.
    Uses ``errors="ignore"`` because the data already passed byte-validity
    filtering for the detected encoding; any residual invalid bytes are
    irrelevant for language scoring.
    úutf-8Úignore)ÚerrorsÚsurrogatepassN)ÚdecodeÚencodeÚLookupErrorÚ	TypeErrorÚ
ValueError)r
   r   s     úŽ/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/chardet/pipeline/language.pyÚ_to_utf8r      sv   € ð �7ÒÐØˆðØ�{Š{˜8¨Hˆ{Ñ5Ô5×<Ò<Ø˜Oð =ñ 
ô 
ð 	
øõ �¥JÐ/ð ð ð Øˆtˆtðøøøs   Š+6 ¶AÁAÚresultsc           	      ó’  — | dt           …         } dt          | ¦  «        cxk     o
t          k     nc }g }d}d}d}|D �]‰}|o|j        duo|j        t          v o|j        du}|j        �	|j        �|s|                     |¦  «         ŒK|j        }	|rdnt          |	¦  «        }
|
€>| r<t          |	¦  «        r-|€t          j
        | ¦  «        }t          | |	||d¬¦  «        \  }}
|o|
duo|
t          v }|
�|re| rct          d¦  «        rTt          | |	¦  «        }|rB||k    rt          j
        |¦  «        }|}t          |d||d¬¦  «        \  }}|
�|�|t          vr|}
|r"|
�	|
t          v r|                     |¦  «         �ŒA|
€|                     |¦  «         �ŒZ|                     t          |	|j        |
|j        ¦  «        ¦  «         �Œ‹|S )u}  Fill missing ``language`` fields on text results via the three-tier algorithm.

    Tier 1: single-language encodings via hardcoded map (instant).
    Tier 2: multi-language encodings via statistical bigram scoring (lazy).
    Tier 3: decode to UTF-8, score against UTF-8 language models (universal fallback).

    Tiers 2 and 3 score in the IDF-weighted space of
    :meth:`~chardet.models.BigramProfile.for_language`, not the plain
    cosine the encoding ranking uses: with 49 languages in play, the plain
    cosine let the UTF-8 bigram for ``Ã©`` alone hand French text to
    Hungarian.

    Binary results (``encoding is None``) are passed through unchanged, as
    are results that already have a non-``None`` language â€” except a
    :data:`~chardet.models.RARE_LANGUAGES` label on a thin input, which is
    re-derived through the same scoring so the thin-rare demotion band
    applies to statistically-attached labels too, not only to labels this
    function computes.  A re-derivation can only *demote* to a prevalent
    language; it never swaps one rare label for another.

    :param data: The raw byte data the results were produced from.  Truncated
        to the first 2 KB internally â€” bigram language models converge quickly.
    :param results: A list of :class:`DetectionResult` from the pipeline.
    :returns: A list of results with ``language`` filled in where possible.
    Nr   T)ÚprofileÚdemote_thin_rareÚlanguage_weightingr   )Ú_LANG_SCORE_MAX_BYTESÚlenr   Úlanguager   r   Úappendr   r   r   Úfor_languager   r   r	   Ú
confidenceÚ	mime_type)r
   r   ÚthinÚfilledr   Úutf8_profileÚutf8_profile_srcÚresultÚrecheckr   ÚlangÚ_ÚescalateÚ	utf8_dataÚ	utf8_langs                  r   Úfill_languagesr0   .   sg  € ð8 Ð&Õ&Ð&Ô'€Dð
 �s�4‰yŒyÐ/Ð/Ò/Ð/Õ/Ò/Ð/Ð/Ð/€DØ$&€FØ$(€GØ)-€LØ%)ÐØð ;ñ ;ˆàð ,Ø” tÐ+ð,à”¥>Ð1ð,ð ” tÐ+ð	 	ð Œ?Ð" v¤Ð'BÈ7Ð'BØ�MŠM˜&Ñ!Ô!Ð!ØØ”?ˆð Ð<ˆtˆt¥N°8Ñ$<Ô$<ˆàˆ<˜Dˆ<Õ%7¸Ñ%AÔ%Aˆ<ØˆÝ'Ô4°TÑ:Ô:�Ý)ØØØØ!%Ø#'ðñ ô ‰GˆAˆtð ÐG˜D¨Ð,ÐG°½Ð1GˆØˆL˜HˆL¨$ˆLÕ3EÀgÑ3NÔ3NˆLÝ   xÑ0Ô0ˆIØð %ØÐ 0Ò0Ð0Ý#0Ô#=¸iÑ#HÔ#H�LØ'0Ð$Ý2ØØØ(Ø%)Ø'+ð ñ  ô  ‘��9ð �<ØÐ)¨i½~Ð.MÐ.Mà$�DØð 
	˜˜¨µÐ(>Ð(>ð �MŠM˜&Ñ!Ô!Ð!Ñ!Øˆ\Ø�MŠM˜&Ñ!Ô!Ð!Ñ!à�MŠMÝ ¨&Ô*;¸TÀ6ÔCSÑTÔTñô ð ñ ð €Mó    )Ú__doc__Úchardet.modelsr   r   r   r   r   r   Úchardet.pipeliner	   r   ÚbytesÚstrr   Úlistr0   © r1   r   ú<module>r9      sñ   ðð	ð 	ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð -Ð ,Ð ,Ð ,Ð ,Ð ,ð
 Ð ð�5ð  Cð ¨E°D©Lð ð ð ð ð$bØ
ðbØ˜Ô/ðbà	ˆ/Ôðbð bð bð bð bð br1   