Ë
    S^(h?K  ã                   ó¶   — d Z ddlZddlZddlZddlZddlmZmZmZm	Z	 ddl
mZ ddlmZ  ej                  e«      Zddd	d
œZd„ Zd„ Zd„ Z G d„ de«      ZdgZy)zTokenization classes for FSMT.é    N)ÚDictÚListÚOptionalÚTupleé   )ÚPreTrainedTokenizer)Úloggingzvocab-src.jsonzvocab-tgt.jsonz
merges.txt)Úsrc_vocab_fileÚtgt_vocab_fileÚmerges_filec                 ób   — t        «       }| d   }| dd D ]  }|j                  ||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       úh/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/fsmt/tokenization_fsmt.pyÚ	get_pairsr   $   sF   € ô
 ‹E€EØ�Q‘€IØ�Q�R�ò ˆØ�	‰	�9˜dÐ#Ô$Ø‰	ðð €Ló    c                 ó*  — | j                  dd«      } t        j                  dd| «      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  d	d
«      } | j                  dd
«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  dd«      } | j                  d d!«      } | j                  d"d#«      } | j                  d$d%«      } | j                  d&d'«      } | j                  d(d)«      } | j                  d*d+«      } | j                  d,d-«      } t        j                  d.d| «      } | j                  d/d0«      } | j                  d1d2«      } | j                  d3d4«      } | j                  d5d6«      } | j                  d7d8«      } | j                  d9d:«      } | j                  d;d<«      } | j                  d=d>«      } | j                  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   â€™ú'u   â€¦z...u   â”�ú-u   ã€ˆú<u   ã€‰ú>u   ã€�ú[u   ã€‘ú]u   ï¼…ú%)ÚreplaceÚreÚsub)Útexts    r   Úreplace_unicode_punctr7   1   sM  € ð �<‰<˜˜sÓ#€DÜ�6‰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‰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 ]:  }t        j                  |«      }|j                  d«      rŒ*|j                  |«       Œ< dj	                  |«      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)r6   Úoutputr   Úcats       r   Úremove_non_printing_charrB   \   sS   € ð €FØò ˆÜ×"Ñ" 4Ó(ˆØ�>‰>˜#ÔØØ�‰�dÕð	ð
 �7‰7�6‹?Ðr   c            
       ó˜  ‡ — e Zd ZdZeZddgZ	 	 	 	 	 	 	 	 	 d ˆ fd„	Zdee	e
f   fd„Zede
fd„«       Zd„ Zd	„ Zd
„ Zd„ Ze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e
      dee
   fd„Z	 d#dee
   deee
      dedee
   fˆ fd„Z	 d"dee
   deee
      dee
   fd„Z d"de	dee	   de!e	   fd„Z"d„ Z#d„ Z$ˆ xZ%S )$ÚFSMTTokenizera	  
    Construct an FAIRSEQ Transformer 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 `langs` defines a pair of languages.

    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:
        langs (`List[str]`, *optional*):
            A list of two languages to translate from and to, for instance `["en", "ru"]`.
        src_vocab_file (`str`, *optional*):
            File containing the vocabulary for the source language.
        tgt_vocab_file (`st`, *optional*):
            File containing the vocabulary for the target language.
        merges_file (`str`, *optional*):
            File containing the merges.
        do_lower_case (`bool`, *optional*, defaults to `False`):
            Whether or not to lowercase the input when tokenizing.
        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.

    Ú	input_idsÚattention_maskc
                 óÐ  •— 	 dd l }|| _        || _        || _        || _        || _        i | _        i | _        i | _	        |rt        |«      dk(  r|\  | _        | _        nt        d|› d�«      ‚t        |d¬«      5 }t        j                   |«      | _        d d d «       t        |d¬«      5 }t        j                   |«      }|j%                  «       D ��ci c]  \  }}||“Œ
 c}}| _        d d d «       t        |d¬«      5 }|j)                  «       j+                  d«      d d	 }d d d «       D �cg c]  }t-        |j+                  «       d d «      ‘Œ  }}t/        t1        |t3        t        |«      «      «      «      | _        i | _        t9        ‰| �t  d|||||||||	d
œ	|
¤Ž y # t        $ r t        d«      ‚w xY w# 1 sw Y   �Œ$xY wc c}}w # 1 sw Y   ŒâxY w# 1 sw Y   Œ¶xY wc c}w )Nr   únYou need to install sacremoses to use XLMTokenizer. See https://pypi.org/project/sacremoses/ for installation.é   zFarg `langs` needs to be a list of 2 langs, e.g. ['en', 'ru'], but got zw. Usually that means that tokenizer can't find a mapping for the given model path in  and other maps of this tokenizer.úutf-8©Úencodingú
éÿÿÿÿ)	Úlangsr
   r   r   Údo_lower_caseÚ	unk_tokenÚ	bos_tokenÚ	sep_tokenÚ	pad_token© )Ú
sacremosesÚImportErrorÚsmr
   r   r   rP   Úcache_moses_punct_normalizerÚcache_moses_tokenizerÚcache_moses_detokenizerÚlenÚsrc_langÚtgt_langÚ
ValueErrorÚopenÚjsonÚloadÚencoderÚitemsÚdecoderÚreadÚsplitÚtupleÚdictÚzipÚrangeÚ	bpe_ranksÚcacheÚsuperÚ__init__)ÚselfrO   r
   r   r   rP   rQ   rR   rS   rT   ÚkwargsrV   Úsrc_vocab_handleÚtgt_vocab_handleÚ	tgt_vocabÚkÚvÚmerges_handleÚmergesÚmergeÚ	__class__s                       €r   ro   zFSMTTokenizer.__init__£   s  ø€ ð	Ûð ˆŒà,ˆÔØ,ˆÔØ&ˆÔØ*ˆÔð -/ˆÔ)à%'ˆÔ"Ø')ˆÔ$á”S˜“Z 1’_Ø+0Ñ(ˆDŒM˜4�=äØXÐY^ÐX_ð `8ð 8óð ô �.¨7Ô3ð 	7Ð7GÜŸ9™9Ð%5Ó6ˆDŒL÷	7ä�.¨7Ô3ð 	@Ð7GÜŸ	™	Ð"2Ó3ˆIØ-6¯_©_Ó->×?¡T Q¨˜A˜q™DÓ?ˆDŒL÷	@ô �+¨Ô0ð 	;°MØ"×'Ñ'Ó)×/Ñ/°Ó5°c°rÐ:ˆF÷	;à8>Ö?¨u”%˜Ÿ™› b qÐ)Õ*Ð?ˆÐ?Üœc &¬%´°F³Ó*<Ó=Ó>ˆŒØˆŒ
Ü‰Ñð 	
ØØ)Ø)Ø#Ø'ØØØØñ	
ð ó	
øôM ò 	ÜðMóð ð	ú÷8	7ñ 	7üó @÷	@ð 	@ú÷	;ð 	;üâ?sG   ƒF  Á;F8Â+)GÃGÃ!	GÃ?#GÄ.#G#Æ F5Æ8GÇGÇGÇG Úreturnc                 ó"   — | j                  «       S ©N)Úget_src_vocab©rp   s    r   Ú	get_vocabzFSMTTokenizer.get_vocabæ   s   € Ø×!Ñ!Ó#Ð#r   c                 ó   — | j                   S r}   )Úsrc_vocab_sizer   s    r   Ú
vocab_sizezFSMTTokenizer.vocab_sizeê   s   € à×"Ñ"Ð"r   c                 ó°   — || j                   vr+| j                  j                  |¬«      }|| j                   |<   | j                   |   j                  |«      S ©N©Úlang)rY   rX   ÚMosesPunctNormalizerÚ	normalize)rp   r6   r‡   Úpunct_normalizers       r   Úmoses_punct_normzFSMTTokenizer.moses_punct_normî   sT   € Ø�t×8Ñ8Ñ8Ø#Ÿw™w×;Ñ;ÀÐ;ÓFÐØ6FˆD×-Ñ-¨dÑ3Ø×0Ñ0°Ñ6×@Ñ@ÀÓFÐFr   c                 ó¸   — || j                   vr+| j                  j                  |¬«      }|| j                   |<   | j                   |   j                  |ddd¬«      S )Nr†   TF)Úaggressive_dash_splitsÚ
return_strÚescape)rZ   rX   ÚMosesTokenizerÚtokenize)rp   r6   r‡   Úmoses_tokenizers       r   Úmoses_tokenizezFSMTTokenizer.moses_tokenizeô   sc   € Ø�t×1Ñ1Ñ1Ø"Ÿg™g×4Ñ4¸$Ð4Ó?ˆOØ/>ˆD×&Ñ& tÑ,Ø×)Ñ)¨$Ñ/×8Ñ8Ø¨¸%Èð 9ó 
ð 	
r   c                 ó°   — || j                   vr+| j                  j                  |¬«      }|| j                   |<   | j                   |   j                  |«      S r…   )r[   rX   ÚMosesDetokenizerÚ
detokenize)rp   Útokensr‡   Úmoses_detokenizers       r   Úmoses_detokenizezFSMTTokenizer.moses_detokenizeü   sT   € Ø�t×3Ñ3Ñ3Ø $§¡× 8Ñ 8¸dÐ 8Ó CÐØ1BˆD×(Ñ(¨Ñ.Ø×+Ñ+¨DÑ1×<Ñ<¸VÓDÐDr   c                 óV   — t        |«      }| j                  ||«      }t        |«      }|S r}   )r7   r‹   rB   )rp   r6   r‡   s      r   Úmoses_pipelinezFSMTTokenizer.moses_pipeline  s-   € Ü$ TÓ*ˆØ×$Ñ$ T¨4Ó0ˆÜ'¨Ó-ˆØˆr   c                 ó,   — t        | j                  «      S r}   )r\   rc   r   s    r   r‚   zFSMTTokenizer.src_vocab_size  ó   € ä�4—<‘<Ó Ð r   c                 ó,   — t        | j                  «      S r}   )r\   re   r   s    r   Útgt_vocab_sizezFSMTTokenizer.tgt_vocab_size  r�   r   c                 óB   — t        | j                  fi | j                  ¤ŽS r}   )ri   rc   Úadded_tokens_encoderr   s    r   r~   zFSMTTokenizer.get_src_vocab  ó   € Ü�D—L‘LÑ> D×$=Ñ$=Ñ>Ð>r   c                 óB   — t        | j                  fi | j                  ¤ŽS r}   )ri   re   Úadded_tokens_decoderr   s    r   Úget_tgt_vocabzFSMTTokenizer.get_tgt_vocab  r¢   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nÎ|\  }}g }d}|t        |«      k  r�	 |j                  ||«      }	|j                  |||	 «       |	}||   |k(  r6|t        |«      dz
  k  r%||dz      |k(  r|j                  ||z   «       |dz  }n|j                  ||   «       |dz  }|t        |«      k  rŒ�t        |«      }|}t        |«      dk(  rnt        |«      }Œídj                  |«      }|d	k(  rd
}|‰ j                  |<   |S # t        $ r |j                  ||d  «       Y Œpw xY w)NrN   ú</w>c                 óN   •— ‰j                   j                  | t        d«      «      S )NÚinf)rl   ÚgetÚfloat)Úpairrp   s    €r   ú<lambda>z#FSMTTokenizer.bpe.<locals>.<lambda>   s   ø€ °·±×1CÑ1CÀDÌ%ÐPUË,Ó1W€ r   ©Úkeyr   r   rI   ú z
  </w>z
</w>)rh   rm   r   Úminrl   r\   ÚindexÚextendr_   r>   r?   )
rp   Útokenr   r   ÚbigramÚfirstÚsecondÚnew_wordÚiÚjs
   `         r   ÚbpezFSMTTokenizer.bpe  sª  ø€ Ü�U˜3˜B�ZÓ  E¨"¡I°Ñ$6Ð#8Ñ8ˆØ�D—J‘JÑØ—:‘:˜eÑ$Ð$Ü˜$“ˆáØ˜6‘>Ð!àÜ˜Ó$WÔXˆFØ˜TŸ^™^Ñ+ØØ"‰MˆE�6ØˆHØˆAØ”c˜$“i’-ðØŸ
™
 5¨!Ó,�Að
 —O‘O D¨¨1 IÔ.Ø�Aà˜‘7˜eÒ#¨¬C°«I¸©MÒ(9¸dÀ1ÀqÁ5¹kÈVÒ>SØ—O‘O E¨F¡NÔ3Ø˜‘F‘Aà—O‘O D¨¡GÔ,Ø˜‘F�Að ”c˜$“i“-ô  ˜X“ˆHØˆDÜ�4‹y˜AŠ~Øä! $›�ð9 ð: �x‰x˜‹~ˆØ�:ÒØˆDØ ˆ�
‰
�5ÑØˆøô/ "ò Ø—O‘O D¨¨ HÔ-Ùðús   ÂE  Å F Å?F c                 óP  — | j                   }| j                  r|j                  «       }|r|j                  «       }n&| j	                  ||¬«      }| j                  ||¬«      }g }|D ]=  }|sŒ|j                  t        | j                  |«      j                  d«      «      «       Œ? |S )av  
        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:
            - lang: ISO language code (default = 'en') (string). Languages should belong of the model supported
              languages. However, we don't enforce it.
            - bypass_tokenizer: Allow users to preprocess and tokenize the sentences externally (default = False)
              (bool). If True, we only apply BPE.

        Returns:
            List of tokens.
        r†   r°   )	r]   rP   Úlowerrg   r›   r“   r³   Úlistr»   )rp   r6   r‡   Úbypass_tokenizerÚsplit_tokensr´   s         r   Ú	_tokenizezFSMTTokenizer._tokenizeB  s    € ð* �}‰}ˆà×ÒØ—:‘:“<ˆDáØ—:‘:“<‰Dà×&Ñ& t°$Ð&Ó7ˆDØ×&Ñ& t°$Ð&Ó7ˆDàˆØò 	FˆEÚØ×#Ñ#¤D¨¯©°%«×)>Ñ)>¸sÓ)CÓ$DÕEð	Fð Ðr   c                 ó€   — | j                   j                  || j                   j                  | j                  «      «      S )z0Converts a token (str) in an id using the vocab.)rc   rª   rQ   )rp   r´   s     r   Ú_convert_token_to_idz"FSMTTokenizer._convert_token_to_idi  s,   € à�|‰|×Ñ  t§|¡|×'7Ñ'7¸¿¹Ó'GÓHÐHr   c                 óN   — | j                   j                  || j                  «      S )z=Converts an index (integer) in a token (str) using the vocab.)re   rª   rQ   )rp   r²   s     r   Ú_convert_id_to_tokenz"FSMTTokenizer._convert_id_to_tokenm  s   € à�|‰|×Ñ  t§~¡~Ó6Ð6r   c                 óä   — |D �cg c]$  }|j                  dd«      j                  dd«      ‘Œ& }}dj                  |«      j                  «       }| j                  || j                  «      }|S c c}w )z:Converts a sequence of tokens (string) in a single string.r°   r:   r§   )r3   r?   rg   r™   r^   )rp   r—   Útr6   s       r   Úconvert_tokens_to_stringz&FSMTTokenizer.convert_tokens_to_stringq  sh   € ð DJÖJ¸a�!—)‘)˜C Ó$×,Ñ,¨V°SÕ9ÐJˆÐJØ—‘˜“×&Ñ&Ó(ˆà×$Ñ$ V¨T¯]©]Ó;ˆØˆùò	 Ks   …)A-Útoken_ids_0Útoken_ids_1c                 ó@   — | j                   g}|€||z   S ||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. A FAIRSEQ Transformer 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.
        )Úsep_token_id©rp   rÉ   rÊ   Úseps       r   Ú build_inputs_with_special_tokensz.FSMTTokenizer.build_inputs_with_special_tokens{  s:   € ð& × Ñ Ð!ˆð ÐØ Ñ$Ð$Ø˜SÑ  ;Ñ.°Ñ4Ð4r   Úalready_has_special_tokensc                 ó¤   •— |rt         ‰| �  ||d¬«      S |�'dgt        |«      z  dgz   dgt        |«      z  z   dgz   S dgt        |«      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Ð   r   r   )rn   Úget_special_tokens_maskr\   )rp   rÉ   rÊ   rÐ   rz   s       €r   rÒ   z%FSMTTokenizer.get_special_tokens_mask•  sz   ø€ ñ& &Ü‘7Ñ2Ø'°[Ð]að 3ó ð ð Ð"Ø�Cœ#˜kÓ*Ñ*¨q¨cÑ1°a°S¼3¸{Ó;KÑ5KÑLÐPQÈsÑRÐRØ�”c˜+Ó&Ñ&¨1¨#Ñ-Ð-r   c                 óŽ   — | j                   g}|€t        ||z   «      dgz  S t        ||z   «      dgz  t        ||z   «      dgz  z   S )a•  
        Create a mask from the two sequences passed to be used in a sequence-pair classification task. A FAIRSEQ
        Transformer sequence pair mask has the following format:

        ```
        0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
        | first sequence    | second sequence |
        ```

        If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).

        Args:
            token_ids_0 (`List[int]`):
                List of IDs.
            token_ids_1 (`List[int]`, *optional*):
                Optional second list of IDs for sequence pairs.

        Returns:
            `List[int]`: List of [token type IDs](../glossary#token-type-ids) according to the given sequence(s).

        Creates a mask from the two sequences passed to be used in a sequence-pair classification task. An
        FAIRSEQ_TRANSFORMER sequence pair mask has the following format:
        r   r   )rÌ   r\   rÍ   s       r   Ú$create_token_type_ids_from_sequencesz2FSMTTokenizer.create_token_type_ids_from_sequences±  s^   € ð4 × Ñ Ð!ˆð ÐÜ�{ SÑ(Ó)¨Q¨CÑ/Ð/Ü�; Ñ$Ó%¨¨Ñ+¬c°+ÀÑ2CÓ.DÈÀsÑ.JÑJÐJr   Úsave_directoryÚfilename_prefixc           	      ó�  — t         j                  j                  |«      st        j	                  d|› d�«       y t         j                  j                  ||r|dz   ndt        d   z   «      }t         j                  j                  ||r|dz   ndt        d   z   «      }t         j                  j                  ||r|dz   ndt        d   z   «      }t        |dd	¬
«      5 }|j                  t        j                  | j                  ddd¬«      dz   «       d d d «       t        |dd	¬
«      5 }| j                  j                  «       D ��ci c]  \  }}||“Œ
 }	}}|j                  t        j                  |	ddd¬«      dz   «       d d d «       d}
t        |dd	¬
«      5 }t        | j                  j                  «       d„ ¬«      D ]M  \  }}|
|k7  rt        j!                  d|› d�«       |}
|j                  dj                  |«      dz   «       |
dz  }
ŒO 	 d d d «       |||fS # 1 sw Y   �ŒxY wc c}}w # 1 sw Y   Œ±xY w# 1 sw Y   Œ-xY w)NzVocabulary path (z) should be a directoryr-   r:   r
   r   r   ÚwrJ   rK   rI   TF)ÚindentÚ	sort_keysÚensure_asciirM   r   c                 ó   — | d   S )Nr   rU   )Úkvs    r   r­   z/FSMTTokenizer.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   )ÚosÚpathÚisdirÚloggerÚerrorr?   ÚVOCAB_FILES_NAMESr`   Úwritera   Údumpsrc   re   rd   Úsortedrl   Úwarning)rp   rÕ   rÖ   r
   r   r   Úfru   rv   rt   r²   ÚwriterÚ
bpe_tokensÚtoken_indexs                 r   Úsave_vocabularyzFSMTTokenizer.save_vocabularyÒ  s/  € Ü�w‰w�}‰}˜^Ô,Ü�L‰LÐ,¨^Ð,<Ð<SÐTÔUØäŸ™Ÿ™Ø±o˜_¨sÒ2È2ÔQbÐcsÑQtÑtó
ˆô Ÿ™Ÿ™Ø±o˜_¨sÒ2È2ÔQbÐcsÑQtÑtó
ˆô —g‘g—l‘lØ±o˜_¨sÒ2È2ÔQbÐcpÑQqÑqó
ˆô �. #°Ô8ð 	c¸AØ�G‰G”D—J‘J˜tŸ|™|°AÀÐTYÔZÐ]aÑaÔb÷	cô �. #°Ô8ð 	`¸AØ*.¯,©,×*<Ñ*<Ó*>×?¡$ ! Q˜˜A™Ð?ˆIÑ?Ø�G‰G”D—J‘J˜y°¸dÐQVÔWÐZ^Ñ^Ô_÷	`ð ˆÜ�+˜s¨WÔ5ð 		¸Ü+1°$·.±.×2FÑ2FÓ2HÑN^Ô+_ò Ñ'�
˜KØ˜KÒ'Ü—N‘NØ/°¨}ð =Mð Môð (�EØ—‘˜SŸX™X jÓ1°DÑ8Ô9Ø˜‘
‘ñ÷		ð ˜~¨{Ð:Ð:÷'	cñ 	cüó @÷	`ð 	`ú÷
		ð 		ús7   Ã6HÄ'H0ÅH*Å.H0ÆA7H<ÈH'È*H0È0H9È<Ic                 óD   — | j                   j                  «       }d |d<   |S )NrX   )Ú__dict__Úcopy)rp   Ústates     r   Ú__getstate__zFSMTTokenizer.__getstate__ö  s"   € Ø—‘×"Ñ"Ó$ˆØˆˆd‰Øˆr   c                 óZ   — || _         	 dd l}|| _        y # t        $ r t        d«      ‚w xY w)Nr   rH   )rî   rV   rW   rX   )rp   ÚdrV   s      r   Ú__setstate__zFSMTTokenizer.__setstate__û  s>   € ØˆŒð	Ûð ˆ�øô ò 	ÜðMóð ð	ús   ‰ •*)	NNNNFz<unk>z<s>z</s>z<pad>)ÚenFr}   )NF)&Ú__name__Ú
__module__Ú__qualname__Ú__doc__rã   Úvocab_files_namesÚmodel_input_namesro   r   ÚstrÚintr€   Úpropertyrƒ   r‹   r“   r™   r›   r‚   rŸ   r~   r¥   r»   rÁ   rÃ   rÅ   rÈ   r   r   rÏ   ÚboolrÒ   rÔ   r   rì   rñ   rô   Ú__classcell__)rz   s   @r   rD   rD   r   s°  ø„ ñ+ðZ *ÐØ$Ð&6Ð7Ðð ØØØØØØØØõ@
ðF$˜4  S ™>ó $ð ð#˜Cò #ó ð#òGò
òEòð ñ!ó ð!ð ñ!ó ð!ò?ò?ò*óX%òNIò7òð JNñ5Ø ™9ð5Ø3;¸DÀ¹IÑ3Fð5à	ˆc‰ó5ð6 sxñ.Ø ™9ð.Ø3;¸DÀ¹IÑ3Fð.Økoð.à	ˆc‰õ.ð: JNñKØ ™9ðKØ3;¸DÀ¹IÑ3FðKà	ˆc‰óKñB";¨cð ";ÀHÈSÁMð ";Ð]bÐcfÑ]gó ";òHö
r   rD   )rù   ra   rÞ   r4   r;   Útypingr   r   r   r   Útokenization_utilsr   Úutilsr	   Ú
get_loggerrö   rá   rã   r   r7   rB   rD   Ú__all__rU   r   r   ú<module>r     ss   ðñ %ã Û 	Û 	Û ß .Ó .å 5Ý ð 
ˆ×	Ñ	˜HÓ	%€ð 'Ø&ØñÐ ò
ò(òV
ô,TÐ'ô Tðn Ð
�r   