+
    œ°³j–<  ã                   óö  € ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
HtHtHt ^ RIHtHt ]P"                  P%                  ]4      t]P"                  P)                  ]R4      t]! ]4      ;_uu_ 4       t]P1                  4       tRRR4        ! R R4      t]
],          t]
]],          ,          t ! R R	]4      t ! R
 R4      t ! R R4      t  ! R R4      t!]3R R llt"R#   + '       g   i     Lg; i)é    N)ÚTemplate)ÚAnyÚCallableÚDictÚListÚ
NamedTupleÚOptionalÚTuple)ÚEncodingÚ	Tokenizerzvisualizer-styles.cssc                   ó>   a € ] tR t^t o V 3R lR ltV 3R ltRtV tR# )Ú
Annotationc                ó,   <€ V ^8„  d   QhRS[ RS[ RS[/# ©é   ÚstartÚendÚlabel©ÚintÚstr)ÚformatÚ__classdict__s   "€Ú\/home/luca/screen-checking/.venv/lib/python3.14/site-packages/tokenizers/tools/visualizer.pyÚ__annotate__ÚAnnotation.__annotate__   s"   ø€ ÷ ñ ™cð ©ð ±Cñ ó    c                ó*   € Wn         W n        W0n        R # ©N)r   r   r   )Úselfr   r   r   s   &&&&r   Ú__init__ÚAnnotation.__init__   s   € ØŒ
ØŒØŽ
r   c                ó>   <€ V ^8„  d   Qh/ S[ ;R&   S[ ;R&   S[;R&   # r   r   )r   r   s   "€r   r   r      s%   ø‡ ‚ Ù�Jñ á	�Hñ ñ �Jò r   )r   r   r   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r!   Ú__annotate_func__Ú__static_attributes__Ú__classdictcell__©r   s   @r   r   r      s   ø‡ € ÷
ð ÷ ƒ r   r   c                   ó,   a € ] tR t^t o V 3R ltRtV tR# )ÚCharStateKeyc                óR   <€ V ^8„  d   Qh/ S[ S[,          ;R&   S[ S[,          ;R&   # )r   Útoken_ixÚanno_ix©r	   r   )r   r   s   "€r   r   ÚCharStateKey.__annotate__   s#   ø‡ ‚ Ù‘s�mÑñ á‘c�]Ñò r   © N)r$   r%   r&   r'   r(   r)   r*   r+   s   @r   r-   r-      s   ø‡ ‡ „ r   r-   c                   ód   a € ] tR t^$t o R t]R 4       t]R 4       tV 3R lR ltV 3R lt	Rt
V tR# )	Ú	CharStatec                ó.   € Wn         R V n        . V n        R # r   )Úchar_ixr0   Útokens)r    r7   s   &&r   r!   ÚCharState.__init__'   s   € ØŒà&*ˆŒØ!#ˆŽr   c                ó`   € \        V P                  4      ^ 8”  d   V P                  ^ ,          # R# )r   N©Úlenr8   ©r    s   &r   r/   ÚCharState.token_ix-   s%   € ä!$ T§[¡[Ó!1°AÔ!5ˆt�{‰{˜1�~Ð?¸4Ð?r   c                ó2   € \        V P                  4      ^8„  # )z:
BPE tokenizers can output more than one token for a char
r;   r=   s   &r   Úis_multitokenÚCharState.is_multitoken1   s   € ô
 �4—;‘;Ó !Ñ#Ð#r   c                ó    <€ V ^8„  d   QhRS[ /# )r   Úreturn)r-   )r   r   s   "€r   r   ÚCharState.__annotate__8   s   ø€ ÷ 
ñ 
™|ñ 
r   c                óD   € \        V P                  V P                  R 7      # ))r/   r0   )r-   r/   r0   r=   s   &r   Úpartition_keyÚCharState.partition_key8   s   € ÜØ—]‘]Ø—L‘Lô
ð 	
r   c                ó6   <€ V ^8„  d   Qh/ S[ S[,          ;R&   # )r   r7   r1   )r   r   s   "€r   r   rD   $   s   ø‡ ‚ Ù‘c�]Ñò r   )r0   r7   r8   N)r$   r%   r&   r'   r!   Úpropertyr/   r@   rF   r(   r)   r*   r+   s   @r   r5   r5   $   sE   ø‡ € ò$ð ñ@ó ð@ð ñ$ó ð$÷
ð 
÷) ƒ r   r5   c                   ó   € ] tR t^?tRtR# )ÚAlignedr3   N)r$   r%   r&   r'   r)   r3   r   r   rK   rK   ?   s   † Ûr   rK   c                   ó  a € ] tR t^Ct o Rt]P                  ! R]P                  R7      tRV 3R lR llt	R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4       t]V 3R lR l4       tRtV tR# )ÚEncodingVisualizera‹  
Build an EncodingVisualizer

Args:

     tokenizer (:class:`~tokenizers.Tokenizer`):
        A tokenizer instance

     default_to_notebook (:obj:`bool`):
        Whether to render html output in a notebook by default

     annotation_converter (:obj:`Callable`, `optional`):
        An optional (lambda) function that takes an annotation in any format and returns
        an Annotation object
z(.{1})?(unk|oov)(.{1})?)ÚflagsNc          	      óT   <€ V ^8„  d   QhRS[ RS[RS[S[S[.S[3,          ,          /# )r   Ú	tokenizerÚdefault_to_notebookÚannotation_converter)r   Úboolr	   r   r   r   )r   r   s   "€r   r   ÚEncodingVisualizer.__annotate__V   s:   ø€ ÷ ñ áðñ "ðñ '¡x±°±zÐ0AÕ'BÕCñ	r   c                óº   € V'       d
    ^ RI HpHp Wn        W n        W0n        R#   \         d*     ^ RIHpHp  L*  \         d    Rp\        T4      Rhi ; ii ; i)r   ©ÚHTMLÚdisplayú–We couldn't import IPython utils for html display.
Are you running in a notebook?
You can also pass `default_to_notebook=False` to get back raw HTML.
N)ÚIPython.displayrW   rX   ÚImportErrorÚIPython.core.displayrP   rQ   Úannotation_coverter)r    rP   rQ   rR   rW   rX   Úmsgs   &&&&   r   r!   ÚEncodingVisualizer.__init__V   sj   € ÷ ð5ß9ð #ŒØ#6Ô Ø#7Ô Ùøô ô 	5ð5ßBÑBøÜ"ô 5ð`ð ô
 & cÓ*°Ð4ð5úð	5ús   Š& ¦A²<¼AÁAc          	      ór   <€ V ^8„  d   QhRS[ RS[S[S[,          ,          RS[S[,          RS[S[ ,          /# )r   ÚtextÚannotationsrQ   rC   )r   r	   r   r   rS   )r   r   s   "€r   r   rT   n   sD   ø€ ÷ 2ñ 2áð2ñ ™d¡3�iÕ(ð2ñ &¡d�^ð	2ñ
 
‘#�ñ2r   c                ó²  € V P                   pVe   TpV'       d
    ^ RIHpHp Vf   . pV P                  e    \        \        V P                  V4      4      pV P                  P                  V4      p\        P                  WV4      p	V'       d   X! X! V	4      4       R# V	#   \         d*     ^ RIHpHp  L”  \         d    Rp\	        T4      Rhi ; ii ; i)aw  
Build a visualization of the given text

Args:
    text (:obj:`str`):
        The text to tokenize

    annotations (:obj:`List[Annotation]`, `optional`):
        An optional list of annotations of the text. The can either be an annotation class
        or anything else if you instantiated the visualizer with a converter function

    default_to_notebook (:obj:`bool`, `optional`, defaults to `False`):
        If True, will render the html in a notebook. Otherwise returns an html string.

Returns:
    The HTML string if default_to_notebook is False, otherwise (default) returns None and
    renders the HTML in the notebook

NrV   rY   )rQ   rZ   rW   rX   r[   r\   r]   ÚlistÚmaprP   ÚencoderM   Ú_EncodingVisualizer__make_html)
r    ra   rb   rQ   Úfinal_default_to_notebookrW   rX   r^   ÚencodingÚhtmls
   &&&&      r   Ú__call__ÚEncodingVisualizer.__call__n   sÖ   € ð2 %)×$<Ñ$<Ð!ØÒ*Ø(;Ð%ß$ð5ß9ð ÒØˆKØ×#Ñ#Ò/Üœs 4×#;Ñ#;¸[ÓIÓJˆKØ—>‘>×(Ñ(¨Ó.ˆÜ!×-Ñ-¨d¸kÓJˆß$Ù‘D˜“JÖàˆKøô' ô 	5ð5ßBÑBøÜ"ô 5ð`ð ô
 & cÓ*°Ð4ð5úð	5ús   œB" Â"CÂ.B8Â8CÃCc                ó<   <€ V ^8„  d   QhRS[ RS[S[S[3,          /# )r   rb   rC   )ÚAnnotationListr   r   )r   r   s   "€r   r   rT   £   s#   ø€ ÷ ñ ©Nð ¹tÁCÉÀH½~ñ r   c                ó  € \        V 4      ^ 8X  d   / # \        \        R V 4      4      p\        V4      p\        ^ÿV,          4      pV^8  d   ^p^ p^@p^
p/ p\	        V4       F  pRV RV RV R2Wx&   Wc,          pK  	  V# )zß
Generates a color palette for all the labels in a given set of annotations

Args:
  annotations (:obj:`Annotation`):
    A list of annotations

Returns:
    :obj:`dict`: A dictionary mapping labels to colors in HSL format
c                 ó   € V P                   # r   )r   )Úxs   &r   Ú<lambda>Ú;EncodingVisualizer.calculate_label_colors.<locals>.<lambda>°   s   €  1§7¢7r   zhsl(Ú,z%,z%))r<   Úsetre   r   Úsorted)	rb   ÚlabelsÚ
num_labelsÚh_stepÚsÚlÚhÚcolorsr   s	   &        r   Úcalculate_label_colorsÚ)EncodingVisualizer.calculate_label_colors¢   s˜   € ô ˆ{Ó˜qÔ ØˆIÜ”SÑ*¨KÓ8Ó9ˆÜ˜“[ˆ
Ü�S˜:Õ%Ó&ˆØ�BŒ;ØˆFØˆØˆØˆØˆä˜F–^ˆEØ" 1 # Q q c¨¨A¨3¨bÐ1ˆF‰MØ�KŠAñ $ð ˆr   c                ó<   <€ V ^8„  d   QhRS[ S[,          RS[RS[/# )r   Úconsecutive_chars_listra   ri   )r   r5   r   r   )r   r   s   "€r   r   rT   À   s0   ø€ ÷ D9ñ D9Ù $¡Y¥ðD9áðD9ñ ñD9r   c                óÔ  € V ^ ,          pVP                   f$   VP                  VP                  ,          pRV R2# V R,          pVP                   f   Q hVP                   f   Q hVP                   pVP                   ^,           pWV p. p	/ p
VP                  eß   V	P                  R4       VP                  '       d   V	P                  R4       VP                  ^,          '       d   V	P                  R4       MV	P                  R4       \
        P                  P                  VP                  VP                  ,          4      e2   V	P                  R4       VP                  VP                  ,          V
R&   MV	P                  R	4       R
RP                  V	4       R2pRpV
P                  4        F  w  rÞVRV RV R2,          pK  	  \        P                  ! V4      pRV RV RV R2# )as  
Converts a list of "consecutive chars" into a single HTML element.
Chars are consecutive if they fall under the same word, token and annotation.
The CharState class is a named tuple with a "partition_key" method that makes it easy to
compare if two chars are consecutive.

Args:
    consecutive_chars_list (:obj:`List[CharState]`):
        A list of CharStates that have been grouped together

    text (:obj:`str`):
        The original text being processed

    encoding (:class:`~tokenizers.Encoding`):
        The encoding returned from the tokenizer

Returns:
    :obj:`str`: The HTML span for a set of consecutive chars
z(<span class="special-token" data-stoken=z></span>Útokenzmulti-tokenz	odd-tokenz
even-tokenzspecial-tokenÚstokz	non-tokenzclass="Ú Ú"Ú z data-z="z<span z >ú</span>éÿÿÿÿ)r7   r8   r/   Úappendr@   rM   Úunk_token_regexÚsearchÚjoinÚitemsrj   Úescape)r�   ra   ri   ÚfirstÚstokenÚlastr   r   Ú	span_textÚcss_classesÚ
data_itemsÚcssÚdataÚkeyÚvals   &&&            r   Úconsecutive_chars_to_htmlÚ,EncodingVisualizer.consecutive_chars_to_html¿   s¾  € ð2 ' qÕ)ˆØ�=‰=Ò à—_‘_ U§^¡^Õ4ˆFð >¸f¸XÀXÐNÐNà% bÕ)ˆØ�}‰}Ò(Ð(Ð(Ø�|‰|Ò'Ð'Ð'Ø—‘ˆØ�l‰l˜QÕˆØ˜s�Oˆ	ØˆØˆ
Ø�>‰>Ò%à×Ñ˜wÔ'Ø×"×"Ð"Ø×"Ñ" =Ô1Ø�~‰~ ×!Ô!ð
 ×"Ñ" ;Õ/ð ×"Ñ" <Ô0Ü!×1Ñ1×8Ñ8¸¿¹ÈÏÉÕ9XÓYÒeà×"Ñ" ?Ô3à%-§_¡_°U·^±^Õ%D�
˜6Ñ"øð ×Ñ˜{Ô+Ø˜#Ÿ(™( ;Ó/Ð0°Ð4ˆØˆØ"×(Ñ(Ö*‰HˆCØ�f˜S˜E  C 5¨Ð*Õ*ŠDñ +ä—K’K 	Ó*ˆ	Ø˜�u˜A˜d˜V 2 i [°Ð8Ð8r   c                ó2   <€ V ^8„  d   QhRS[ RS[RS[RS[ /# ©r   ra   ri   rb   rC   )r   r   rn   )r   r   s   "€r   r   rT     s0   ø€ ÷ Dñ D™#ð D©ð DÁð DÑSVñ Dr   c           	     óÂ  € \         P                  WV4      pV^ ,          .pV^ ,          P                  p. p\         P                  V4      pV^ ,          P                  pVe5   W(,          p	V	P                  p
Wz,          pVP                  RV RV
 R24       VR,           Fõ  pVP                  pW…8w  dx   VP                  \         P                  VV VR7      4       V.pVe   VP                  R4       Ve5   W(,          p	V	P                  p
Wz,          pVP                  RV RV
 R24       TpVP                  4       V^ ,          P                  4       8X  d   VP                  V4       KË  VP                  \         P                  VV VR7      4       V.pK÷  	  VP                  \         P                  VV VR7      4       Ve   VP                  R4       \        V4      pV# )r   z&<span class="annotation" style="color:z" data-label="z">:é   NN)ra   ri   rˆ   )	rM   Ú%_EncodingVisualizer__make_char_statesr0   r~   r   rŠ   rš   rF   ÚHTMLBody)ra   ri   rb   Úchar_statesÚcurrent_consecutive_charsÚprev_anno_ixÚspansÚlabel_colors_dictÚcur_anno_ixÚannor   ÚcolorÚcsÚress   &&&           r   Ú__make_htmlÚEncodingVisualizer.__make_html  sì  € ä(×;Ñ;¸DÈKÓXˆØ%0°¥^Ð$4Ð!Ø" 1•~×-Ñ-ˆØˆÜ.×EÑEÀkÓRÐØ! !•n×,Ñ,ˆØÒ"àÕ+ˆDØ—J‘JˆEØ%Õ,ˆEØ�L‰LÐAÀ%ÀÈÐW\ÐV]Ð]_Ð`Ôaà˜b—/�/ˆBØŸ*™*ˆKØÔ*à—‘ä&×@Ñ@Ø1Ø!Ø!)ð Aó ôð .0¨DÐ)àÒ+à—L‘L Ô+ØÒ*à&Õ3�DØ ŸJ™J�EØ-Õ4�EØ—L‘LÐ#IÈ%ÈÐP^Ð_dÐ^eÐegÐ!hÔiØ&ˆLà×ÑÓ!Ð%>¸qÕ%A×%OÑ%OÓ%QÔQà)×0Ñ0°Ö4ð —‘Ü&×@Ñ@Ø1Ø!Ø!)ð Aó ôð .0¨DÒ)ñM "ðR 	�‰Ü×8Ñ8Ø)ØØ!ð 9ó ô	
ð Ò"Ø�L‰L˜Ô#ä�u‹oˆØˆ
r   c                ó,   <€ V ^8„  d   QhRS[ RS[RS[/# )r   ra   rb   rC   )r   rn   ÚPartialIntList)r   r   s   "€r   r   rT   N  s"   ø€ ÷ ñ ™cð ±ð Á>ñ r   c                óª   € R.\        V 4      ,          p\        V4       F0  w  r4\        VP                  VP                  4       F  pW2V&   K	  	  K2  	  V# )aƒ  
Args:
    text (:obj:`str`):
        The raw text we want to align to

    annotations (:obj:`AnnotationList`):
        A (possibly empty) list of annotations

Returns:
    A list of  length len(text) whose entry at index i is None if there is no annotation on
    character i or k, the index of the annotation that covers index i where k is with
    respect to the list of annotations
N)r<   Ú	enumerateÚranger   r   )ra   rb   Úannotation_mapr0   ÚaÚis   &&    r   Ú__make_anno_mapÚ"EncodingVisualizer.__make_anno_mapM  sN   € ð ˜¤# d£)Õ+ˆÜ# KÖ0‰JˆGÜ˜1Ÿ7™7 A§E¡EÖ*�Ø$+˜qÓ!ó +ñ 1ð Ðr   c          	      óB   <€ V ^8„  d   QhRS[ RS[RS[RS[S[,          /# r�   )r   r   rn   r   r5   )r   r   s   "€r   r   rT   c  s0   ø€ ÷ "ñ "¡ð "±ð "Á~ð "ÑZ^Ñ_hÕZiñ "r   c                ó¬  € \         P                  W4      p\        \        V 4      4       Uu. uF  p\	        V4      NK  	  pp\        VP                  4       FS  w  rgVP                  V4      pVf   K  Vw  rš\        Wš4       F$  pW[,          P                  P                  V4       K&  	  KU  	  \        V4       F  w  rLWÅV,          n	        K  	  V# u upi )aJ  
For each character in the original text, we emit a tuple representing it's "state":

    * which token_ix it corresponds to
    * which word_ix it corresponds to
    * which annotation_ix it corresponds to

Args:
    text (:obj:`str`):
        The raw text we want to align to

    annotations (:obj:`List[Annotation]`):
        A (possibly empty) list of annotations

    encoding: (:class:`~tokenizers.Encoding`):
        The encoding returned from the tokenizer

Returns:
    :obj:`List[CharState]`: A list of CharStates, indicating for each char in the text what
    it's state is
)
rM   Ú"_EncodingVisualizer__make_anno_mapr²   r<   r5   r±   r8   Útoken_to_charsrŠ   r0   )ra   ri   rb   r³   r7   r¢   r/   rƒ   Úoffsetsr   r   rµ   r0   s   &&&          r   Ú__make_char_statesÚ%EncodingVisualizer.__make_char_statesb  s¿   € ô. ,×;Ñ;¸DÓNˆäJOÔPSÐTXÓPYÔJZÓ'[ÑJZ¸w¬	°'Ö(:ÑJZˆÐ'[Ü(¨¯©Ö9‰OˆHØ×-Ñ-¨hÓ7ˆGØÔ"Ø$‘
�Ü˜uÖ*�AØ•N×)Ñ)×0Ñ0°Ö:ó +ñ	  :ô !*¨.Ö 9ÑˆGØ+2˜Õ Ö(ñ !:ð Ðùò (\s   ¬C)r]   rQ   rP   )TN)NN)r$   r%   r&   r'   Ú__doc__ÚreÚcompileÚ
IGNORECASEr‹   r!   rk   Ústaticmethodr~   rš   rg   rº   r    r)   r*   r+   s   @r   rM   rM   C   s    ø‡ € ñð  —j’jÐ!>ÀbÇmÁmÔT€O÷ò ÷02ò 2ðh ÷ó ðð8 ÷D9ó ðD9ðL ÷Dó ðDðL ÷ó ðð( ÷"ó ö"r   rM   c                óF   € V ^8„  d   QhR\         \        ,          R\        /# )r   ÚchildrenrC   )r   r   )r   s   "r   r   r   ˆ  s   € ÷ ñ ”tœC•yð ´Sñ r   c                ó6   € RP                  V 4      pRV RV R2# )a7  
Generates the full html with css from a list of html spans

Args:
    children (:obj:`List[str]`):
        A list of strings, assumed to be html elements

    css_styles (:obj:`str`, `optional`):
        Optional alternative implementation of the css

Returns:
    :obj:`str`: An HTML string with style markup
r‡   z?
    <html>
        <head>
            <style>
                zs
            </style>
        </head>
        <body>
            <div class="tokenized-text" dir=auto>
            z4
            </div>
        </body>
    </html>
    )r�   )rÅ   Ú
css_stylesÚchildren_texts   && r   r¡   r¡   ˆ  s9   € ð —G‘G˜HÓ%€Mðð �ð ð
 ˆOð ðð r   )#rj   Ú	itertoolsÚosrÀ   Ústringr   Útypingr   r   r   r   r   r	   r
   Ú
tokenizersr   r   ÚpathÚdirnameÚ__file__r�   Úcss_filenameÚopenÚfÚreadr–   r   rn   r   r¯   r-   r5   rK   rM   r¡   r3   r   r   Ú<module>rÕ      sÎ   ðÛ Û Û 	Û 	Ý ß I× IÑ Iç *à
�'‰'�/‰/˜(Ó
#€Ø�w‰w�|‰|˜GÐ%<Ó=€Ù	ˆ,×Ô˜1Ø
�&‰&‹(€C÷ ÷ñ ð �jÕ!€Ø�h˜s•mÕ$€ô�:ô ÷

ñ 
÷6	ñ 	÷Bñ BðJ
 .1÷ ñ ÷y ×ús   Á8C(Ã(C8	