§
    'ê[fc(  ã                   óf   — d dl mZ d dlmZmZ d„ Zd„ Zd„ Z G d„ d¦  «        Zd„ Z	d	„ Z
d
„ Zd„ ZdS )é    )Úfinditer)ÚescapeÚunescapec              #   ó,  K  — t          |¦  «        dk    rt          d¦  «        ‚d}	 	 |                      ||¦  «        }|dk    r||fV — n7# t          $ r* |t          | ¦  «        k    r|t          | ¦  «        fV — Y dS w xY w|t          |¦  «        z   }Œn)a¯  
    Return the offsets of the tokens in *s*, as a sequence of ``(start, end)``
    tuples, by splitting the string at each occurrence of *sep*.

        >>> from nltk.tokenize.util import string_span_tokenize
        >>> s = '''Good muffins cost $3.88\nin New York.  Please buy me
        ... two of them.\n\nThanks.'''
        >>> list(string_span_tokenize(s, " ")) # doctest: +NORMALIZE_WHITESPACE
        [(0, 4), (5, 12), (13, 17), (18, 26), (27, 30), (31, 36), (37, 37),
        (38, 44), (45, 48), (49, 55), (56, 58), (59, 73)]

    :param s: the string to be tokenized
    :type s: str
    :param sep: the token separator
    :type sep: str
    :rtype: iter(tuple(int, int))
    r   z!Token delimiter must not be emptyTN)ÚlenÚ
ValueErrorÚindex)ÚsÚsepÚleftÚrights       úF/var/www/piapp/venv/lib/python3.11/site-packages/nltk/tokenize/util.pyÚstring_span_tokenizer      sÀ   è è € õ$ ˆ3�x„x�1‚}€}ÝÐ<Ñ=Ô=Ð=Ø€Dð
 ð	Ø—G’G˜C Ñ&Ô&ˆEØ˜ŠzˆzØ˜E�kÐ!Ð!Ð!øøÝð 	ð 	ð 	Ø•s˜1‘v”vŠ~ˆ~Ø�C ™FœF�lÐ"Ð"Ð"ØˆEˆEð	øøøð
 •s˜3‘x”xÑˆð
 s   ©"A Á0B Á?B c              #   ó¤   K  — d}t          || ¦  «        D ]'}|                     ¦   «         \  }}||k    r||fV — |}Œ(|t          | ¦  «        fV — dS )a  
    Return the offsets of the tokens in *s*, as a sequence of ``(start, end)``
    tuples, by splitting the string at each successive match of *regexp*.

        >>> from nltk.tokenize.util import regexp_span_tokenize
        >>> s = '''Good muffins cost $3.88\nin New York.  Please buy me
        ... two of them.\n\nThanks.'''
        >>> list(regexp_span_tokenize(s, r'\s')) # doctest: +NORMALIZE_WHITESPACE
        [(0, 4), (5, 12), (13, 17), (18, 23), (24, 26), (27, 30), (31, 36),
        (38, 44), (45, 48), (49, 51), (52, 55), (56, 58), (59, 64), (66, 73)]

    :param s: the string to be tokenized
    :type s: str
    :param regexp: regular expression that matches token separators (must not be empty)
    :type regexp: str
    :rtype: iter(tuple(int, int))
    r   N)r   Úspanr   )r
   Úregexpr   Úmr   Únexts         r   Úregexp_span_tokenizer   .   ss   è è € ð$ €DÝ�f˜aÑ Ô ð ð ˆØ—f’f‘h”h‰ˆˆtØ�DŠ=ˆ=Ø˜�+ÐÐÐØˆˆØ
•�A‘”ˆ,ÐÐÐÐÐó    c              #   ó:   K  — d}| D ]\  }}||z
  ||z
  fV — |}ŒdS )a«  
    Return a sequence of relative spans, given a sequence of spans.

        >>> from nltk.tokenize import WhitespaceTokenizer
        >>> from nltk.tokenize.util import spans_to_relative
        >>> s = '''Good muffins cost $3.88\nin New York.  Please buy me
        ... two of them.\n\nThanks.'''
        >>> list(spans_to_relative(WhitespaceTokenizer().span_tokenize(s))) # doctest: +NORMALIZE_WHITESPACE
        [(0, 4), (1, 7), (1, 4), (1, 5), (1, 2), (1, 3), (1, 5), (2, 6),
        (1, 3), (1, 2), (1, 3), (1, 2), (1, 5), (2, 7)]

    :param spans: a sequence of (start, end) offsets of the tokens
    :type spans: iter(tuple(int, int))
    :rtype: iter(tuple(int, int))
    r   N© )ÚspansÚprevr   r   s       r   Úspans_to_relativer   I   sJ   è è € ð  €DØð ð ‰ˆˆeØ�T‰k˜5 4™<Ð'Ð'Ð'Ð'Øˆˆðð r   c                   óF   — e 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gZd
S )ÚCJKCharsa^  
    An object that enumerates the code points of the CJK characters as listed on
    https://en.wikipedia.org/wiki/Basic_Multilingual_Plane#Basic_Multilingual_Plane

    This is a Python port of the CJK code point enumerations of Moses tokenizer:
    https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/detokenizer.perl#L309
    ©i   iÿ  ©i€.  iÏ¤  ©i@¨  i¨  ©i ¬  i¯×  ©i ù  iÿú  ©i0þ  iOþ  ©ieÿ  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ÚSupplementary_Ideographic_PlaneÚrangesr   r   r   r   r   _   sv   € € € € € ðð ð €Kð* "€Lð €Hð &Ðð $2Ð ð -Ðð !/Ðð'Ð#ð 	ØØØØ$ØØ!Ø'ð	€F€F€Fr   r   c                 ó:   ‡ — t          ˆ fd„dD ¦   «         ¦  «        S )uŒ  
    Python port of Moses' code to check for CJK character.

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

    :param character: The character that needs to be checked.
    :type character: char
    :return: bool
    c                 óP   •— g | ]"\  }}|t          ‰¦  «        cxk    o|k    nc ‘Œ#S r   )Úord)Ú.0ÚstartÚendÚ	characters      €r   ú
<listcomp>zis_cjk.<locals>.<listcomp>±   sO   ø€ ð 	
ð 	
ð 	
á��sð •S˜‘^”^Ð*Ð*Ò*Ð* sÒ*Ð*Ð*Ð*ð	
ð 	
ð 	
r   )r   r   r    r!   r"   r#   r$   r%   )Úany)r9   s   `r   Úis_cjkr<   ¡   s?   ø€ õ ð	
ð 	
ð 	
ð 	
ð	ð	
ñ 	
ô 	
ñô ð r   c           	      ó0   — 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_escaperL   Á   s7   € õ( ØàØØØØð
ð 
ð	ñ 	ô 	ð 	r   c           	      ó0   — t          | ddddddœ¬¦  «        S )aj  
    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
    rC   rD   rE   rF   rG   )r>   r?   r@   rA   rB   rH   )r   rJ   s    r   Úxml_unescaperN   á   s7   € õ& ØàØØØØð
ð 
ð	ñ 	ô 	ð 	r   c           	      óì   — d}g }| D ]l}	 |                      ||¦  «        }n)# t          $ r}t          d|› d|› d�¦  «        |‚d}~ww xY w|t          |¦  «        z   }|                     ||f¦  «         Œm|S )aÅ  
    This module attempt to find the offsets of the tokens in *s*, as a sequence
    of ``(start, end)`` tuples, given the tokens and also the source string.

        >>> from nltk.tokenize import TreebankWordTokenizer
        >>> from nltk.tokenize.util import align_tokens
        >>> s = str("The plane, bound for St Petersburg, crashed in Egypt's "
        ... "Sinai desert just 23 minutes after take-off from Sharm el-Sheikh "
        ... "on Saturday.")
        >>> tokens = TreebankWordTokenizer().tokenize(s)
        >>> expected = [(0, 3), (4, 9), (9, 10), (11, 16), (17, 20), (21, 23),
        ... (24, 34), (34, 35), (36, 43), (44, 46), (47, 52), (52, 54),
        ... (55, 60), (61, 67), (68, 72), (73, 75), (76, 83), (84, 89),
        ... (90, 98), (99, 103), (104, 109), (110, 119), (120, 122),
        ... (123, 131), (131, 132)]
        >>> output = list(align_tokens(tokens, s))
        >>> len(tokens) == len(expected) == len(output)  # Check that length of tokens and tuples are the same.
        True
        >>> expected == list(align_tokens(tokens, s))  # Check that the output is as expected.
        True
        >>> tokens == [s[start:end] for start, end in output]  # Check that the slices of the string corresponds to the tokens.
        True

    :param tokens: The list of strings that are the result of tokenization
    :type tokens: list(str)
    :param sentence: The original string
    :type sentence: str
    :rtype: list(tuple(int,int))
    r   zsubstring "z" not found in "rD   N)r	   r   r   Úappend)ÚtokensÚsentenceÚpointÚoffsetsÚtokenr7   Úes          r   Úalign_tokensrW      s®   € ð< €EØ€GØð 'ð 'ˆð	VØ—N’N 5¨%Ñ0Ô0ˆEˆEøÝð 	Vð 	Vð 	VÝÐM¨5ÐMÐMÀ(ÐMÐMÐMÑNÔNÐTUÐUøøøøð	Vøøøà�˜E™
œ
Ñ"ˆØ�Š˜˜u�~Ñ&Ô&Ð&Ð&Ø€Ns   Š!¡
A«AÁAN)Úrer   Úxml.sax.saxutilsr   r   r   r   r   r   r<   rL   rN   rW   r   r   r   ú<module>rZ      sÐ   ðð Ð Ð Ð Ð Ð Ø -Ð -Ð -Ð -Ð -Ð -Ð -Ð -ð ð  ð  ðDð ð ð6ð ð ð,?ð ?ð ?ð ?ð ?ñ ?ô ?ð ?ðDð ð ð@ð ð ð@ð ð ð>'ð 'ð 'ð 'ð 'r   