Ë
    T^(hËW  ã                   óØ   — d Z ddlZddlZddlZddlmZmZmZ ddlm	Z	m
Z
mZmZmZ ddlmZ  ej                   e«      ZddiZd	„ Zd
„ Z G d„ de
«      Z G d„ d«      Z G d„ d«      ZdgZy)zTokenization classes for MPNet.é    N)ÚListÚOptionalÚTupleé   )Ú
AddedTokenÚPreTrainedTokenizerÚ_is_controlÚ_is_punctuationÚ_is_whitespace)ÚloggingÚ
vocab_filez	vocab.txtc                 óæ   — t        j                  «       }t        | dd¬«      5 }|j                  «       }ddd«       t	        «      D ]  \  }}|j                  d«      }|||<   Œ |S # 1 sw Y   Œ4xY w)z*Loads a vocabulary file into a dictionary.Úrúutf-8©ÚencodingNú
)ÚcollectionsÚOrderedDictÚopenÚ	readlinesÚ	enumerateÚrstrip)r   ÚvocabÚreaderÚtokensÚindexÚtokens         új/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/mpnet/tokenization_mpnet.pyÚ
load_vocabr        sw   € ä×#Ñ#Ó%€EÜ	ˆj˜#¨Ô	0ð $°FØ×!Ñ!Ó#ˆ÷$ä! &Ó)ò ‰ˆˆuØ—‘˜TÓ"ˆØˆˆeŠðð €L÷$ð $ús   £A'Á'A0c                 óN   — | j                  «       } | sg S | j                  «       }|S )z@Runs basic whitespace cleaning and splitting on a piece of text.)ÚstripÚsplit)Útextr   s     r   Úwhitespace_tokenizer%   +   s%   € à�:‰:‹<€DÙØˆ	Ø�Z‰Z‹\€FØ€Mó    c            
       óB  ‡ — e Zd ZdZeZddgZ	 	 	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Zed„ «       Z	ed„ «       Z
d„ Z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ˆ xZS )ÚMPNetTokenizeraV  

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

    Args:
        vocab_file (`str`):
            Path to the vocabulary file.
        do_lower_case (`bool`, *optional*, defaults to `True`):
            Whether or not to lowercase the input when tokenizing.
        do_basic_tokenize (`bool`, *optional*, defaults to `True`):
            Whether or not to do basic tokenization before WordPiece.
        never_split (`Iterable`, *optional*):
            Collection of tokens which will never be split during tokenization. Only has an effect when
            `do_basic_tokenize=True`
        bos_token (`str`, *optional*, defaults to `"<s>"`):
            The beginning of sequence token that was used during pre-training. 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>

        eos_token (`str`, *optional*, defaults to `"</s>"`):
            The end of sequence token.

            <Tip>

            When building a sequence using special tokens, this is not the token that is used for the end of sequence.
            The token used is the `sep_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.
        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.
        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.
        pad_token (`str`, *optional*, defaults to `"<pad>"`):
            The token used for padding, for example when batching sequences of different lengths.
        mask_token (`str`, *optional*, defaults to `"<mask>"`):
            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.
        tokenize_chinese_chars (`bool`, *optional*, defaults to `True`):
            Whether or not to tokenize Chinese characters.

            This should likely be deactivated for Japanese (see this
            [issue](https://github.com/huggingface/transformers/issues/328)).
        strip_accents (`bool`, *optional*):
            Whether or not to strip all accents. If this option is not specified, then it will be determined by the
            value for `lowercase` (as in the original BERT).
        clean_up_tokenization_spaces (`bool`, *optional*, defaults to `True`):
            Whether or not to cleanup spaces after decoding, cleanup consists in removing potential artifacts like
            extra spaces.
    Ú	input_idsÚattention_maskc                 óŽ  •— t        |t        «      rt        |d¬«      n|}t        |t        «      rt        |d¬«      n|}t        |t        «      rt        |d¬«      n|}t        |t        «      rt        |d¬«      n|}t        |	t        «      rt        |	d¬«      n|	}	t        |
t        «      rt        |
d¬«      n|
}
t        |t        «      rt        |dd¬«      n|}t        j                  j                  |«      st        d|› d�«      ‚t        |«      | _        t        j                  | j                  j                  «       D ��cg c]	  \  }}||f‘Œ c}}«      | _        || _        |rt        ||||¬«      | _        t!        | j                  t        |	«      ¬«      | _        t%        ‰| �L  d	||||||	|||
||||dœ|¤Ž y c c}}w )
NT)Úspecial)Úlstripr,   z&Can't find a vocabulary file at path 'z'. To load the vocabulary from a Google pretrained model use `tokenizer = AutoTokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`)Údo_lower_caseÚnever_splitÚtokenize_chinese_charsÚstrip_accents)r   Ú	unk_token)r.   Údo_basic_tokenizer/   Ú	bos_tokenÚ	eos_tokenr2   Ú	sep_tokenÚ	cls_tokenÚ	pad_tokenÚ
mask_tokenr0   r1   Úclean_up_tokenization_spaces© )Ú
isinstanceÚstrr   ÚosÚpathÚisfileÚ
ValueErrorr    r   r   r   ÚitemsÚids_to_tokensr3   ÚBasicTokenizerÚbasic_tokenizerÚWordpieceTokenizerÚwordpiece_tokenizerÚsuperÚ__init__)Úselfr   r.   r3   r/   r4   r5   r6   r7   r2   r8   r9   r0   r1   r:   ÚkwargsÚtokÚidsÚ	__class__s                     €r   rI   zMPNetTokenizer.__init__w   sº  ø€ ô$ <FÀiÔQTÔ;U”J˜y°$Õ7Ð[dˆ	Ü;EÀiÔQTÔ;U”J˜y°$Õ7Ð[dˆ	Ü;EÀiÔQTÔ;U”J˜y°$Õ7Ð[dˆ	Ü;EÀiÔQTÔ;U”J˜y°$Õ7Ð[dˆ	Ü;EÀiÔQTÔ;U”J˜y°$Õ7Ð[dˆ	Ü;EÀiÔQTÔ;U”J˜y°$Õ7Ð[dˆ	ô KUÐU_ÔadÔJe”Z 
°4ÀÕFÐkuˆ
ä�w‰w�~‰~˜jÔ)ÜØ8¸¸ð E`ð `óð ô   
Ó+ˆŒ
Ü(×4Ñ4ÐQU×Q[ÑQ[×QaÑQaÓQc×5dÁXÀSÈ#°s¸C²jÓ5dÓeˆÔØ!2ˆÔÙÜ#1Ø+Ø'Ø'=Ø+ô	$ˆDÔ ô $6¸D¿J¹JÔRUÐV_ÓR`Ô#aˆÔ ä‰Ñð 	
Ø'Ø/Ø#ØØØØØØØ!Ø#9Ø'Ø)Eñ	
ð ó	
ùó 6es   ÅG
c                 ó.   — | j                   j                  S ©N)rE   r.   ©rJ   s    r   r.   zMPNetTokenizer.do_lower_caseµ   s   € à×#Ñ#×1Ñ1Ð1r&   c                 ó,   — t        | j                  «      S rP   )Úlenr   rQ   s    r   Ú
vocab_sizezMPNetTokenizer.vocab_size¹   s   € ä�4—:‘:‹Ðr&   c                 óp   — | j                   j                  «       }|j                  | j                  «       |S rP   )Úadded_tokens_encoderÚcopyÚupdater   )rJ   r   s     r   Ú	get_vocabzMPNetTokenizer.get_vocab½   s+   € à×)Ñ)×.Ñ.Ó0ˆØ�‰�T—Z‘ZÔ Øˆr&   c                 óD  — g }| j                   rv| j                  j                  || j                  ¬«      D ]J  }|| j                  j                  v r|j                  |«       Œ-|| j                  j                  |«      z  }ŒL |S | j                  j                  |«      }|S )N)r/   )r3   rE   ÚtokenizeÚall_special_tokensr/   ÚappendrG   )rJ   r$   Úsplit_tokensr   s       r   Ú	_tokenizezMPNetTokenizer._tokenizeÃ   s    € ØˆØ×!Ò!Ø×-Ñ-×6Ñ6°tÈ×I`ÑI`Ð6Óaò M�à˜D×0Ñ0×<Ñ<Ñ<Ø ×'Ñ'¨Õ.à  D×$<Ñ$<×$EÑ$EÀeÓ$LÑL‘LðMð Ðð  ×3Ñ3×<Ñ<¸TÓBˆLØÐr&   c                 ó€   — | j                   j                  || j                   j                  | j                  «      «      S )z0Converts a token (str) in an id using the vocab.)r   Úgetr2   )rJ   r   s     r   Ú_convert_token_to_idz#MPNetTokenizer._convert_token_to_idÐ   s(   € à�z‰z�~‰~˜e T§Z¡Z§^¡^°D·N±NÓ%CÓDÐDr&   c                 óN   — | j                   j                  || j                  «      S )z=Converts an index (integer) in a token (str) using the vocab.)rC   ra   r2   )rJ   r   s     r   Ú_convert_id_to_tokenz#MPNetTokenizer._convert_id_to_tokenÔ   s   € à×!Ñ!×%Ñ% e¨T¯^©^Ó<Ð<r&   c                 ód   — dj                  |«      j                  dd«      j                  «       }|S )z:Converts a sequence of tokens (string) in a single string.ú z ##Ú )ÚjoinÚreplacer"   )rJ   r   Ú
out_strings      r   Úconvert_tokens_to_stringz'MPNetTokenizer.convert_tokens_to_stringØ   s,   € à—X‘X˜fÓ%×-Ñ-¨e°RÓ8×>Ñ>Ó@ˆ
ØÐr&   Útoken_ids_0Útoken_ids_1Úreturnc                 ó˜   — |€| j                   g|z   | j                  gz   S | j                   g}| j                  g}||z   |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. A MPNet sequence has the following format:

        - single sequence: `<s> X </s>`
        - pair of sequences: `<s> A </s></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.
        )Úcls_token_idÚsep_token_id)rJ   rl   rm   ÚclsÚseps        r   Ú build_inputs_with_special_tokensz/MPNetTokenizer.build_inputs_with_special_tokensÝ   sg   € ð& ÐØ×%Ñ%Ð&¨Ñ4¸×8IÑ8IÐ7JÑJÐJØ× Ñ Ð!ˆØ× Ñ Ð!ˆØ�[Ñ  3Ñ&¨Ñ,¨{Ñ:¸SÑ@Ð@r&   Úalready_has_special_tokensc                 ó¶   •— |rt         ‰| �  ||d¬«      S |€dgdgt        |«      z  z   dgz   S dgdgt        |«      z  z   ddgz   dgt        |«      z  z   dgz   S )aÅ  
        Retrieves 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` methods.

        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`):
                Set to True if 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)rl   rm   ru   é   r   )rH   Úget_special_tokens_maskrS   )rJ   rl   rm   ru   rN   s       €r   rx   z&MPNetTokenizer.get_special_tokens_maskö   s‹   ø€ ñ$ &Ü‘7Ñ2Ø'°[Ð]að 3ó ð ð ÐØ�3˜1˜#¤ KÓ 0Ñ0Ñ1°Q°CÑ7Ð7Øˆs�q�cœC Ó,Ñ,Ñ-°°A°Ñ6¸1¸#ÄÀKÓ@PÑ:PÑQÐUVÐTWÑWÐWr&   c                 ó    — | j                   g}| j                  g}|€t        ||z   |z   «      dgz  S t        ||z   |z   |z   |z   |z   «      dgz  S )aË  
        Creates a mask from the two sequences passed to be used in a sequence-pair classification task. MPNet does not
        make use of token type ids, therefore a list of zeros is returned.

        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 zeros.
        r   )rq   rp   rS   )rJ   rl   rm   rs   rr   s        r   Ú$create_token_type_ids_from_sequencesz3MPNetTokenizer.create_token_type_ids_from_sequences  sm   € ð  × Ñ Ð!ˆØ× Ñ Ð!ˆàÐÜ�s˜[Ñ(¨3Ñ.Ó/°1°#Ñ5Ð5Ü�3˜Ñ$ sÑ*¨SÑ0°;Ñ>ÀÑDÓEÈÈÑKÐKr&   Úsave_directoryÚfilename_prefixc                 óà  — d}t         j                  j                  |«      r2t         j                  j                  ||r|dz   ndt        d   z   «      }n|r|dz   nd|z   }t        |dd¬«      5 }t        | j                  j                  «       d„ ¬	«      D ]>  \  }}||k7  rt        j                  d
|› d�«       |}|j                  |dz   «       |dz  }Œ@ 	 d d d «       |fS # 1 sw Y   |fS xY w)Nr   ú-rg   r   Úwr   r   c                 ó   — | d   S )Nrw   r;   )Úkvs    r   ú<lambda>z0MPNetTokenizer.save_vocabulary.<locals>.<lambda>1  s   € ÐPRÐSTÑPU€ r&   )ÚkeyzSaving vocabulary to z\: vocabulary indices are not consecutive. Please check that the vocabulary is not corrupted!r   rw   )r>   r?   Úisdirrh   ÚVOCAB_FILES_NAMESr   Úsortedr   rB   ÚloggerÚwarningÚwrite)rJ   r{   r|   r   r   Úwriterr   Útoken_indexs           r   Úsave_vocabularyzMPNetTokenizer.save_vocabulary(  sû   € ØˆÜ�7‰7�=‰=˜Ô(ÜŸ™Ÿ™Ø¹/ °3Ò!6ÈrÔUfÐgsÑUtÑ tó‰Jñ 4C˜/¨CÒ/ÈÈnÑ\ˆJÜ�*˜c¨GÔ4ð 		¸Ü&,¨T¯Z©Z×-=Ñ-=Ó-?ÑEUÔ&Vò Ñ"��{Ø˜KÒ'Ü—N‘NØ/°
¨|ð <Nð Nôð (�EØ—‘˜U T™\Ô*Ø˜‘
‘ñ÷		ð ˆ}Ð÷		ð ˆ}Ðús   Á.A(C"Ã"C-)TTNú<s>ú</s>rŽ   r�   z[UNK]z<pad>z<mask>TNTrP   )NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r…   Úvocab_files_namesÚmodel_input_namesrI   Úpropertyr.   rT   rY   r_   rb   rd   rk   r   Úintr   rt   Úboolrx   rz   r=   r   rŒ   Ú__classcell__)rN   s   @r   r(   r(   4   sg  ø„ ñ=ð~ *ÐØ$Ð&6Ð7Ðð
 ØØØØØØØØØØ#ØØ%)õ<
ð| ñ2ó ð2ð ñó ðòòòEò=òð JNñAØ ™9ðAØ3;¸DÀ¹IÑ3FðAà	ˆc‰óAð4 sxñXØ ™9ðXØ3;¸DÀ¹IÑ3FðXØkoðXà	ˆc‰õXð8 JNñLØ ™9ðLØ3;¸DÀ¹IÑ3FðLà	ˆc‰óLñ.¨cð ÀHÈSÁMð Ð]bÐcfÑ]g÷ r&   r(   c                   óJ   — e Zd ZdZ	 	 	 	 	 d
d„Zdd„Zd„ Zdd„Zd„ Zd„ Z	d	„ Z
y)rD   aª  
    Constructs a BasicTokenizer that will run basic tokenization (punctuation splitting, lower casing, etc.).

    Args:
        do_lower_case (`bool`, *optional*, defaults to `True`):
            Whether or not to lowercase the input when tokenizing.
        never_split (`Iterable`, *optional*):
            Collection of tokens which will never be split during tokenization. Only has an effect when
            `do_basic_tokenize=True`
        tokenize_chinese_chars (`bool`, *optional*, defaults to `True`):
            Whether or not to tokenize Chinese characters.

            This should likely be deactivated for Japanese (see this
            [issue](https://github.com/huggingface/transformers/issues/328)).
        strip_accents (`bool`, *optional*):
            Whether or not to strip all accents. If this option is not specified, then it will be determined by the
            value for `lowercase` (as in the original BERT).
        do_split_on_punc (`bool`, *optional*, defaults to `True`):
            In some instances we want to skip the basic punctuation splitting so that later tokenization can capture
            the full context of the words, such as contractions.
    Nc                 ód   — |€g }|| _         t        |«      | _        || _        || _        || _        y rP   )r.   Úsetr/   r0   r1   Údo_split_on_punc)rJ   r.   r/   r0   r1   rœ   s         r   rI   zBasicTokenizer.__init__U  s<   € ð ÐØˆKØ*ˆÔÜ˜{Ó+ˆÔØ&<ˆÔ#Ø*ˆÔØ 0ˆÕr&   c                 óJ  — |r$| j                   j                  t        |«      «      n| j                   }| j                  |«      }| j                  r| j                  |«      }t        j                  d|«      }t        |«      }g }|D ]€  }||vrY| j                  r0|j                  «       }| j                  dur/| j                  |«      }n| j                  r| j                  |«      }|j                  | j                  ||«      «       Œ‚ t        dj                  |«      «      }|S )aj  
        Basic Tokenization of a piece of text. For sub-word tokenization, see WordPieceTokenizer.

        Args:
            never_split (`List[str]`, *optional*)
                Kept for backward compatibility purposes. Now implemented directly at the base class level (see
                [`PreTrainedTokenizer.tokenize`]) List of token not to split.
        ÚNFCFrf   )r/   Úunionr›   Ú_clean_textr0   Ú_tokenize_chinese_charsÚunicodedataÚ	normalizer%   r.   Úlowerr1   Ú_run_strip_accentsÚextendÚ_run_split_on_puncrh   )rJ   r$   r/   Úunicode_normalized_textÚorig_tokensr^   r   Úoutput_tokenss           r   r[   zBasicTokenizer.tokenizee  s  € ñ CN�d×&Ñ&×,Ñ,¬S°Ó-=Ô>ÐSW×ScÑScˆØ×Ñ Ó%ˆð ×&Ò&Ø×/Ñ/°Ó5ˆDä"-×"7Ñ"7¸¸tÓ"DÐÜ)Ð*AÓBˆØˆØ ò 	MˆEØ˜KÑ'Ø×%Ò%Ø!ŸK™K›M�EØ×)Ñ)°Ñ6Ø $× 7Ñ 7¸Ó >™Ø×'Ò'Ø ×3Ñ3°EÓ:�EØ×Ñ × 7Ñ 7¸¸{Ó KÕLð	Mô ,¨C¯H©H°\Ó,BÓCˆØÐr&   c                 óº   — t        j                  d|«      }g }|D ].  }t        j                  |«      }|dk(  rŒ|j                  |«       Œ0 dj	                  |«      S )z$Strips accents from a piece of text.ÚNFDÚMnrg   )r¢   r£   Úcategoryr]   rh   )rJ   r$   ÚoutputÚcharÚcats        r   r¥   z!BasicTokenizer._run_strip_accents‹  s^   € ä×$Ñ$ U¨DÓ1ˆØˆØò 	 ˆDÜ×&Ñ& tÓ,ˆCØ�dŠ{ØØ�M‰M˜$Õð		 ð
 �w‰w�v‹Ðr&   c                 óv  — | j                   r|�||v r|gS t        |«      }d}d}g }|t        |«      k  rb||   }t        |«      r|j	                  |g«       d}n)|r|j	                  g «       d}|d   j	                  |«       |dz  }|t        |«      k  rŒb|D �cg c]  }dj                  |«      ‘Œ c}S c c}w )z&Splits punctuation on a piece of text.r   TFéÿÿÿÿrw   rg   )rœ   ÚlistrS   r
   r]   rh   )	rJ   r$   r/   ÚcharsÚiÚstart_new_wordr¯   r°   Úxs	            r   r§   z!BasicTokenizer._run_split_on_punc–  s¿   € à×$Ò$¨Ð)@ÀTÈ[ÑEXØ�6ˆMÜ�T“
ˆØˆØˆØˆØ”#�e“*ŠnØ˜‘8ˆDÜ˜tÔ$Ø—‘˜t˜fÔ%Ø!%‘á!Ø—M‘M "Ô%Ø!&�Ø�r‘
×!Ñ! $Ô'Ø�‰FˆAð ”#�e“*‹nð %+Ö+˜q�—‘˜•
Ò+Ð+ùÒ+s   ÂB6c                 óø   — g }|D ]c  }t        |«      }| j                  |«      r4|j                  d«       |j                  |«       |j                  d«       ŒS|j                  |«       Œe dj                  |«      S )z)Adds whitespace around any CJK character.rf   rg   )ÚordÚ_is_chinese_charr]   rh   ©rJ   r$   r¯   r°   Úcps        r   r¡   z&BasicTokenizer._tokenize_chinese_chars¬  sm   € àˆØò 	$ˆDÜ�T“ˆBØ×$Ñ$ RÔ(Ø—‘˜cÔ"Ø—‘˜dÔ#Ø—‘˜cÕ"à—‘˜dÕ#ð	$ð �w‰w�v‹Ðr&   c                 ó¦   — |dk\  r|dk  sF|dk\  r|dk  s<|dk\  r|dk  s2|dk\  r|dk  s(|d	k\  r|d
k  s|dk\  r|dk  s|dk\  r|dk  s
|dk\  r|dk  ryy)z6Checks whether CP is the codepoint of a CJK character.i N  iÿŸ  i 4  i¿M  i   iß¦ i § i?· i@· i¸ i ¸ i¯Î i ù  iÿú  i ø iú TFr;   )rJ   r½   s     r   r»   zBasicTokenizer._is_chinese_char¹  sr   € ð �6Š\˜b FšlØ�f’  v¢Ø�g’ "¨¢-Ø�g’ "¨¢-Ø�g’ "¨¢-Ø�g’ "¨¢-Ø�f’  v¢Ø�g’ "¨¢-ààr&   c                 óÔ   — g }|D ]Q  }t        |«      }|dk(  s|dk(  st        |«      rŒ$t        |«      r|j                  d«       ŒA|j                  |«       ŒS dj	                  |«      S )zBPerforms invalid character removal and whitespace cleanup on text.r   iýÿ  rf   rg   )rº   r	   r   r]   rh   r¼   s        r   r    zBasicTokenizer._clean_textÑ  sf   € àˆØò 	$ˆDÜ�T“ˆBØ�QŠw˜" š,¬+°dÔ*;ØÜ˜dÔ#Ø—‘˜cÕ"à—‘˜dÕ#ð	$ð �w‰w�v‹Ðr&   )TNTNTrP   )r�   r�   r‘   r’   rI   r[   r¥   r§   r¡   r»   r    r;   r&   r   rD   rD   >  s<   „ ñð0 ØØ#ØØó1ó $òL	ó,ò,òó0r&   rD   c                   ó   — e Zd ZdZdd„Zd„ Zy)rF   zRuns WordPiece tokenization.c                 ó.   — || _         || _        || _        y rP   )r   r2   Úmax_input_chars_per_word)rJ   r   r2   rÂ   s       r   rI   zWordpieceTokenizer.__init__ã  s   € ØˆŒ
Ø"ˆŒØ(@ˆÕ%r&   c                 ó  — g }t        |«      D ]÷  }t        |«      }t        |«      | j                  kD  r|j	                  | j
                  «       ŒBd}d}g }|t        |«      k  rst        |«      }d}	||k  r:dj                  ||| «      }
|dkD  rd|
z   }
|
| j                  v r|
}	n|dz  }||k  rŒ:|	€d}n"|j	                  |	«       |}|t        |«      k  rŒs|r|j	                  | j
                  «       Œç|j                  |«       Œù |S )aå  
        Tokenizes a piece of text into its word pieces. This uses a greedy longest-match-first algorithm to perform
        tokenization using the given vocabulary.

        For example, `input = "unaffable"` wil return as output `["un", "##aff", "##able"]`.

        Args:
            text: A single token or whitespace separated tokens. This should have
                already been passed through *BasicTokenizer*.

        Returns:
            A list of wordpiece tokens.
        Fr   Nrg   z##rw   T)	r%   r´   rS   rÂ   r]   r2   rh   r   r¦   )rJ   r$   rª   r   rµ   Úis_badÚstartÚ
sub_tokensÚendÚ
cur_substrÚsubstrs              r   r[   zWordpieceTokenizer.tokenizeè  s&  € ð ˆÜ(¨Ó.ò 	1ˆEÜ˜“KˆEÜ�5‹z˜D×9Ñ9Ò9Ø×$Ñ$ T§^¡^Ô4ØàˆFØˆEØˆJØœ#˜e›*Ò$Ü˜%“j�Ø!�
Ø˜c’kØŸW™W U¨5°Ð%5Ó6�FØ˜q’yØ!%¨¡˜Ø §¡Ñ+Ø%+˜
ØØ˜1‘H�Cð ˜c“kð Ð%Ø!�FØØ×!Ñ! *Ô-Ø�ð œ#˜e›*Ó$ñ" Ø×$Ñ$ T§^¡^Õ4à×$Ñ$ ZÕ0ð;	1ð< Ðr&   N)éd   )r�   r�   r‘   r’   rI   r[   r;   r&   r   rF   rF   à  s   „ Ù&óAó
.r&   rF   )r’   r   r>   r¢   Útypingr   r   r   Útokenization_utilsr   r   r	   r
   r   Úutilsr   Ú
get_loggerr�   r‡   r…   r    r%   r(   rD   rF   Ú__all__r;   r&   r   ú<module>rÐ      s}   ðñ  &ã Û 	Û ß (Ñ (ç oÕ oÝ ð 
ˆ×	Ñ	˜HÓ	%€à! ;Ð/Ð òòôFÐ(ô F÷T^ñ ^÷D6ñ 6ðr Ð
�r&   