§
    ‚Štj„  ã                   óš   — d Z ddl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  ej        e¦  «        Zddd	œZ G d
„ de¦  «        ZdgZdS )z%Tokenization class for model PEGASUS.é    )ÚRegexÚ	TokenizerÚdecodersÚnormalizersÚpre_tokenizersÚ
processors)ÚUnigramé   )ÚTokenizersBackend)Úloggingzspiece.modelztokenizer.json)Ú
vocab_fileÚtokenizer_filec                   ót   ‡ — e Zd ZdZeZddgZeZ	 	 	 	 	 	 	 	 	 dde	e
ee	ef                  z  dz  fˆ fd„Zˆ xZS )ÚPegasusTokenizera  
    Construct a PEGASUS 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_file (`str`, *optional*):
            [SentencePiece](https://github.com/google/sentencepiece) file (generally has a *.spm* extension) that
            contains the vocabulary necessary to instantiate a tokenizer.
        pad_token (`str`, *optional*, defaults to `"<pad>"`):
            The token used for padding, for example when batching sequences of different lengths.
        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.
        mask_token (`str`, *optional*, defaults to `"<mask_2>"`):
            The token used for masking single token values. This is the token used when training this model with masked
            language modeling (MLM). This is the token that the PEGASUS encoder will try to predict during pretraining.
            It corresponds to *[MASK2]* in [PEGASUS: Pre-training with Extracted Gap-sentences for Abstractive
            Summarization](https://huggingface.co/papers/1912.08777).
        mask_token_sent (`str`, *optional*, defaults to `"<mask_1>"`):
            The token used for masking whole target sentences. This is the token used when training this model with gap
            sentences generation (GSG). This is the sentence that the PEGASUS decoder will try to predict during
            pretraining. It corresponds to *[MASK1]* in [PEGASUS: Pre-training with Extracted Gap-sentences for
            Abstractive Summarization](https://huggingface.co/papers/1912.08777).
        additional_special_tokens (`List[str]`, *optional*):
            Additional special tokens used by the tokenizer. If no additional_special_tokens are provided <mask_2> and
            <unk_2, ..., unk_102> are used as additional special tokens corresponding to the [original PEGASUS
            tokenizer](https://github.com/google-research/pegasus/blob/939830367bcf411193d2b5eca2f2f90f3f9260ca/pegasus/ops/pretrain_parsing_ops.cc#L66)
            that uses the tokens 2 - 104 only for pretraining
        offset (`int`, *optional*, defaults to 103):
            Offset for additional special tokens.
        vocab (`str` or `list[tuple[str, float]]`, *optional*):
            Custom vocabulary with `(token, score)` tuples. If not provided, a blank vocabulary is initialized.
    Ú	input_idsÚattention_maskNú<pad>ú</s>ú<unk>ú<mask_2>ú<mask_1>ég   Úvocabc
                 ó„  •— |	| _         |�||vr|�|gng }ng }|d„ t          d| j         ¦  «        D ¦   «         z  }|€Bt          |¦  «        dft          |¦  «        dft          |¦  «        dft          |¦  «        dfg}|| _        t	          t          || j                             t          |¦  «        dfd¦  «        ¬¦  «        ¦  «        | _        |�St          j	        t          j
        |¦  «        t          j        t          d¦  «        d¦  «        g¦  «        | j        _        n`t          j	        t          j        t          d¦  «        d¦  «        t          j        t          d¦  «        d¦  «        g¦  «        | j        _        t          j        d	d
d¬¦  «        | j        _        t#          j        d	d
d¬¦  «        | j        _         t'          ¦   «         j        d||||||	|dœ|
¤Ž t+          j        d|› �d|› �t          |¦  «        |                      t          |¦  «        ¦  «        fg¬¦  «        | j        _        d S )Nc                 ó   — g | ]}d |› d�‘Œ	S )z<unk_ú>© )Ú.0Úis     ún/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/transformers/models/pegasus/tokenization_pegasus.pyú
<listcomp>z-PegasusTokenizer.__init__.<locals>.<listcomp>c   s    € Ð%RÐ%RÐ%R°q l¨a l l lÐ%RÐ%RÐ%Ró    é   g        é   )r   Úunk_idz {2,}ú z\nu   â–�ÚalwaysT)ÚreplacementÚprepend_schemeÚsplit)Ú	pad_tokenÚ	eos_tokenÚ	unk_tokenÚ
mask_tokenÚmask_token_sentÚoffsetÚadditional_special_tokensz$A z$A $B )ÚsingleÚpairÚspecial_tokensr   )r0   ÚrangeÚstrÚ_vocabr   r	   ÚindexÚ
_tokenizerr   ÚSequenceÚPrecompiledÚReplacer   Ú
normalizerr   Ú	MetaspaceÚpre_tokenizerr   ÚdecoderÚsuperÚ__init__r   ÚTemplateProcessingÚconvert_tokens_to_idsÚpost_processor)Úselfr   r+   r,   r-   r.   r/   Ú_spm_precompiled_charsmapr1   r0   ÚkwargsÚ	__class__s              €r    rB   zPegasusTokenizer.__init__P   sa  ø€ ð ˆŒà$Ð,°ÐG`Ð0`Ð0`Ø=LÐ=X¨Ð(9Ð(9Ð^`Ð%Ð%à(*Ð%Ø!Ð%RÐ%R½EÀ!ÀTÄ[Ñ<QÔ<QÐ%RÑ%RÔ%RÑRÐ!àˆ=Ý˜)‘n”n cÐ*­S°©^¬^¸SÐ,AÅCÈ	ÁNÄNÐTWÐCXÕ[^Ð_iÑ[jÔ[jÐloÐZpÐqˆEàˆŒÝ#¥G°%ÀÄ×@QÒ@QÕSVÐW`ÑSaÔSaÐcfÐRgÐijÑ@kÔ@kÐ$lÑ$lÔ$lÑmÔmˆŒØ$Ð0Ý)4Ô)=ÝÔ(Ð)BÑCÔCÅ[ÔEXÕY^Ð_gÑYhÔYhÐjmÑEnÔEnÐoñ*ô *ˆDŒOÔ&Ð&õ *5Ô)=ÝÔ$¥U¨5¡\¤\°3Ñ7Ô7½Ô9LÍUÐS[É_Ì_Ð^aÑ9bÔ9bÐcñ*ô *ˆDŒOÔ&õ )7Ô(@ÈUÐckÐswÐ(xÑ(xÔ(xˆŒÔ%Ý"*Ô"4ÀÐW_ÐgkÐ"lÑ"lÔ"lˆŒÔà�‰ŒÔð 		
ØØØØ!Ø+ØØ&?ð		
ð 		
ð ð		
ð 		
ð 		
õ *4Ô)FØ$˜Ð$Ð$Ø%˜)Ð%Ð%Ý  ™^œ^¨T×-GÒ-GÍÈIÉÌÑ-WÔ-WÐXÐYð*
ñ *
ô *
ˆŒÔ&Ð&Ð&r"   )	Nr   r   r   r   r   NNr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚVOCAB_FILES_NAMESÚvocab_files_namesÚmodel_input_namesr	   Úmodelr6   ÚlistÚtupleÚfloatrB   Ú__classcell__)rI   s   @r    r   r      s£   ø€ € € € € ð-ð -ð^ *ÐØ$Ð&6Ð7ÐØ€Eð 7;ØØØØØ"Ø"&Ø"&Øð4
ð 4
à�T˜%  U 
Ô+Ô,Ñ,¨tÑ3ð4
ð 4
ð 4
ð 4
ð 4
ð 4
ð 4
ð 4
ð 4
ð 4
r"   r   N)rM   Ú
tokenizersr   r   r   r   r   r   Útokenizers.modelsr	   Útokenization_utils_tokenizersr   Úutilsr   Ú
get_loggerrJ   ÚloggerrN   r   Ú__all__r   r"   r    ú<module>r]      sØ   ðð ,Ð +à ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZÐ ZØ %Ð %Ð %Ð %Ð %Ð %à >Ð >Ð >Ð >Ð >Ð >Ø Ð Ð Ð Ð Ð ð 
ˆÔ	˜HÑ	%Ô	%€à#1ÐEUÐVÐVÐ ðh
ð h
ð h
ð h
ð h
Ð(ñ h
ô h
ð h
ðV Ð
€€€r"   