





'''simple docstring'''





import math_equivalence  # From: git+https://github.com/hendrycks/math.git

import datasets


_UpperCAmelCase        =				'\\n@article{hendrycksmath2021,\n  title={Measuring Mathematical Problem Solving With the MATH Dataset},\n  author={Dan Hendrycks\n    and Collin Burns\n    and Saurav Kadavath\n    and Akul Arora\n    and Steven Basart\n    and Eric Tang\n    and Dawn Song\n    and Jacob Steinhardt},\n  journal={arXiv preprint arXiv:2103.03874},\n  year={2021}\n}\n'


_UpperCAmelCase        =				'\\nThis metric is used to assess performance on the Mathematics Aptitude Test of Heuristics (MATH) dataset.\nIt first canonicalizes the inputs (e.g., converting "1/2" to "\\frac{1}{2}") and then computes accuracy.\n'


_UpperCAmelCase        =				r'\nCalculates accuracy after canonicalizing inputs.\n\nArgs:\n    predictions: list of predictions to score. Each prediction\n        is a string that contains natural language and LaTex.\n    references: list of reference for each prediction. Each\n        reference is a string that contains natural language\n        and LaTex.\nReturns:\n    accuracy: accuracy after canonicalizing inputs\n        (e.g., converting "1/2" to "\\frac{1}{2}")\n\nExamples:\n    >>> metric = datasets.load_metric("competition_math")\n    >>> results = metric.compute(references=["\\frac{1}{2}"], predictions=["1/2"])\n    >>> print(results)\n    {\'accuracy\': 1.0}\n'



@datasets.utils.file_utils.add_end_docstrings(_DESCRIPTION  ,						_KWARGS_DESCRIPTION     )
class 							_UpperCamelCase					(	datasets.Metric     ):

       def lowercase (		self: Union[str, Any]		)       -> List[Any]:




              """simple docstring"""


              return datasets.MetricInfo(
                  description=_DESCRIPTION					,   citation=_CITATION					,   inputs_description=_KWARGS_DESCRIPTION					,   features=datasets.Features(
                      {
                          "predictions": datasets.Value("string"		),
                          "references": datasets.Value("string"		),
                      }		)					,   homepage="https://github.com/hendrycks/math"					,   codebase_urls=["https://github.com/hendrycks/math"]					,   )



       def lowercase (		self: Optional[int]					,   _SCREAMING_SNAKE_CASE: Any					,   _SCREAMING_SNAKE_CASE: Dict		)       -> List[Any]:




              """simple docstring"""


              UpperCamelCase_          =  0.0
              for i, j in zip(__UpperCamelCase					,   __UpperCamelCase		):
                     n_correct += 1.0 if math_equivalence.is_equiv(__UpperCamelCase					,   __UpperCamelCase		) else 0.0
              UpperCamelCase_          =  n_correct / len(__UpperCamelCase		)
              return {
                  "accuracy": accuracy,
              }








_UpperCAmelCase        =				{
    'a': 'AAAAA',
    'b': 'AAAAB',
    'c': 'AAABA',
    'd': 'AAABB',
    'e': 'AABAA',
    'f': 'AABAB',
    'g': 'AABBA',
    'h': 'AABBB',
    'i': 'ABAAA',
    'j': 'BBBAA',
    'k': 'ABAAB',
    'l': 'ABABA',
    'm': 'ABABB',
    'n': 'ABBAA',
    'o': 'ABBAB',
    'p': 'ABBBA',
    'q': 'ABBBB',
    'r': 'BAAAA',
    's': 'BAAAB',
    't': 'BAABA',
    'u': 'BAABB',
    'v': 'BBBAB',
    'w': 'BABAA',
    'x': 'BABAB',
    'y': 'BABBA',
    'z': 'BABBB',
    ' ': ' ',
}


_UpperCAmelCase        =				{value: key for key, value in encode_dict.items()}




def  lowerCAmelCase_ (							UpperCamelCase_  )     ->		str:
       UpperCamelCase_          =  ""
       for letter in word.lower():
              if letter.isalpha() or letter == " ":
                     encoded += encode_dict[letter]
              else:
                     raise Exception("encode() accepts only letters of the alphabet and spaces"  )
       return encoded




def  lowerCAmelCase_ (							UpperCamelCase_  )     ->		str:
       if set(UpperCamelCase_  ) - {"A", "B", " "} != set():
              raise Exception("decode() accepts only 'A', 'B' and spaces"  )
       UpperCamelCase_          =  ""
       for word in coded.split():
              while len(UpperCamelCase_  ) != 0:
                     decoded += decode_dict[word[:5]]
                     UpperCamelCase_          =  word[5:]
              decoded += " "
       return decoded.strip()


if __name__ == "__main__":
     from doctest import testmod

     testmod()

