






import re
import string

import numpy as np

import datasets


SCREAMING_SNAKE_CASE__   :      List[Any]				=		"""
Returns the rate at which the input predicted strings exactly match their references, ignoring any strings input as part of the regexes_to_ignore list.
"""

SCREAMING_SNAKE_CASE__   :      Tuple				=		"""
Args:
    predictions: List of predicted texts.
    references: List of reference texts.
    regexes_to_ignore: List, defaults to None. Regex expressions of characters to
        ignore when calculating the exact matches. Note: these regexes are removed
        from the input data before the changes based on the options below (e.g. ignore_case,
        ignore_punctuation, ignore_numbers) are applied.
    ignore_case: Boolean, defaults to False. If true, turns everything
        to lowercase so that capitalization differences are ignored.
    ignore_punctuation: Boolean, defaults to False. If true, removes all punctuation before
        comparing predictions and references.
    ignore_numbers: Boolean, defaults to False. If true, removes all punctuation before
        comparing predictions and references.
Returns:
    exact_match: Dictionary containing exact_match rate. Possible values are between 0.0 and 100.0, inclusive.
Examples:
    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    25.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    50.0


    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True)
    >>> print(round(results[\"exact_match\"], 1))
    75.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"the cat\", \"theater\", \"YELLING\", \"agent007\"]
    >>> preds = [\"cat?\", \"theater\", \"yelling\", \"agent\"]
    >>> results = exact_match.compute(references=refs, predictions=preds, regexes_to_ignore=[\"the \", \"yell\", \"YELL\"], ignore_case=True, ignore_punctuation=True, ignore_numbers=True)
    >>> print(round(results[\"exact_match\"], 1))
    100.0

    >>> exact_match = datasets.load_metric(\"exact_match\")
    >>> refs = [\"The cat sat on the mat.\", \"Theaters are great.\", \"It's like comparing oranges and apples.\"]
    >>> preds = [\"The cat sat on the mat?\", \"Theaters are great.\", \"It's like comparing apples and oranges.\"]
    >>> results = exact_match.compute(references=refs, predictions=preds)
    >>> print(round(results[\"exact_match\"], 1))
    33.3

"""

SCREAMING_SNAKE_CASE__   :      Optional[Any]				=		"""
"""
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION      ,					_KWARGS_DESCRIPTION			)
class     lowerCamelCase_					(   datasets.Metric			):







				def       A						(    self  ):
								"""simple docstring"""
								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'''  ),
								        }  )							,       reference_urls=[]							,       )







				def       A						(    self							,       __lowerCAmelCase							,       __lowerCAmelCase							,       __lowerCAmelCase=None							,       __lowerCAmelCase=False							,       __lowerCAmelCase=False							,       __lowerCAmelCase=False							,       ):
								"""simple docstring"""
								if regexes_to_ignore is not None:
												for s in regexes_to_ignore:
																__magic_name__		:str   =   np.array([re.sub(__lowerCAmelCase							,       ''''''							,       __lowerCAmelCase  ) for x in predictions]  )
																__magic_name__		:Dict   =   np.array([re.sub(__lowerCAmelCase							,       ''''''							,       __lowerCAmelCase  ) for x in references]  )
								else:
												__magic_name__		:Tuple   =   np.asarray(__lowerCAmelCase  )
												__magic_name__		:Dict   =   np.asarray(__lowerCAmelCase  )

								if ignore_case:
												__magic_name__		:int   =   np.char.lower(__lowerCAmelCase  )
												__magic_name__		:Union[str, Any]   =   np.char.lower(__lowerCAmelCase  )

								if ignore_punctuation:
												__magic_name__		:List[Any]   =   string.punctuation.maketrans(''''''							,       ''''''							,       string.punctuation  )
												__magic_name__		:int   =   np.char.translate(__lowerCAmelCase							,       table=__lowerCAmelCase  )
												__magic_name__		:Any   =   np.char.translate(__lowerCAmelCase							,       table=__lowerCAmelCase  )

								if ignore_numbers:
												__magic_name__		:Any   =   string.digits.maketrans(''''''							,       ''''''							,       string.digits  )
												__magic_name__		:Optional[Any]   =   np.char.translate(__lowerCAmelCase							,       table=__lowerCAmelCase  )
												__magic_name__		:Tuple   =   np.char.translate(__lowerCAmelCase							,       table=__lowerCAmelCase  )

								__magic_name__		:Optional[Any]   =   predictions == references

								return {"exact_match": np.mean(__lowerCAmelCase  ) * 1_0_0}














def   __lowercase       (			snake_case			):







				"""simple docstring"""






				return "".join([hex(snake_case			)[2:].zfill(2			).upper() for byte in list(snake_case			)]			)

def   __lowercase       (			snake_case			):







				"""simple docstring"""






				if (len(snake_case			) % 2) != 0:
								raise ValueError(
								    '''Base16 encoded data is invalid:
Data does not have an even number of hex digits.'''			)
				# Check the character set - the standard base16 alphabet
				# is uppercase according to RFC3548 section 6
				if not set(snake_case			) <= set('''0123456789ABCDEF'''			):
								raise ValueError(
								    '''Base16 encoded data is invalid:
Data is not uppercase hex or it contains invalid characters.'''			)
				# For every two hexadecimal digits (= a byte), turn it into an integer.
				# Then, string the result together into bytes, and return it.
				return bytes(int(data[i] + data[i + 1],	1_6			) for i in range(0,	len(snake_case			),	2			)			)


if __name__ == "__main__":
					import doctest

					doctest.testmod()






