






"""simple docstring"""





from __future__ import annotations

from enum import Enum, unique
from typing import TypeVar

# Create a generic variable that can be 'Enum', or any subclass.
UpperCamelCase					=     TypeVar("""T""", bound="""Enum""")







@unique
class 						_a  (		lowercase_       ):





   '''simple docstring'''






   UpperCamelCase__     	=							80
   UpperCamelCase__     	=							70
   UpperCamelCase__     	=							60
   UpperCamelCase__     	=							50
   UpperCamelCase__     	=							40
   UpperCamelCase__     	=							30
   UpperCamelCase__     	=							20
   UpperCamelCase__     	=							10







@unique
class 						_a  (		lowercase_       ):





   '''simple docstring'''






   UpperCamelCase__     	=							24
   UpperCamelCase__     	=							21
   UpperCamelCase__     	=							18
   UpperCamelCase__     	=							15
   UpperCamelCase__     	=							12
   UpperCamelCase__     	=							9
   UpperCamelCase__     	=							6
   UpperCamelCase__     	=							3
   UpperCamelCase__     	=							2
   UpperCamelCase__     	=							1
   UpperCamelCase__     	=							-1
   UpperCamelCase__     	=							-2
   UpperCamelCase__     	=							-3
   UpperCamelCase__     	=							-6
   UpperCamelCase__     	=							-9
   UpperCamelCase__     	=							-12
   UpperCamelCase__     	=							-15
   UpperCamelCase__     	=							-18
   UpperCamelCase__     	=							-21
   UpperCamelCase__     	=							-24





   @classmethod
   def __lowercase							(       cls)			->   dict:




          '''simple docstring'''




          return {unit.name: unit.value for unit in cls if unit.value > 0}





   @classmethod
   def __lowercase							(       cls)			->   dict:




          '''simple docstring'''




          return {unit.name: unit.value for unit in cls if unit.value < 0}







def 							A(    snake_case_						):
       """simple docstring"""





       lowercase__:							Union[str, Any]         =     SIUnit.get_positive() if value > 0 else SIUnit.get_negative()
       for name_prefix, value_prefix in prefixes.items():
              lowercase__:							str         =     value / (10**value_prefix)
              if numerical_part > 1:
                     return F"""{numerical_part!s} {name_prefix}"""
       return str(snake_case_						)






def 							A(    snake_case_						):
       """simple docstring"""





       for prefix in BinaryUnit:
              lowercase__:							Tuple         =     value / (2**prefix.value)
              if numerical_part > 1:
                     return F"""{numerical_part!s} {prefix.name}"""
       return str(snake_case_						)


if __name__ == "__main__":
  import doctest

  doctest.testmod()














"""simple docstring"""





import argparse
import json
import re
import string
import sys
from collections import Counter






def 							A(    snake_case_						):
       """simple docstring"""





       def remove_articles(snake_case_						):
              return re.sub(r"\b(a|an|the)\b"		,  " "		,  snake_case_						)

       def white_space_fix(snake_case_						):
              return " ".join(text.split()						)

       def remove_punc(snake_case_						):
              lowercase__:							str         =     set(string.punctuation						)
              return "".join(ch for ch in text if ch not in exclude						)

       def lower(snake_case_						):
              return text.lower()

       return white_space_fix(remove_articles(remove_punc(lower(snake_case_						)						)						)						)






def 							A(    snake_case_		,  snake_case_						):
       """simple docstring"""





       lowercase__:							Dict         =     normalize_answer(snake_case_						).split()
       lowercase__:							List[str]         =     normalize_answer(snake_case_						).split()
       lowercase__:							Optional[int]         =     Counter(snake_case_						) & Counter(snake_case_						)
       lowercase__:							Any         =     sum(common.values()						)
       if num_same == 0:
              return 0
       lowercase__:							Any         =     1.0 * num_same / len(snake_case_						)
       lowercase__:							List[Any]         =     1.0 * num_same / len(snake_case_						)
       lowercase__:							int         =     (2 * precision * recall) / (precision + recall)
       return fa






def 							A(    snake_case_		,  snake_case_						):
       """simple docstring"""





       return normalize_answer(snake_case_						) == normalize_answer(snake_case_						)






def 							A(    snake_case_		,  snake_case_		,  snake_case_						):
       """simple docstring"""





       lowercase__:							int         =     []
       for ground_truth in ground_truths:
              lowercase__:							str         =     metric_fn(snake_case_		,  snake_case_						)
              scores_for_ground_truths.append(snake_case_						)
       return max(snake_case_						)






def 							A(    snake_case_		,  snake_case_						):
       """simple docstring"""





       lowercase__:							Optional[int]         =     0
       for article in dataset:
              for paragraph in article["paragraphs"]:
                     for qa in paragraph["qas"]:
                            total += 1
                            if qa["id"] not in predictions:
                                   lowercase__:							Union[str, Any]         =     "Unanswered question " + qa["id"] + " will receive score 0."
                                   print(snake_case_		,  file=sys.stderr						)
                                   continue
                            lowercase__:							List[Any]         =     [x["text"] for x in qa["answers"]]
                            lowercase__:							Optional[Any]         =     predictions[qa["id"]]
                            exact_match += metric_max_over_ground_truths(snake_case_		,  snake_case_		,  snake_case_						)
                            fa += metric_max_over_ground_truths(snake_case_		,  snake_case_		,  snake_case_						)

       lowercase__:							Union[str, Any]         =     1_00.0 * exact_match / total
       lowercase__:							str         =     1_00.0 * fa / total

       return {"exact_match": exact_match, "f1": fa}


if __name__ == "__main__":
  UpperCamelCase					=     """1.1"""
  UpperCamelCase					=     argparse.ArgumentParser(description="""Evaluation for SQuAD """ + expected_version)
  parser.add_argument("""dataset_file""", help="""Dataset file""")
  parser.add_argument("""prediction_file""", help="""Prediction File""")
  UpperCamelCase					=     parser.parse_args()
  with open(args.dataset_file) as dataset_file:
    UpperCamelCase					=     json.load(dataset_file)
    if dataset_json["version"] != expected_version:
      print(
          """Evaluation expects v-""" + expected_version + """, but got dataset with v-""" + dataset_json["""version"""],
          file=sys.stderr,
      )
    UpperCamelCase					=     dataset_json["""data"""]
  with open(args.prediction_file) as prediction_file:
    UpperCamelCase					=     json.load(prediction_file)
  print(json.dumps(evaluate(dataset, predictions)))






