Ë
    T^(hõQ  ã                   óÔ   — 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 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 Splinter.é    N)ÚListÚOptionalÚTupleé   )Ú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         úp/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/transformers/models/splinter/tokenization_splinter.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            
       óF  ‡ — e Zd ZdZeZ	 	 	 	 	 	 	 	 	 	 	 dˆ fd„	Ze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 )ÚSplinterTokenizeraœ
  
    Construct a Splinter tokenizer. Based on WordPiece.

    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`):
            File containing the vocabulary.
        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`
        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.
        sep_token (`str`, *optional*, defaults to `"[SEP]"`):
            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 `"[CLS]"`):
            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 `"[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.
        question_token (`str`, *optional*, defaults to `"[QUESTION]"`):
            The token used for constructing question representations.
        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).
    c                 óä  •— t         j                  j                  |«      st        d|› d�«      ‚t	        |«      | _        t        j                  | j
                  j                  «       D ��cg c]	  \  }}||f‘Œ c}}«      | _	        || _
        |rt        ||||¬«      | _        t        | j
                  t        |«      ¬«      | _        |
| _        t#        ‰| �H  d||||||||	|
||dœ|¤Ž y c c}}w )Nz&Can't find a vocabulary file at path 'z'. To load the vocabulary from a Google pretrained model use `tokenizer = BertTokenizer.from_pretrained(PRETRAINED_MODEL_NAME)`)Údo_lower_caseÚnever_splitÚtokenize_chinese_charsÚstrip_accents)r   Ú	unk_token)r)   Údo_basic_tokenizer*   r-   Ú	sep_tokenÚ	pad_tokenÚ	cls_tokenÚ
mask_tokenÚquestion_tokenr+   r,   © )ÚosÚpathÚisfileÚ
ValueErrorr   r   r   r   ÚitemsÚids_to_tokensr.   ÚBasicTokenizerÚbasic_tokenizerÚWordpieceTokenizerÚstrÚwordpiece_tokenizerr3   ÚsuperÚ__init__)Úselfr   r)   r.   r*   r-   r/   r0   r1   r2   r3   r+   r,   ÚkwargsÚtokÚidsÚ	__class__s                   €r   rA   zSplinterTokenizer.__init__b   s  ø€ ô  �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Ø'ñ	
ð ó	
ùó 6es   Á,C,
c                 ó8   — | j                  | j                  «      S )z‘
        `Optional[int]`: Id of the question token in the vocabulary, used to condition the answer on a question
        representation.
        )Úconvert_tokens_to_idsr3   ©rB   s    r   Úquestion_token_idz#SplinterTokenizer.question_token_id’   s   € ð ×)Ñ)¨$×*=Ñ*=Ó>Ð>r%   c                 ó.   — | j                   j                  S ©N)r<   r)   rI   s    r   r)   zSplinterTokenizer.do_lower_caseš   s   € à×#Ñ#×1Ñ1Ð1r%   c                 ó,   — t        | j                  «      S rL   )Úlenr   rI   s    r   Ú
vocab_sizezSplinterTokenizer.vocab_sizež   s   € ä�4—:‘:‹Ðr%   c                 óB   — t        | j                  fi | j                  ¤ŽS rL   )Údictr   Úadded_tokens_encoderrI   s    r   Ú	get_vocabzSplinterTokenizer.get_vocab¢   s   € Ü�D—J‘JÑ< $×";Ñ";Ñ<Ð<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*   )r.   r<   ÚtokenizeÚall_special_tokensr*   Úappendr?   )rB   r#   Úsplit_tokensr   s       r   Ú	_tokenizezSplinterTokenizer._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   Úgetr-   )rB   r   s     r   Ú_convert_token_to_idz&SplinterTokenizer._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.)r:   r[   r-   )rB   r   s     r   Ú_convert_id_to_tokenz&SplinterTokenizer._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!   )rB   r   Ú
out_strings      r   Úconvert_tokens_to_stringz*SplinterTokenizer.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}| j                  g| j                  d«      gz   }| j                  dk(  r||z   |z   |z   |z   |z   S ||z   |z   |z   |z   |z   S )aÞ  
        Build model inputs from a pair of sequence for question answering tasks by concatenating and adding special
        tokens. A Splinter sequence has the following format:

        - single sequence: `[CLS] X [SEP]`
        - pair of sequences for question answering: `[CLS] question_tokens [QUESTION] . [SEP] context_tokens [SEP]`

        Args:
            token_ids_0 (`List[int]`):
                The question token IDs if pad_on_right, else context tokens IDs
            token_ids_1 (`List[int]`, *optional*):
                The context token IDs if pad_on_right, else question token IDs

        Returns:
            `List[int]`: List of [input IDs](../glossary#input-ids) with the appropriate special tokens.
        ú.Úright)Úcls_token_idÚsep_token_idrJ   rH   Úpadding_side)rB   rf   rg   ÚclsÚsepÚquestion_suffixs         r   Ú build_inputs_with_special_tokensz2SplinterTokenizer.build_inputs_with_special_tokens¿   s¸   € ð& ÐØ×%Ñ%Ð&¨Ñ4¸×8IÑ8IÐ7JÑJÐJà× Ñ Ð!ˆØ× Ñ Ð!ˆØ×1Ñ1Ð2°d×6PÑ6PÐQTÓ6UÐ5VÑVˆØ×Ñ Ò'à˜Ñ$ Ñ6¸Ñ<¸{ÑJÈSÑPÐPð ˜Ñ$ sÑ*¨[Ñ8¸?ÑJÈSÑPÐPr%   Úalready_has_special_tokensc                 ó´   •— |rt         ‰| �  ||d¬«      S |�+d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)rf   rg   rs   é   r   )r@   Úget_special_tokens_maskrN   )rB   rf   rg   rs   rF   s       €r   rv   z)SplinterTokenizer.get_special_tokens_maskß   s‰   ø€ ñ& &Ü‘7Ñ2Ø'°[Ð]að 3ó ð ð Ð"Ø�3˜1˜#¤ KÓ 0Ñ0Ñ1°Q°CÑ7¸A¸3ÄÀ[ÓAQÑ;QÑRÐVWÐUXÑXÐXØˆs�q�cœC Ó,Ñ,Ñ-°°Ñ3Ð3r%   c                 ón  — | j                   g}| j                  g}| j                  g| j                  d«      gz   }|€t	        ||z   |z   «      dgz  S | j
                  dk(  r+t	        ||z   |z   |z   «      dgz  t	        ||z   «      dgz  z   S t	        ||z   |z   «      dgz  t	        ||z   |z   «      dgz  z   S )aÔ  
        Create the token type IDs corresponding to the sequences passed. [What are token type
        IDs?](../glossary#token-type-ids)

        Should be overridden in a subclass if the model has a special way of building those.

        Args:
            token_ids_0 (`List[int]`): The first tokenized sequence.
            token_ids_1 (`List[int]`, *optional*): The second tokenized sequence.

        Returns:
            `List[int]`: The token type ids.
        rj   r   rk   ru   )rm   rl   rJ   rH   rN   rn   )rB   rf   rg   rp   ro   rq   s         r   Ú$create_token_type_ids_from_sequencesz6SplinterTokenizer.create_token_type_ids_from_sequencesû   sè   € ð  × Ñ Ð!ˆØ× Ñ Ð!ˆØ×1Ñ1Ð2°d×6PÑ6PÐQTÓ6UÐ5VÑVˆØÐÜ�s˜[Ñ(¨3Ñ.Ó/°1°#Ñ5Ð5à×Ñ Ò'ä�s˜[Ñ(¨?Ñ:¸SÑ@ÓAÀQÀCÑGÌ#ÈkÐ\_ÑN_ÓJ`ÐdeÐcfÑJfÑfÐfô �s˜[Ñ(¨3Ñ.Ó/°1°#Ñ5¼¸KÈ/Ñ<YÐ\_Ñ<_Ó8`ÐdeÐcfÑ8fÑfÐfr%   Ú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   ú-ra   r   Úwr   r   c                 ó   — | d   S )Nru   r4   )Úkvs    r   ú<lambda>z3SplinterTokenizer.save_vocabulary.<locals>.<lambda>!  s   € ÐPRÐSTÑPU€ r%   )ÚkeyzSaving vocabulary to z\: vocabulary indices are not consecutive. Please check that the vocabulary is not corrupted!r   ru   )r5   r6   Úisdirrb   ÚVOCAB_FILES_NAMESr   Úsortedr   r9   ÚloggerÚwarningÚwrite)rB   ry   rz   r   r   Úwriterr   Útoken_indexs           r   Úsave_vocabularyz!SplinterTokenizer.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-)TTNz[UNK]z[SEP]z[PAD]z[CLS]z[MASK]z
[QUESTION]TNrL   )NF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rƒ   Úvocab_files_namesrA   ÚpropertyrJ   r)   rO   rS   rY   r\   r^   re   r   Úintr   rr   Úboolrv   rx   r>   r   rŠ   Ú__classcell__)rF   s   @r   r'   r'   4   se  ø„ ñ)ðV *Ðð
 ØØØØØØØØ#Ø#Øõ.
ð` ñ?ó ð?ð ñ2ó ð2ð ñó ðò=òòEò=òð JNñQØ ™9ðQØ3;¸DÀ¹IÑ3FðQà	ˆc‰óQðB sxñ4Ø ™9ð4Ø3;¸DÀ¹IÑ3Fð4Økoð4à	ˆc‰õ4ð: JNñgØ ™9ðgØ3;¸DÀ¹IÑ3Fðgà	ˆc‰ógñ:¨cð ÀHÈSÁMð Ð]bÐcfÑ]g÷ r%   r'   c                   ó@   — e Zd ZdZd
d„Zdd„Zd„ Zdd„Zd„ Zd„ Z	d	„ Z
y)r;   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).
    Nc                 óV   — |€g }|| _         t        |«      | _        || _        || _        y rL   )r)   Úsetr*   r+   r,   )rB   r)   r*   r+   r,   s        r   rA   zBasicTokenizer.__init__A  s2   € ØÐØˆKØ*ˆÔÜ˜{Ó+ˆÔØ&<ˆÔ#Ø*ˆÕr%   c                 ó  — |r$| j                   j                  t        |«      «      n| j                   }| j                  |«      }| j                  r| j                  |«      }t        |«      }g }|D ]€  }||vrY| j                  r0|j                  «       }| j                  dur/| j                  |«      }n| j                  r| j                  |«      }|j                  | j                  ||«      «       Œ‚ t        dj                  |«      «      }|S )a”  
        Basic Tokenization of a piece of text. Split on "white spaces" only, for sub-word tokenization, see
        WordPieceTokenizer.

        Args:
            **never_split**: (*optional*) list of str
                Kept for backward compatibility purposes. Now implemented directly at the base class level (see
                [`PreTrainedTokenizer.tokenize`]) List of token not to split.
        Fr`   )r*   Úunionr–   Ú_clean_textr+   Ú_tokenize_chinese_charsr$   r)   Úlowerr,   Ú_run_strip_accentsÚextendÚ_run_split_on_puncrb   )rB   r#   r*   Úorig_tokensrX   r   Úoutput_tokenss          r   rU   zBasicTokenizer.tokenizeI  s   € ñ CN�d×&Ñ&×,Ñ,¬S°Ó-=Ô>ÐSW×ScÑScˆØ×Ñ Ó%ˆð ×&Ò&Ø×/Ñ/°Ó5ˆDÜ)¨$Ó/ˆØˆØ ò 	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ÚMnra   )ÚunicodedataÚ	normalizeÚcategoryrW   rb   )rB   r#   ÚoutputÚcharÚcats        r   rœ   z!BasicTokenizer._run_strip_accentsn  s^   € ä×$Ñ$ U¨DÓ1ˆØˆØò 	 ˆDÜ×&Ñ& tÓ,ˆCØ�dŠ{ØØ�M‰M˜$Õð		 ð
 �w‰w�v‹Ðr%   c                 ó^  — |�||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éÿÿÿÿru   ra   )ÚlistrN   r	   rW   rb   )	rB   r#   r*   ÚcharsÚiÚstart_new_wordr§   r¨   Úxs	            r   rž   z!BasicTokenizer._run_split_on_puncy  s·   € àÐ" t¨{Ñ':Ø�6ˆMÜ�T“
ˆØˆØˆØˆØ”#�e“*ŠnØ˜‘8ˆDÜ˜tÔ$Ø—‘˜t˜fÔ%Ø!%‘á!Ø—M‘M "Ô%Ø!&�Ø�r‘
×!Ñ! $Ô'Ø�‰FˆAð ”#�e“*‹nð %+Ö+˜q�—‘˜•
Ò+Ð+ùÒ+s   ÂB*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.r`   ra   )ÚordÚ_is_chinese_charrW   rb   ©rB   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ú TFr4   )rB   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ýÿ  r`   ra   )r²   r   r
   rW   rb   r´   s        r   r™   zBasicTokenizer._clean_text´  sf   € àˆØò 	$ˆDÜ�T“ˆBØ�QŠw˜" š,¬+°dÔ*;ØÜ˜dÔ#Ø—‘˜cÕ"à—‘˜dÕ#ð	$ð �w‰w�v‹Ðr%   )TNTNrL   )r‹   rŒ   r�   rŽ   rA   rU   rœ   rž   rš   r³   r™   r4   r%   r   r;   r;   -  s+   „ ñó&+ó#òJ	ó,ò,òó0r%   r;   c                   ó   — e Zd ZdZdd„Zd„ Zy)r=   zRuns WordPiece tokenization.c                 ó.   — || _         || _        || _        y rL   )r   r-   Úmax_input_chars_per_word)rB   r   r-   rº   s       r   rA   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   Nra   z##ru   T)	r$   r¬   rN   rº   rW   r-   rb   r   r�   )rB   r#   r    r   r­   Úis_badÚstartÚ
sub_tokensÚendÚ
cur_substrÚsubstrs              r   rU   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Ž   rA   rU   r4   r%   r   r=   r=   Â  s   „ Ù&óAó
.r%   r=   )rŽ   r   r5   r¤   Útypingr   r   r   Útokenization_utilsr   r   r	   r
   Úutilsr   Ú
get_loggerr‹   r…   rƒ   r   r$   r'   r;   r=   Ú__all__r4   r%   r   ú<module>rÈ      s}   ðñ  )ã Û 	Û ß (Ñ (ç cÓ cÝ ð 
ˆ×	Ñ	˜HÓ	%€à! ;Ð/Ð òòôvÐ+ô v÷rRñ R÷j6ñ 6ðr Ð
�r%   