§
    ‚Štj·Q  ã                   ó¦   — d Z ddlZddlZddlZddlZddlmZ ddlmZ  ej	        e
¦  «        ZdddœZd	„ Zd
„ Zd„ Zd„ Z G d„ de¦  «        ZdgZdS )z"Tokenization classes for Flaubert.é    Né   )ÚPreTrainedTokenizer)Úloggingz
vocab.jsonz
merges.txt)Ú
vocab_fileÚmerges_filec                 ó&   — dd„} || dd¬¦  «        S )zQ
    Converts `text` to Unicode (if it's not already), assuming UTF-8 input.
    úutf-8Ústrictc                 óÆ   — t          | t          ¦  «        r|                      ||¦  «        S t          | t          ¦  «        r| S t	          dt          | ¦  «        › d�¦  «        ‚)Nznot expecting type 'ú')Ú
isinstanceÚbytesÚdecodeÚstrÚ	TypeErrorÚtype)ÚsÚencodingÚerrorss      úp/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/flaubert/tokenization_flaubert.pyÚensure_textz'convert_to_unicode.<locals>.ensure_text&   s_   € Ý�a�ÑÔð 	?Ø—8’8˜H fÑ-Ô-Ð-Ý˜�3ÑÔð 	?ØˆHåÐ=µ4¸±7´7Ð=Ð=Ð=Ñ>Ô>Ð>ó    Úignore)r   r   )r	   r
   © )Útextr   s     r   Úconvert_to_unicoder   !   s/   € ð
?ð ?ð ?ð ?ð ˆ;�t g°hÐ?Ñ?Ô?Ð?r   c                 ó~   — t          ¦   «         }| d         }| dd…         D ]}|                     ||f¦  «         |}Œ|S )zƒ
    Return set of symbol pairs in a word. word is represented as tuple of symbols (symbols being variable-length
    strings)
    r   é   N)ÚsetÚadd)ÚwordÚpairsÚ	prev_charÚchars       r   Ú	get_pairsr%   2   sP   € õ
 ‰EŒE€EØ�Q”€IØ�Q�R�R”ð ð ˆØ�	Š	�9˜dÐ#Ñ$Ô$Ð$Øˆ	ˆ	Ø€Lr   c                 ó6  — |                       dd¦  «        } t          j        dd| ¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       d	d
¦  «        } |                       dd
¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       dd¦  «        } |                       d d!¦  «        } |                       d"d#¦  «        } |                       d$d%¦  «        } |                       d&d'¦  «        } |                       d(d)¦  «        } |                       d*d+¦  «        } |                       d,d-¦  «        } t          j        d.d| ¦  «        } |                       d/d0¦  «        } |                       d1d2¦  «        } |                       d3d4¦  «        } |                       d5d6¦  «        } |                       d7d8¦  «        } |                       d9d:¦  «        } |                       d;d<¦  «        } |                       d=d>¦  «        } |                       d?d@¦  «        } | S )Azz
    Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/replace-unicode-punctuation.perl
    u   ï¼Œú,u   ã€‚\s*z. u   ã€�u   â€�ú"u   â€œu   âˆ¶ú:u   ï¼šu   ï¼Ÿú?u   ã€Šu   ã€‹u   ï¼‰ú)u   ï¼�ú!u   ï¼ˆú(u   ï¼›ú;u   ï¼‘Ú1u   ã€�u   ã€Œu   ï¼�Ú0u   ï¼“Ú3u   ï¼’Ú2u   ï¼•Ú5u   ï¼–Ú6u   ï¼™Ú9u   ï¼—Ú7u   ï¼˜Ú8u   ï¼”Ú4u   ï¼Ž\s*u   ï½žú~u   â€™r   u   â€¦z...u   â”�ú-u   ã€ˆú<u   ã€‰ú>u   ã€�ú[u   ã€‘ú]u   ï¼…ú%)ÚreplaceÚreÚsub)r   s    r   Úreplace_unicode_punctrC   @   sµ  € ð �<Š<˜˜sÑ#Ô#€DÝŒ6�)˜T 4Ñ(Ô(€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DÝŒ6�)˜T 4Ñ(Ô(€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜uÑ%Ô%€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ�<Š<˜˜sÑ#Ô#€DØ€Kr   c                 ó¸   — g }| D ]A}t          j        |¦  «        }|                     d¦  «        rŒ,|                     |¦  «         ŒBd                     |¦  «        S )zw
    Port of https://github.com/moses-smt/mosesdecoder/blob/master/scripts/tokenizer/remove-non-printing-char.perl
    ÚCÚ )ÚunicodedataÚcategoryÚ
startswithÚappendÚjoin)r   Úoutputr$   Úcats       r   Úremove_non_printing_charrN   l   sd   € ð €FØð ð ˆÝÔ" 4Ñ(Ô(ˆØ�>Š>˜#ÑÔð 	ØØ�Š�dÑÔÐÐØ�7Š7�6‰?Œ?Ðr   c            
       óp  ‡ — e Zd ZdZeZdddddddg d¢d	d	f
ˆ fd
„	Zed„ ¦   «         Zd„ Z	d„ Z
d„ Zd„ Zed„ ¦   «         Zd„ Zd„ Zd„ Zd#d„Zd„ Zd„ Zd„ Z	 d$dee         dee         d	z  dee         fd„Z	 d%dee         dee         d	z  dedee         fˆ fd„Zd$deded	z  dee         fd „Zd!„ Zd"„ Zˆ xZS )&ÚFlaubertTokenizeraì  
    Construct a Flaubert tokenizer. Based on Byte-Pair Encoding. The tokenization process is the following:

    - Moses preprocessing and tokenization.
    - Normalizing all inputs text.
    - The arguments `special_tokens` and the function `set_special_tokens`, can be used to add additional symbols (like
      "__classify__") to a vocabulary.
    - The argument `do_lowercase` controls lower casing (automatically set for pretrained vocabularies).

    This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
    this superclass for more information regarding those methods.

    Args:
        vocab_file (`str`):
            Vocabulary file.
        merges_file (`str`):
            Merges file.
        do_lowercase (`bool`, *optional*, defaults to `False`):
            Controls lower casing.
        unk_token (`str`, *optional*, defaults to `"<unk>"`):
            The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
            token instead.
        bos_token (`str`, *optional*, defaults to `"<s>"`):
            The beginning of sequence token that was used during pretraining. Can be used a sequence classifier token.

            <Tip>

            When building a sequence using special tokens, this is not the token that is used for the beginning of
            sequence. The token used is the `cls_token`.

            </Tip>

        sep_token (`str`, *optional*, defaults to `"</s>"`):
            The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
            sequence classification or for a text and a question for question answering. It is also used as the last
            token of a sequence built with special tokens.
        pad_token (`str`, *optional*, defaults to `"<pad>"`):
            The token used for padding, for example when batching sequences of different lengths.
        cls_token (`str`, *optional*, defaults to `"</s>"`):
            The classifier token which is used when doing sequence classification (classification of the whole sequence
            instead of per-token classification). It is the first token of the sequence when built with special tokens.
        mask_token (`str`, *optional*, defaults to `"<special1>"`):
            The token used for masking values. This is the token used when training this model with masked language
            modeling. This is the token which the model will try to predict.
        additional_special_tokens (`List[str]`, *optional*, defaults to `['<special0>', '<special1>', '<special2>', '<special3>', '<special4>', '<special5>', '<special6>', '<special7>', '<special8>', '<special9>']`):
            List of additional special tokens.
        lang2id (`Dict[str, int]`, *optional*):
            Dictionary mapping languages string identifiers to their IDs.
        id2lang (`Dict[int, str]`, *optional*):
            Dictionary mapping language IDs to their string identifiers.
    Fz<unk>z<s>z</s>z<pad>ú
<special1>)
z
<special0>rQ   z
<special2>z
<special3>z
<special4>z
<special5>z
<special6>z
<special7>z
<special8>z
<special9>Nc                 óø  •— |                      dd ¦  «        }|�t                               d¦  «         d| _        || _        	 dd l}n# t          $ r t          d¦  «        ‚w xY w|| _        i | _        i | _	        h d£| _
        || _        || _        |�$|�"t          |¦  «        t          |¦  «        k    sJ ‚d | _        d | _        t!          |d¬¦  «        5 }t#          j        |¦  «        | _        d d d ¦  «         n# 1 swxY w Y   d	„ | j                             ¦   «         D ¦   «         | _        t!          |d¬¦  «        5 }|                     ¦   «                              d
¦  «        d d…         }d d d ¦  «         n# 1 swxY w Y   d„ |D ¦   «         }t1          t3          |t5          t          |¦  «        ¦  «        ¦  «        ¦  «        | _        i | _         t;          ¦   «         j        d|||||||	|
||dœ
|¤Ž d S )NÚdo_lowercase_and_remove_accentz�`do_lowercase_and_remove_accent` is passed as a keyword argument, but this won't do anything. `FlaubertTokenizer` will always set it to `False`.Fr   zsYou need to install sacremoses to use FlaubertTokenizer. See https://pypi.org/project/sacremoses/ for installation.>   ÚjaÚthÚzhr	   ©r   c                 ó   — i | ]\  }}||“Œ	S r   r   )Ú.0ÚkÚvs      r   ú
<dictcomp>z.FlaubertTokenizer.__init__.<locals>.<dictcomp>ï   s   € Ð>Ð>Ð>¡  A˜˜1Ð>Ð>Ð>r   ú
éÿÿÿÿc                 ó`   — g | ]+}t          |                     ¦   «         d d…         ¦  «        ‘Œ,S )Né   )ÚtupleÚsplit)rY   Úmerges     r   ú
<listcomp>z.FlaubertTokenizer.__init__.<locals>.<listcomp>ò   s1   € Ð?Ð?Ð?¨u•%˜Ÿš™œ b q bÔ)Ñ*Ô*Ð?Ð?Ð?r   )
Údo_lowercaseÚ	unk_tokenÚ	bos_tokenÚ	sep_tokenÚ	pad_tokenÚ	cls_tokenÚ
mask_tokenÚadditional_special_tokensÚlang2idÚid2langr   )ÚpopÚloggerÚwarningrS   re   Ú
sacremosesÚImportErrorÚsmÚcache_moses_punct_normalizerÚcache_moses_tokenizerÚlang_with_custom_tokenizerrm   rn   ÚlenÚja_word_tokenizerÚzh_word_tokenizerÚopenÚjsonÚloadÚencoderÚitemsÚdecoderÚreadrb   ÚdictÚzipÚrangeÚ	bpe_ranksÚcacheÚsuperÚ__init__)Úselfr   r   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ÚkwargsrS   rr   Úvocab_handleÚmerges_handleÚmergesÚ	__class__s                      €r   rˆ   zFlaubertTokenizer.__init__°   sÃ  ø€ ð6 *0¯ªÐ4TÐVZÑ)[Ô)[Ð&Ø)Ð5Ý�NŠNðFñô ð ð
 /4ˆÔ+à(ˆÔð	ØÐÐÐÐøÝð 	ð 	ð 	ÝðMñô ð ð	øøøð ˆŒð -/ˆÔ)à%'ˆÔ"Ø*<Ð*<Ð*<ˆÔ'ØˆŒØˆŒØÐ 7Ð#6Ý�w‘<”<¥3 w¡<¤<Ò/Ð/Ð/Ð/à!%ˆÔØ!%ˆÔå�* wÐ/Ñ/Ô/ð 	3°<Ýœ9 \Ñ2Ô2ˆDŒLð	3ð 	3ð 	3ñ 	3ô 	3ð 	3ð 	3ð 	3ð 	3ð 	3ð 	3øøøð 	3ð 	3ð 	3ð 	3à>Ð>¨¬×);Ò);Ñ)=Ô)=Ð>Ñ>Ô>ˆŒÝ�+¨Ð0Ñ0Ô0ð 	;°MØ"×'Ò'Ñ)Ô)×/Ò/°Ñ5Ô5°c°r°cÔ:ˆFð	;ð 	;ð 	;ñ 	;ô 	;ð 	;ð 	;ð 	;ð 	;ð 	;ð 	;øøøð 	;ð 	;ð 	;ð 	;à?Ð?¸Ð?Ñ?Ô?ˆÝ�c &­%µ°F±´Ñ*<Ô*<Ñ=Ô=Ñ>Ô>ˆŒØˆŒ
à�‰ŒÔð 	
Ø%ØØØØØØ!Ø&?ØØð	
ð 	
ð ð	
ð 	
ð 	
ð 	
ð 	
s0   ÁA ÁA"ÃC<Ã<D ÄD Å 0E<Å<F ÆF c                 ó   — | j         S ©N)rS   ©r‰   s    r   Údo_lower_casezFlaubertTokenizer.do_lower_case  s   € ð Ô2Ð2r   c                 ó¤   — || j         vr&| j                             |¬¦  «        }|| j         |<   n| j         |         }|                     |¦  «        S )N©Úlang)ru   rt   ÚMosesPunctNormalizerÚ	normalize)r‰   r   r•   Úpunct_normalizers       r   Úmoses_punct_normz"FlaubertTokenizer.moses_punct_norm
  s[   € Ø�tÔ8Ð8Ð8Ø#œw×;Ò;ÀÐ;ÑFÔFÐØ6FˆDÔ-¨dÑ3Ð3à#Ô@ÀÔFÐØ×)Ò)¨$Ñ/Ô/Ð/r   c                 óª   — || j         vr&| j                             |¬¦  «        }|| j         |<   n| j         |         }|                     |dd¬¦  «        S )Nr”   F)Ú
return_strÚescape)rv   rt   ÚMosesTokenizerÚtokenize)r‰   r   r•   Úmoses_tokenizers       r   Úmoses_tokenizez FlaubertTokenizer.moses_tokenize  s`   € Ø�tÔ1Ð1Ð1Ø"œg×4Ò4¸$Ð4Ñ?Ô?ˆOØ/>ˆDÔ& tÑ,Ð,à"Ô8¸Ô>ˆOØ×'Ò'¨¸ÀuÐ'ÑMÔMÐMr   c                 ón   — t          |¦  «        }|                      ||¦  «        }t          |¦  «        }|S r�   )rC   r™   rN   )r‰   r   r•   s      r   Úmoses_pipelinez FlaubertTokenizer.moses_pipeline  s6   € Ý$ TÑ*Ô*ˆØ×$Ò$ T¨4Ñ0Ô0ˆÝ'¨Ñ-Ô-ˆØˆr   c                 óD  — | j         €ó	 dd l}|                     dt          j                             d¦  «        › d�¦  «        | _         n²# t
          t          f$ rž t                               d¦  «         t                               d¦  «         t                               d¦  «         t                               d¦  «         t                               d	¦  «         t                               d
¦  «         ‚ w xY wt          | j          
                    |¦  «        ¦  «        S )Nr   z-model r9   z/local/share/kytea/model.binz™Make sure you install KyTea (https://github.com/neubig/kytea) and it's python wrapper (https://github.com/chezou/Mykytea-python) with the following stepsz81. git clone git@github.com:neubig/kytea.git && cd kyteaz2. autoreconf -iz#3. ./configure --prefix=$HOME/localz4. make && make installz5. pip install kytea)ry   ÚMykyteaÚosÚpathÚ
expanduserÚAttributeErrorrs   rp   ÚerrorÚlistÚgetWS)r‰   r   r¤   s      r   Úja_tokenizezFlaubertTokenizer.ja_tokenize#  s  € ØÔ!Ð)ðØ���à)0¯ªØS�bœg×0Ò0°Ñ5Ô5ÐSÐSÐSñ*ô *�Ô&Ð&øõ #¥KÐ0ð 
ð 
ð 
Ý—’ð[ñô ð õ —’ÐWÑXÔXÐXÝ—’Ð/Ñ0Ô0Ð0Ý—’ÐBÑCÔCÐCÝ—’Ð6Ñ7Ô7Ð7Ý—’Ð3Ñ4Ô4Ð4Øð
øøøõ �DÔ*×0Ò0°Ñ6Ô6Ñ7Ô7Ð7s   ‰?A	 Á	B/C8c                 ó*   — t          | j        ¦  «        S r�   )rx   r~   r‘   s    r   Ú
vocab_sizezFlaubertTokenizer.vocab_size8  s   € õ �4”<Ñ Ô Ð r   c                 ó0   — t          | j        fi | j        ¤ŽS r�   )r‚   r~   Úadded_tokens_encoderr‘   s    r   Ú	get_vocabzFlaubertTokenizer.get_vocab>  s   € Ý�D”LÐ>Ð> DÔ$=Ð>Ð>Ð>r   c                 ó¦  ‡ — t          |d d…         ¦  «        |d         dz   fz   }|‰ j        v r‰ j        |         S t          |¦  «        }|s|dz   S 	 t          |ˆ fd„¬¦  «        }|‰ j        vr�n8|\  }}g }d}|t          |¦  «        k     ræ	 |                     ||¦  «        }	|                     |||	…         ¦  «         |	}n-# t          $ r  |                     ||d …         ¦  «         Y n†w xY w||         |k    rC|t          |¦  «        dz
  k     r-||dz            |k    r| 	                    ||z   ¦  «         |dz  }n | 	                    ||         ¦  «         |dz  }|t          |¦  «        k     °æt          |¦  «        }|}t          |¦  «        dk    rnt          |¦  «        }�ŒWd	 
                    |¦  «        }|d
k    rd}|‰ j        |<   |S )Nr^   ú</w>Tc                 óT   •— ‰j                              | t          d¦  «        ¦  «        S )NÚinf)r…   ÚgetÚfloat)Úpairr‰   s    €r   ú<lambda>z'FlaubertTokenizer.bpe.<locals>.<lambda>L  s    ø€ °´×1CÒ1CÀDÍ%ÐPUÉ,Ì,Ñ1WÔ1W€ r   ©Úkeyr   r   r`   ú z
  </w>z
</w>)ra   r†   r%   Úminr…   rx   ÚindexÚextendÚ
ValueErrorrJ   rK   )
r‰   Útokenr!   r"   ÚbigramÚfirstÚsecondÚnew_wordÚiÚjs
   `         r   ÚbpezFlaubertTokenizer.bpeB  s  ø€ Ý�U˜3˜B˜3”ZÑ Ô  E¨"¤I°Ñ$6Ð#8Ñ8ˆØ�D”JÐÐØ”:˜eÔ$Ð$Ý˜$‘”ˆàð 	"Ø˜6‘>Ð!ð	(Ý˜Ð$WÐ$WÐ$WÐ$WÐXÑXÔXˆFØ˜Tœ^Ð+Ð+ÙØ"‰MˆE�6ØˆHØˆAØ•c˜$‘i”i’-�-ðØŸ
š
 5¨!Ñ,Ô,�Að
 —O’O D¨¨1¨¤IÑ.Ô.Ð.Ø�A�Aøõ "ð ð ð Ø—O’O D¨¨¨¤HÑ-Ô-Ð-Ø�Eðøøøð ˜”7˜eÒ#Ð#¨­C°©I¬I¸©MÒ(9Ð(9¸dÀ1ÀqÁ5¼kÈVÒ>SÐ>SØ—O’O E¨F¡NÑ3Ô3Ð3Ø˜‘F�A�Aà—O’O D¨¤GÑ,Ô,Ð,Ø˜‘F�Að •c˜$‘i”i’-�-õ  ˜X‘”ˆHØˆDÝ�4‰yŒy˜AŠ~ˆ~Øå! $™œ�ñ9	(ð: �xŠx˜‰~Œ~ˆØ�:ÒÐØˆDØ ˆŒ
�5ÑØˆs   ÂC Ã'C/Ã.C/c                 óØ   — |                      dd¦  «                              dd¦  «        }t          |¦  «        }t          j        d|¦  «        }| j        r|                     ¦   «         }|S )Nz``r(   z''ÚNFC)r@   r   rG   r—   re   Úlower)r‰   r   s     r   Úpreprocess_textz!FlaubertTokenizer.preprocess_textn  sa   € Ø�|Š|˜D #Ñ&Ô&×.Ò.¨t°SÑ9Ô9ˆÝ! $Ñ'Ô'ˆÝÔ$ U¨DÑ1Ô1ˆàÔð 	 Ø—:’:‘<”<ˆDàˆr   c                 ó¸  — d}|r*| j         r#|| j         vrt                               d¦  «         |r|                     ¦   «         }nC|                      |¦  «        }|                      ||¬¦  «        }|                      ||¬¦  «        }g }|D ]L}|rH|                     t          |  	                    |¦  «                             d¦  «        ¦  «        ¦  «         ŒM|S )aÏ  
        Tokenize a string given language code using Moses.

        Details of tokenization:

            - [sacremoses](https://github.com/alvations/sacremoses): port of Moses
            - Install with `pip install sacremoses`

        Args:
            - bypass_tokenizer: Allow users to preprocess and tokenize the sentences externally (default = False)
              (bool). If True, we only apply BPE.

        Returns:
            List of tokens.
        Úfrz�Supplied language code not found in lang2id mapping. Please check that your language is supported by the loaded pretrained model.r”   r¼   )
rm   rp   r©   rb   rÌ   r¢   r    r¿   rª   rÈ   )r‰   r   Úbypass_tokenizerr•   Úsplit_tokensrÁ   s         r   Ú	_tokenizezFlaubertTokenizer._tokenizex  s÷   € ð  ˆØð 	�D”Lð 	 T°´Ð%=Ð%=Ý�LŠLð0ñô ð ð
 ð 	8Ø—:’:‘<”<ˆDˆDà×'Ò'¨Ñ-Ô-ˆDØ×&Ò& t°$Ð&Ñ7Ô7ˆDØ×&Ò& t°$Ð&Ñ7Ô7ˆDàˆØð 	Fð 	FˆEØð FØ×#Ò#¥D¨¯ª°%©¬×)>Ò)>¸sÑ)CÔ)CÑ$DÔ$DÑEÔEÐEøàÐr   c                 ór   — | j                              || j                              | j        ¦  «        ¦  «        S )z0Converts a token (str) in an id using the vocab.)r~   r¶   rf   )r‰   rÁ   s     r   Ú_convert_token_to_idz&FlaubertTokenizer._convert_token_to_idž  s,   € àŒ|×Ò  t¤|×'7Ò'7¸¼Ñ'GÔ'GÑHÔHÐHr   c                 óB   — | j                              || j        ¦  «        S )z=Converts an index (integer) in a token (str) using the vocab.)r€   r¶   rf   )r‰   r¾   s     r   Ú_convert_id_to_tokenz&FlaubertTokenizer._convert_id_to_token£  s   € àŒ|×Ò  t¤~Ñ6Ô6Ð6r   c                 ó|   — d                      |¦  «                             dd¦  «                             ¦   «         }|S )z:Converts a sequence of tokens (string) in a single string.rF   r³   r¼   )rK   r@   Ústrip)r‰   ÚtokensÚ
out_strings      r   Úconvert_tokens_to_stringz*FlaubertTokenizer.convert_tokens_to_string¨  s3   € à—W’W˜V‘_”_×,Ò,¨V°SÑ9Ô9×?Ò?ÑAÔAˆ
ØÐr   Útoken_ids_0Útoken_ids_1Úreturnc                 óR   — | j         g}| j        g}|€||z   |z   S ||z   |z   |z   |z   S )a�  
        Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
        adding special tokens. An XLM sequence has the following format:

        - single sequence: `<s> X </s>`
        - pair of sequences: `<s> A </s> B </s>`

        Args:
            token_ids_0 (`List[int]`):
                List of IDs to which the special tokens will be added.
            token_ids_1 (`List[int]`, *optional*):
                Optional second list of IDs for sequence pairs.

        Returns:
            `List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.

        )Úbos_token_idÚsep_token_id)r‰   rÛ   rÜ   ÚbosÚseps        r   Ú build_inputs_with_special_tokensz2FlaubertTokenizer.build_inputs_with_special_tokens®  sJ   € ð( Ô Ð!ˆØÔ Ð!ˆàÐØ˜Ñ$ sÑ*Ð*Ø�[Ñ  3Ñ&¨Ñ4°sÑ:Ð:r   Úalready_has_special_tokensc                 óð   •— |r$t          ¦   «                              ||d¬¦  «        S |�3dgdgt          |¦  «        z  z   dgz   dgt          |¦  «        z  z   dgz   S dgdgt          |¦  «        z  z   dgz   S )aÄ  
        Retrieve sequence ids from a token list that has no special tokens added. This method is called when adding
        special tokens using the tokenizer `prepare_for_model` method.

        Args:
            token_ids_0 (`List[int]`):
                List of IDs.
            token_ids_1 (`List[int]`, *optional*):
                Optional second list of IDs for sequence pairs.
            already_has_special_tokens (`bool`, *optional*, defaults to `False`):
                Whether or not the token list is already formatted with special tokens for the model.

        Returns:
            `List[int]`: A list of integers in the range [0, 1]: 1 for a special token, 0 for a sequence token.
        T)rÛ   rÜ   rä   Nr   r   )r‡   Úget_special_tokens_maskrx   )r‰   rÛ   rÜ   rä   rŽ   s       €r   ræ   z)FlaubertTokenizer.get_special_tokens_maskÊ  s¡   ø€ ð& &ð 	Ý‘7”7×2Ò2Ø'°[Ð]að 3ñ ô ð ð Ð"Ø�3˜1˜#¥ KÑ 0Ô 0Ñ0Ñ1°Q°CÑ7¸A¸3ÅÀ[ÑAQÔAQÑ;QÑRÐVWÐUXÑXÐXØˆs�q�c�C Ñ,Ô,Ñ,Ñ-°°Ñ3Ð3r   Úsave_directoryÚfilename_prefixc           	      óz  — t           j                             |¦  «        s t                               d|› d�¦  «         d S t           j                             ||r|dz   ndt          d         z   ¦  «        }t           j                             ||r|dz   ndt          d         z   ¦  «        }t          |dd¬	¦  «        5 }|                     t          j
        | j        d
dd¬¦  «        dz   ¦  «         d d d ¦  «         n# 1 swxY w Y   d}t          |dd¬	¦  «        5 }t          | j                             ¦   «         d„ ¬¦  «        D ][\  }}	||	k    r t                               d|› d�¦  «         |	}|                     d                     |¦  «        dz   ¦  «         |dz  }Œ\	 d d d ¦  «         n# 1 swxY w Y   ||fS )NzVocabulary path (z) should be a directoryr:   rF   r   r   Úwr	   rW   r`   TF)ÚindentÚ	sort_keysÚensure_asciir]   r   c                 ó   — | d         S )Nr   r   )Úkvs    r   r¹   z3FlaubertTokenizer.save_vocabulary.<locals>.<lambda>÷  s   € ÐY[Ð\]ÔY^€ r   rº   zSaving vocabulary to zZ: BPE merge indices are not consecutive. Please check that the tokenizer is not corrupted!r¼   r   )r¥   r¦   Úisdirrp   r©   rK   ÚVOCAB_FILES_NAMESr{   Úwriter|   Údumpsr~   Úsortedr…   r   rq   )
r‰   rç   rè   r   Ú
merge_fileÚfr¾   ÚwriterÚ
bpe_tokensÚtoken_indexs
             r   Úsave_vocabularyz!FlaubertTokenizer.save_vocabularyç  sq  € ÝŒw�}Š}˜^Ñ,Ô,ð 	Ý�LŠLÐT¨^ÐTÐTÐTÑUÔUÐUØˆFÝ”W—\’\Ø°oÐM˜_¨sÑ2Ð2È2ÕQbÐcoÔQpÑpñ
ô 
ˆ
õ ”W—\’\Ø°oÐM˜_¨sÑ2Ð2È2ÕQbÐcpÔQqÑqñ
ô 
ˆ
õ �*˜c¨GÐ4Ñ4Ô4ð 	c¸Ø�GŠG•D”J˜tœ|°AÀÐTYÐZÑZÔZÐ]aÑaÑbÔbÐbð	cð 	cð 	cñ 	cô 	cð 	cð 	cð 	cð 	cð 	cð 	cøøøð 	cð 	cð 	cð 	cð ˆÝ�*˜c¨GÐ4Ñ4Ô4ð 		¸Ý+1°$´.×2FÒ2FÑ2HÔ2HÐN^ÐN^Ð+_Ñ+_Ô+_ð ð Ñ'�
˜KØ˜KÒ'Ð'Ý—N’NðM°
ð Mð Mð Mñô ð ð (�EØ—’˜SŸXšX jÑ1Ô1°DÑ8Ñ9Ô9Ð9Ø˜‘
��ðð		ð 		ð 		ñ 		ô 		ð 		ð 		ð 		ð 		ð 		ð 		øøøð 		ð 		ð 		ð 		ð ˜:Ð%Ð%s%   Â<4C<Ã<D ÄD ÄBF.Æ.F2Æ5F2c                 óB   — | j                              ¦   «         }d |d<   |S )Nrt   )Ú__dict__Úcopy)r‰   Ústates     r   Ú__getstate__zFlaubertTokenizer.__getstate__  s#   € Ø”×"Ò"Ñ$Ô$ˆØˆˆd‰Øˆr   c                 óh   — || _         	 dd l}n# t          $ r t          d¦  «        ‚w xY w|| _        d S )Nr   znYou need to install sacremoses to use XLMTokenizer. See https://pypi.org/project/sacremoses/ for installation.)rü   rr   rs   rt   )r‰   Údrr   s      r   Ú__setstate__zFlaubertTokenizer.__setstate__
  s]   € ØˆŒð	ØÐÐÐÐøÝð 	ð 	ð 	ÝðMñô ð ð	øøøð ˆŒˆˆs   ‰ Ž()Fr�   )NF) Ú__name__Ú
__module__Ú__qualname__Ú__doc__rñ   Úvocab_files_namesrˆ   Úpropertyr’   r™   r    r¢   r¬   r®   r±   rÈ   rÌ   rÑ   rÓ   rÕ   rÚ   rª   Úintrã   Úboolræ   r   ra   rú   rÿ   r  Ú__classcell__)rŽ   s   @r   rP   rP   y   sh  ø€ € € € € ð2ð 2ðh *Ðð ØØØØØØð#
ð #
ð #
ð Øð1R
ð R
ð R
ð R
ð R
ð R
ðh ð3ð 3ñ „Xð3ð0ð 0ð 0ðNð Nð Nðð ð ð8ð 8ð 8ð* ð!ð !ñ „Xð!ð?ð ?ð ?ð*ð *ð *ðXð ð ð#ð #ð #ð #ðLIð Ið Ið
7ð 7ð 7ð
ð ð ð GKð;ð ;Ø œ9ð;Ø37¸´9¸tÑ3Cð;à	ˆcŒð;ð ;ð ;ð ;ð: puð4ð 4Ø œ9ð4Ø37¸´9¸tÑ3Cð4Øhlð4à	ˆcŒð4ð 4ð 4ð 4ð 4ð 4ð:&ð &¨cð &ÀCÈ$ÁJð &ÐZ_Ð`cÔZdð &ð &ð &ð &ð:ð ð ðð ð ð ð ð ð r   rP   )r  r|   r¥   rA   rG   Útokenization_pythonr   Úutilsr   Ú
get_loggerr  rp   rñ   r   r%   rC   rN   rP   Ú__all__r   r   r   ú<module>r     s  ðð )Ð (à €€€Ø 	€	€	€	Ø 	€	€	€	Ø Ð Ð Ð à 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø Ð Ð Ð Ð Ð ð 
ˆÔ	˜HÑ	%Ô	%€ð Øðð Ð ð@ð @ð @ð"
ð 
ð 
ð(ð (ð (ðX
ð 
ð 
ð\ð \ð \ð \ð \Ð+ñ \ô \ð \ð~ Ð
€€€r   