Ë
    ›¾jQ  ã                   ó    — d dl mZmZ d dlmZmZ d dlmZmZ d dl	m	Z	  G d„ de
«      Z e«       j                  Zd„ Zd„ Zd	„ Zd
„ Zdd„Zdd„Zy)é    )ÚteeÚzip_longest)ÚescapeÚunescape)ÚParallelÚdelayed)Útqdmc                   óZ   — e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZeeeeee	e
eeeegZy)ÚCJKCharsz©
    An object that enumerates the code points of the CJK characters as listed on
    http://en.wikipedia.org/wiki/Basic_Multilingual_Plane#Basic_Multilingual_Plane
    )i   iÿ  )i€.  iÏ¤  )i@¨  i¨  )i ¬  i¯×  )i ù  iÿú  )i0þ  iOþ  )ieÿ  iÜÿ  )iào iÿo )i p iÿŠ )i ° i/± )ip± iÿ² )i   iÿÿ N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚHangul_JamoÚCJK_RadicalsÚPhags_PaÚHangul_SyllablesÚCJK_Compatibility_IdeographsÚCJK_Compatibility_FormsÚKatakana_Hangul_HalfwidthÚ#Ideographic_Symbols_And_PunctuationÚTangutÚKana_SupplementÚNushuÚSupplementary_Ideographic_PlaneÚranges© ó    úY/home/spazio/kingdom_calls/work5/transenv/lib/python3.12/site-packages/sacremoses/util.pyr   r      s‹   „ ñð €Kð* "€Lð €Hð &Ðð $2Ð ð -Ðð !/Ðð+Ð'ð €Fð '€Oð €Eð'Ð#ð 	ØØØØ$ØØ!ØØØØ'ð�Fr   r   c                 óN   — t        | «      }t        D ]  \  }}||k  sŒ||kD  c S  y)u¿  
    This checks for CJK character.

        >>> CJKChars().ranges
        [(4352, 4607), (11904, 42191), (43072, 43135), (44032, 55215), (63744, 64255), (65072, 65103), (65381, 65500), (94208, 101119), (110592, 110895), (110960, 111359), (131072, 196607)]
        >>> is_cjk('ã�¾')
        True
        >>> is_cjk('ï¹Ÿ')
        False

    :param character: The character that needs to be checked.
    :type character: char
    :return: bool
    F)ÚordÚ_CJKChars_ranges)Ú	characterÚcharÚstartÚends       r   Úis_cjkr'   a   s6   € ô ˆy‹>€DÜ&ò  ‰
ˆˆsØ�#‹:Ø˜%‘<Òð ð r   c           	      ó(   — t        | ddddddœ¬«      S )a‹  
    This function transforms the input text into an "escaped" version suitable
    for well-formed XML formatting.
    Note that the default xml.sax.saxutils.escape() function don't escape
    some characters that Moses does so we have to manually add them to the
    entities dictionary.

        >>> input_str = ''')| & < > ' " ] ['''
        >>> expected_output =  ''')| &amp; &lt; &gt; ' " ] ['''
        >>> escape(input_str) == expected_output
        True
        >>> xml_escape(input_str)
        ')&#124; &amp; &lt; &gt; &apos; &quot; &#93; &#91;'

    :param text: The text that needs to be escaped.
    :type text: str
    :rtype: str
    ú&apos;ú&quot;ú&#124;ú&#91;ú&#93;)ú'ú"ú|ú[ú]©Úentities)r   ©Útexts    r   Ú
xml_escaper7   w   s(   € ô& ØàØØØØñ
ô	ð 	r   c           	      ó(   — t        | ddddddœ¬«      S )ai  
    This function transforms the "escaped" version suitable
    for well-formed XML formatting into humanly-readable string.
    Note that the default xml.sax.saxutils.unescape() function don't unescape
    some characters that Moses does so we have to manually add them to the
    entities dictionary.

        >>> from xml.sax.saxutils import unescape
        >>> s = ')&#124; &amp; &lt; &gt; &apos; &quot; &#93; &#91;'
        >>> expected = ''')| & < > ' " ] ['''
        >>> xml_unescape(s) == expected
        True

    :param text: The text that needs to be unescaped.
    :type text: str
    :rtype: str
    r.   r/   r0   r1   r2   )r)   r*   r+   r,   r-   r3   )r   r5   s    r   Úxml_unescaper9   –   s(   € ô$ ØàØØØØñ
ô	ð 	r   c                 óN   — t        | «      \  }}t        |d«       t        ||«      S )zp
    From https://docs.python.org/3/library/itertools.html#recipes
    s -> (s0,s1), (s1,s2), (s2, s3), ...
    N)r   ÚnextÚzip)ÚiterableÚaÚbs      r   Úpairwiser@   ´   s&   € ô
 ˆx‹=�D€A€qÜˆˆD„MÜˆq�!‹9Ðr   Nc                 ó6   — t        | «      g|z  }t        |d|iŽS )ziCollect data into fixed-length chunks or blocks
    from https://stackoverflow.com/a/16789869/610569
    Ú	fillvalue)Úiterr   )r=   ÚnrB   Úargss       r   ÚgrouperrF   ¾   s%   € ô
 �‹NÐ˜aÑ€DÜ˜Ð2¨	Ñ2Ð2r   c                 óz   ‡ — |rt        |«      n|}|dk  rt        ‰ |«      S  t        |¬«      ˆ fd„|D «       «      S )Né   )Ún_jobsc              3   ó@   •K  — | ]  } t        ‰«      |«      –— Œ y ­w©N)r   )Ú.0ÚlineÚfuncs     €r   ú	<genexpr>z)parallelize_preprocess.<locals>.<genexpr>Ë   s   øè ø€ Ò%O¸d m¤g¨d£m°D×&9Ñ%Oùs   ƒ)r	   Úmapr   )rN   ÚiteratorÚ	processesÚprogress_bars   `   r   Úparallelize_preprocessrT   Ç   s<   ø€ Ù!-Œt�HŒ~°8€HØ�A‚~Ü�4˜Ó"Ð"Ø%Œ8˜9Ô%Ó%OÀhÔ%OÓOÐOr   rK   )F)Ú	itertoolsr   r   Úxml.sax.saxutilsr   r   Újoblibr   r   r	   Úobjectr   r   r"   r'   r7   r9   r@   rF   rT   r   r   r   ú<module>rY      sQ   ð÷ 'ß -ç $Ý ôPˆvô Pñf “:×$Ñ$Ð òò,ò>ò<ó3ôPr   