


'''simple docstring'''





import re
import string

import numpy as np

import datasets


UpperCAmelCase__  			=				'''
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.
'''

UpperCAmelCase__  			=				'''
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

'''

UpperCAmelCase__  			=				'''
'''
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION      ,  _KWARGS_DESCRIPTION   )
class 						a__					(					datasets.Metric   ):





			'''simple docstring'''

			def 					lowerCAmelCase     (  self							:			List[Any]	)      ->		Union[str, Any]:
						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 					lowerCAmelCase     (  self							:			Dict			,    lowerCAmelCase_							:			Dict			,    lowerCAmelCase_							:			str			,    lowerCAmelCase_							:			str=None			,    lowerCAmelCase_							:			Union[str, Any]=False			,    lowerCAmelCase_							:			Optional[Any]=False			,    lowerCAmelCase_							:			Union[str, Any]=False			,    )      ->		Any:
						if regexes_to_ignore is not None:
									for s in regexes_to_ignore:
												__A=	np.array([re.sub(lowerCAmelCase_			,    ''			,    lowerCAmelCase_	) for x in predictions]	)
												__A=	np.array([re.sub(lowerCAmelCase_			,    ''			,    lowerCAmelCase_	) for x in references]	)
						else:
									__A=	np.asarray(lowerCAmelCase_	)
									__A=	np.asarray(lowerCAmelCase_	)

						if ignore_case:
									__A=	np.char.lower(lowerCAmelCase_	)
									__A=	np.char.lower(lowerCAmelCase_	)

						if ignore_punctuation:
									__A=	string.punctuation.maketrans(''			,    ''			,    string.punctuation	)
									__A=	np.char.translate(lowerCAmelCase_			,    table=lowerCAmelCase_	)
									__A=	np.char.translate(lowerCAmelCase_			,    table=lowerCAmelCase_	)

						if ignore_numbers:
									__A=	string.digits.maketrans(''			,    ''			,    string.digits	)
									__A=	np.char.translate(lowerCAmelCase_			,    table=lowerCAmelCase_	)
									__A=	np.char.translate(lowerCAmelCase_			,    table=lowerCAmelCase_	)

						__A=	predictions == references

						return {"exact_match": np.mean(lowerCAmelCase_	) * 100}







'''simple docstring'''





# this script reports modified .py files under the desired list of top-level sub-dirs passed as a list of arguments, e.g.:
#   python ./utils/get_modified_files.py utils src tests examples
#
# it uses git to find the forking point and which files were modified - i.e. files not under git won't be considered
# since the output of this script is fed into Makefile commands it doesn't print a newline after the results

import re
import subprocess
import sys


UpperCAmelCase__  			=				subprocess.check_output('''git merge-base main HEAD'''.split()).decode('''utf-8''')
UpperCAmelCase__  			=				subprocess.check_output(F"""git diff --name-only {fork_point_sha}""".split()).decode('''utf-8''').split()

UpperCAmelCase__  			=				'''|'''.join(sys.argv[1:])
UpperCAmelCase__  			=				re.compile(rF"""^({joined_dirs}).*?\.py$""")

UpperCAmelCase__  			=				[x for x in modified_files if regex.match(x)]
print(''' '''.join(relevant_modified_files), end='''''')



