
    qi                         d Z ddlmZmZmZmZmZmZmZ ddl	m
Z
 ddlm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dZdZ G d de      ZdgZy)z%Tokenization classes for XLNet model.    )
AddedTokenRegex	Tokenizerdecodersnormalizerspre_tokenizers
processors)Unigram   )_get_prepend_scheme)TokenizersBackend)loggingzspiece.modelztokenizer.json)
vocab_filetokenizer_file   ▁         c                   p     e Zd ZdZeZdZeZ	 	 	 	 	 	 	 	 	 	 	 	 	 dde	e
ee	ef      z  dz  def fdZ xZS )XLNetTokenizera  
    Construct a XLNet tokenizer (backed by HuggingFace's *tokenizers* library). Based on
    [Unigram](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=unigram#models).

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

    Args:
        vocab (`list of tuples`, *optional*):
            List of (token, score) tuples for Unigram model. If not provided, an empty list is used.
        unk_id (`int`, *optional*, defaults to 0):
            The ID of the unknown token in the vocabulary.
        do_lower_case (`bool`, *optional*, defaults to `False`):
            Whether to lowercase the input when tokenizing.
        remove_space (`bool`, *optional*, defaults to `True`):
            Whether to strip the text when tokenizing (removing excess spaces before and after the string).
        keep_accents (`bool`, *optional*, defaults to `False`):
            Whether to keep accents when tokenizing.
        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>

        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>

        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.
        additional_special_tokens (`list[str]`, *optional*, defaults to `["<eop>", "<eod>"]`):
            Additional special tokens used by the tokenizer.
    leftNvocabunk_idc                    |ddg}||| _         nt        |      dfg| _         t        t        | j                   |d            | _        t        j                  dd      t        j                  dd      g}|j                  t        j                                |j                  t        j                                |r#|j                  t        j                                |j                  t        j                  t        d	      d
             t        j                  |      | j                  _        d}t        ||       }t        j                  t        j                          t        j"                  d|      g      | j                  _        t'        j"                  d|      | j                  _        d| _        || _        || _        || _        t3        |t              rt5        |dd      n|}t7        | p  d||||||||	|
|||d| t;        j<                  dt        | j>                         dt        | j@                         ddt        | j>                         dt        | j>                         dt        | j@                         dt        | j>                        | jB                  ft        | j@                        | jD                  fg      | j                  _#        y )Nz<eop>z<eod>g        F)r   byte_fallbackz``"z''z {2,} Tr   )replacementprepend_schemer   )lstriprstrip)r   do_lower_caseremove_spacekeep_accents	bos_token	eos_token	unk_token	sep_token	pad_token	cls_token
mask_tokenadditional_special_tokensz$A:0 z:0 z:2z:0 $B:1 z:1 )singlepairspecial_tokens )$_vocabstrr   r
   
_tokenizerr   ReplaceappendNFKDStripAccents	Lowercaser   Sequence
normalizerr   r   WhitespaceSplit	Metaspacepre_tokenizerr   decoder_pad_token_type_idr"   r#   r$   
isinstancer   super__init__r	   TemplateProcessingr(   r*   sep_token_idcls_token_idpost_processor)selfr   r   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   kwargslist_normalizersadd_prefix_spacer   	__class__s                     ^/opt/pipecat/venv/lib/python3.12/site-packages/transformers/models/xlnet/tokenization_xlnet.pyrB   zXLNetTokenizer.__init__d   s   " %,)0'(:%DK	NC01DK##
 c*c*

 	 0 0 23 8 8 :;##K$9$9$;< 3 3E'NC HI%0%9%9:J%K",-=tD(6(?(?..0((U>Z)
% #+"4"4We"f"#*((JTU_adJeZ
4Fku
 	
'%%!&?	
 	
  *4)F)F3t~~./s3t~~3F2GrJT^^,-Xc$..6I5J#cRVR`R`NaMbbdeT^^$d&7&78T^^$d&7&78*
&    )Nr   FTFz<s>z</s>z<unk>z<sep>z<pad>z<cls>z<mask>N)__name__
__module____qualname____doc__VOCAB_FILES_NAMESvocab_files_namespadding_sider
   modelr2   listtuplefloatintrB   __classcell__)rK   s   @rL   r   r   &   s|    7r *LE 7;"&T
T%U
+,,t3T
 T
 T
rM   r   N)rQ   
tokenizersr   r   r   r   r   r   r	   tokenizers.modelsr
   tokenization_utils_baser   tokenization_utils_tokenizersr   utilsr   
get_loggerrN   loggerrR   SPIECE_UNDERLINESEG_ID_ASEG_ID_B
SEG_ID_CLS
SEG_ID_SEP
SEG_ID_PADr   __all__r0   rM   rL   <module>ri      sz    , f f f % : >  
		H	%#1EUV   


R
& R
j 
rM   