
    bCi                         S r SSKrSSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
JrJr  \" 5       (       a  S	S
KJr  OSr\R                  " \5      rSSS.rSr " S S\	5      rS/rg)z.Fast tokenization classes for Camembert model.    N)copyfile)Optional   )
AddedToken)PreTrainedTokenizerFast)is_sentencepiece_availablelogging   )CamembertTokenizerzsentencepiece.bpe.modelztokenizer.json)
vocab_filetokenizer_fileu   ▁c                      ^  \ rS rSrSr\rSS/r\r	SSSSSSSS	S
/ SQ4
U 4S jjr
 SS\\   S\\\      S\\   4S jjr SS\\   S\\\      S\\   4S jjrSS\S\\   S\\   4S jjrSrU =r$ )CamembertTokenizerFast(   ax
  
Construct a "fast" CamemBERT tokenizer (backed by HuggingFace's *tokenizers* library). Adapted from
[`RobertaTokenizer`] and [`XLNetTokenizer`]. Based on
[BPE](https://huggingface.co/docs/tokenizers/python/latest/components.html?highlight=BPE#models).

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

Args:
    vocab_file (`str`):
        [SentencePiece](https://github.com/google/sentencepiece) file (generally has a *.spm* extension) that
        contains the vocabulary necessary to instantiate a tokenizer.
    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>

    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.
    additional_special_tokens (`list[str]`, *optional*, defaults to `["<s>NOTUSED", "</s>NOTUSED"]`):
        Additional special tokens used by the tokenizer.
	input_idsattention_maskNz<s>z</s>z<unk>z<pad>z<mask>)z
<s>NOTUSEDz</s>NOTUSEDz<unk>NOTUSEDc                    > [        U	[        5      (       a  [        U	SSS9OU	n	[        TU ]  " U4UUUUUUUU	U
S.	UD6  Xl        g )NT)lstripspecial)	r   	bos_token	eos_token	sep_token	cls_token	unk_token	pad_token
mask_tokenadditional_special_tokens)
isinstancestrr   super__init__r   )selfr   r   r   r   r   r   r   r   r   r   kwargs	__class__s               s/home/james-whalen/.local/lib/python3.13/site-packages/transformers/models/camembert/tokenization_camembert_fast.pyr!   CamembertTokenizerFast.__init__`   sg     KUU_adJeJeZ
4Fku
	
)!&?	
 	
 %    token_ids_0token_ids_1returnc                     Uc  U R                   /U-   U R                  /-   $ U R                   /nU R                  /nX1-   U-   U-   U-   U-   $ )a9  
Build model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and
adding special tokens. An CamemBERT 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)r"   r(   r)   clsseps        r%    build_inputs_with_special_tokens7CamembertTokenizerFast.build_inputs_with_special_tokens   se    ( %%&48I8I7JJJ  !  ! 3&,{:S@@r'   c                     U R                   /nU R                  /nUc  [        XA-   U-   5      S/-  $ [        XA-   U-   U-   U-   U-   5      S/-  $ )a  
Create a mask from the two sequences passed to be used in a sequence-pair classification task. CamemBERT, like
RoBERTa, 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   )r-   r,   len)r"   r(   r)   r/   r.   s        r%   $create_token_type_ids_from_sequences;CamembertTokenizerFast.create_token_type_ids_from_sequences   si        !  !s(3./1#553$s*S0;>DEKKr'   save_directoryfilename_prefixc                    U R                   (       d  [        S5      e[        R                  R	                  U5      (       d  [
        R                  SU S35        g [        R                  R                  X(       a  US-   OS[        S   -   5      n[        R                  R                  U R                  5      [        R                  R                  U5      :w  a  [        U R                  U5        U4$ )NzhYour fast tokenizer does not have the necessary information to save the vocabulary for a slow tokenizer.zVocabulary path (z) should be a directory- r   )can_save_slow_tokenizer
ValueErrorospathisdirloggererrorjoinVOCAB_FILES_NAMESabspathr   r   )r"   r6   r7   out_vocab_files       r%   save_vocabulary&CamembertTokenizerFast.save_vocabulary   s    ++ 
 ww}}^,,LL,^,<<STUo_s22QbcoQpp
 77??4??+rww~/NNT__n5  r'   )r   )N)__name__
__module____qualname____firstlineno____doc__rC   vocab_files_namesmodel_input_namesr   slow_tokenizer_classr!   listintr   r0   r4   r   tuplerF   __static_attributes____classcell__)r$   s   @r%   r   r   (   s    1f *$&67- "O%B JNA9A3;DI3FA	cA6 JNL9L3;DI3FL	cL.!c !HSM !]bcf]g ! !r'   r   )rL   r=   shutilr   typingr   tokenization_utilsr   tokenization_utils_fastr   utilsr   r	   tokenization_camembertr   
get_loggerrH   r@   rC   SPIECE_UNDERLINEr   __all__ r'   r%   <module>r_      sp    5 	   , > 8 : 
		H	%#<P`a   Z!4 Z!z $
$r'   