"""simple docstring"""





import numpy as np
from nltk.translate import meteor_score

import datasets
from datasets.config import importlib_metadata, version


__A  =				version.parse(importlib_metadata.version('''nltk'''))
if NLTK_VERSION >= version.Version('''3.6.4'''):
				from nltk import word_tokenize


__A  =				'''\
@inproceedings{banarjee2005,
  title     = {{METEOR}: An Automatic Metric for {MT} Evaluation with Improved Correlation with Human Judgments},
  author    = {Banerjee, Satanjeev  and Lavie, Alon},
  booktitle = {Proceedings of the {ACL} Workshop on Intrinsic and Extrinsic Evaluation Measures for Machine Translation and/or Summarization},
  month     = jun,
  year      = {2005},
  address   = {Ann Arbor, Michigan},
  publisher = {Association for Computational Linguistics},
  url       = {https://www.aclweb.org/anthology/W05-0909},
  pages     = {65--72},
}
'''

__A  =				'''\
METEOR, an automatic metric for machine translation evaluation
that is based on a generalized concept of unigram matching between the
machine-produced translation and human-produced reference translations.
Unigrams can be matched based on their surface forms, stemmed forms,
and meanings; furthermore, METEOR can be easily extended to include more
advanced matching strategies. Once all generalized unigram matches
between the two strings have been found, METEOR computes a score for
this matching using a combination of unigram-precision, unigram-recall, and
a measure of fragmentation that is designed to directly capture how
well-ordered the matched words in the machine translation are in relation
to the reference.

METEOR gets an R correlation value of 0.347 with human evaluation on the Arabic
data and 0.331 on the Chinese data. This is shown to be an improvement on
using simply unigram-precision, unigram-recall and their harmonic F1
combination.
'''

__A  =				'''
Computes METEOR score of translated segments against one or more references.
Args:
    predictions: list of predictions to score. Each prediction
        should be a string with tokens separated by spaces.
    references: list of reference for each prediction. Each
        reference should be a string with tokens separated by spaces.
    alpha: Parameter for controlling relative weights of precision and recall. default: 0.9
    beta: Parameter for controlling shape of penalty as a function of fragmentation. default: 3
    gamma: Relative weight assigned to fragmentation penalty. default: 0.5
Returns:
    \'meteor\': meteor score.
Examples:

    >>> meteor = datasets.load_metric(\'meteor\')
    >>> predictions = ["It is a guide to action which ensures that the military always obeys the commands of the party"]
    >>> references = ["It is a guide to action that ensures that the military will forever heed Party commands"]
    >>> results = meteor.compute(predictions=predictions, references=references)
    >>> print(round(results["meteor"], 4))
    0.6944
'''
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION				, _KWARGS_DESCRIPTION		)
class  _snake_case     (					datasets.Metric		):






						def       lowerCamelCase__     (       self      :			Tuple    ):
													return datasets.MetricInfo(
													    description=_DESCRIPTION							,					citation=_CITATION							,					inputs_description=_KWARGS_DESCRIPTION							,					features=datasets.Features(
													        {
													            "predictions": datasets.Value("string"							,					id="sequence"    ),
													            "references": datasets.Value("string"							,					id="sequence"    ),
													        }    )							,					codebase_urls=["https://github.com/nltk/nltk/blob/develop/nltk/translate/meteor_score.py"]							,					reference_urls=[
													        "https://www.nltk.org/api/nltk.translate.html#module-nltk.translate.meteor_score",
													        "https://en.wikipedia.org/wiki/METEOR",
													    ]							,					)






						def       lowerCamelCase__     (       self      :			Optional[int]							,					UpperCAmelCase      :			Tuple    ):
													import nltk

													nltk.download("wordnet"    )
													if NLTK_VERSION >= version.Version("3.6.5"    ):
																				nltk.download("punkt"    )
													if NLTK_VERSION >= version.Version("3.6.6"    ):
																				nltk.download("omw-1.4"    )







						def       lowerCamelCase__     (       self      :			int							,					UpperCAmelCase      :			Dict							,					UpperCAmelCase      :			Tuple							,					UpperCAmelCase      :			List[str]=0.9							,					UpperCAmelCase      :			List[Any]=3							,					UpperCAmelCase      :			Optional[Any]=0.5    ):
													if NLTK_VERSION >= version.Version("3.6.5"    ):
																				__lowerCamelCase					:		Tuple		   =     [
																				    meteor_score.single_meteor_score(
																				        word_tokenize(UpperCAmelCase    )							,					word_tokenize(UpperCAmelCase    )							,					alpha=UpperCAmelCase							,					beta=UpperCAmelCase							,					gamma=UpperCAmelCase    )
																				    for ref, pred in zip(UpperCAmelCase							,					UpperCAmelCase    )
																				]
													else:
																				__lowerCamelCase					:		List[str]		   =     [
																				    meteor_score.single_meteor_score(UpperCAmelCase							,					UpperCAmelCase							,					alpha=UpperCAmelCase							,					beta=UpperCAmelCase							,					gamma=UpperCAmelCase    )
																				    for ref, pred in zip(UpperCAmelCase							,					UpperCAmelCase    )
																				]

													return {"meteor": np.mean(UpperCAmelCase    )}
"""simple docstring"""





import json
from typing import List, Optional, Tuple

from tokenizers import normalizers

from ...tokenization_utils_fast import PreTrainedTokenizerFast
from ...utils import logging
from .tokenization_funnel import FunnelTokenizer


__A  =				logging.get_logger(__name__)

__A  =				{'''vocab_file''': '''vocab.txt''', '''tokenizer_file''': '''tokenizer.json'''}

__A  =				[
    '''small''',
    '''small-base''',
    '''medium''',
    '''medium-base''',
    '''intermediate''',
    '''intermediate-base''',
    '''large''',
    '''large-base''',
    '''xlarge''',
    '''xlarge-base''',
]

__A  =				{
    '''vocab_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/vocab.txt''',
        '''funnel-transformer/small-base''': '''https://huggingface.co/funnel-transformer/small-base/resolve/main/vocab.txt''',
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/vocab.txt''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/vocab.txt'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/vocab.txt''',
        '''funnel-transformer/large-base''': '''https://huggingface.co/funnel-transformer/large-base/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/vocab.txt''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/vocab.txt'''
        ),
    },
    '''tokenizer_file''': {
        '''funnel-transformer/small''': '''https://huggingface.co/funnel-transformer/small/resolve/main/tokenizer.json''',
        '''funnel-transformer/small-base''': (
            '''https://huggingface.co/funnel-transformer/small-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/medium''': '''https://huggingface.co/funnel-transformer/medium/resolve/main/tokenizer.json''',
        '''funnel-transformer/medium-base''': (
            '''https://huggingface.co/funnel-transformer/medium-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate''': (
            '''https://huggingface.co/funnel-transformer/intermediate/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/intermediate-base''': (
            '''https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/large''': '''https://huggingface.co/funnel-transformer/large/resolve/main/tokenizer.json''',
        '''funnel-transformer/large-base''': (
            '''https://huggingface.co/funnel-transformer/large-base/resolve/main/tokenizer.json'''
        ),
        '''funnel-transformer/xlarge''': '''https://huggingface.co/funnel-transformer/xlarge/resolve/main/tokenizer.json''',
        '''funnel-transformer/xlarge-base''': (
            '''https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/tokenizer.json'''
        ),
    },
}
__A  =				{F"""funnel-transformer/{name}""": 512 for name in _model_names}
__A  =				{F"""funnel-transformer/{name}""": {'''do_lower_case''': True} for name in _model_names}
class  _snake_case     (					a__		):
						snake_case__			  =			VOCAB_FILES_NAMES
						snake_case__			  =			PRETRAINED_VOCAB_FILES_MAP
						snake_case__			  =			PRETRAINED_INIT_CONFIGURATION
						snake_case__			  =			FunnelTokenizer
						snake_case__			  =			PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
						snake_case__			  =			2






						def __init__(       self      :			List[Any]							,					UpperCAmelCase      :			List[str]=None							,					UpperCAmelCase      :			Optional[int]=None							,					UpperCAmelCase      :			List[Any]=True							,					UpperCAmelCase      :			int="<unk>"							,					UpperCAmelCase      :			List[Any]="<sep>"							,					UpperCAmelCase      :			List[str]="<pad>"							,					UpperCAmelCase      :			Union[str, Any]="<cls>"							,					UpperCAmelCase      :			int="<mask>"							,					UpperCAmelCase      :			List[str]="<s>"							,					UpperCAmelCase      :			Union[str, Any]="</s>"							,					UpperCAmelCase      :			List[Any]=True							,					UpperCAmelCase      :			Tuple=True							,					UpperCAmelCase      :			int=None							,					UpperCAmelCase      :			int="##"							,					**UpperCAmelCase      :			Dict							,					):
													super().__init__(
													    UpperCAmelCase							,					tokenizer_file=UpperCAmelCase							,					do_lower_case=UpperCAmelCase							,					unk_token=UpperCAmelCase							,					sep_token=UpperCAmelCase							,					pad_token=UpperCAmelCase							,					cls_token=UpperCAmelCase							,					mask_token=UpperCAmelCase							,					bos_token=UpperCAmelCase							,					eos_token=UpperCAmelCase							,					clean_text=UpperCAmelCase							,					tokenize_chinese_chars=UpperCAmelCase							,					strip_accents=UpperCAmelCase							,					wordpieces_prefix=UpperCAmelCase							,					**UpperCAmelCase							,					)

													__lowerCamelCase					:		List[Any]		   =     json.loads(self.backend_tokenizer.normalizer.__getstate__()    )
													if (
													    normalizer_state.get("lowercase"							,					UpperCAmelCase    ) != do_lower_case
													    or normalizer_state.get("strip_accents"							,					UpperCAmelCase    ) != strip_accents
													    or normalizer_state.get("handle_chinese_chars"							,					UpperCAmelCase    ) != tokenize_chinese_chars
													):
																				__lowerCamelCase					:		Tuple		   =     getattr(UpperCAmelCase							,					normalizer_state.pop("type"    )    )
																				__lowerCamelCase					:		Optional[int]		   =     do_lower_case
																				__lowerCamelCase					:		Union[str, Any]		   =     strip_accents
																				__lowerCamelCase					:		Optional[Any]		   =     tokenize_chinese_chars
																				__lowerCamelCase					:		Optional[Any]		   =     normalizer_class(**UpperCAmelCase    )

													__lowerCamelCase					:		List[Any]		   =     do_lower_case






						def       lowerCamelCase__     (       self      :			Union[str, Any]							,					UpperCAmelCase      :			Union[str, Any]							,					UpperCAmelCase      :			Tuple=None    ):
													__lowerCamelCase					:		List[Any]		   =     [self.cls_token_id] + token_ids_a + [self.sep_token_id]

													if token_ids_a:
																				output += token_ids_a + [self.sep_token_id]

													return output






						def       lowerCamelCase__     (       self      :			Dict							,					UpperCAmelCase      :			List[int]							,					UpperCAmelCase      :			Optional[List[int]] = None    ):
													__lowerCamelCase					:		Tuple		   =     [self.sep_token_id]
													__lowerCamelCase					:		int		   =     [self.cls_token_id]
													if token_ids_a is None:
																				return len(cls    ) * [self.cls_token_type_id] + len(token_ids_a + sep    ) * [0]
													return len(cls    ) * [self.cls_token_type_id] + len(token_ids_a + sep    ) * [0] + len(token_ids_a + sep    ) * [1]







						def       lowerCamelCase__     (       self      :			Tuple							,					UpperCAmelCase      :			str							,					UpperCAmelCase      :			Optional[str] = None    ):
													__lowerCamelCase					:		List[Any]		   =     self._tokenizer.model.save(UpperCAmelCase							,					name=UpperCAmelCase    )
													return tuple(UpperCAmelCase    )