






"""simple docstring"""







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





def 						lowercase__(A						)				->Dict:




						"""simple docstring"""



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

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

						def remove_punc(A						):
												lowercase__				:      Union[str, Any]=       set(string.punctuation						)
												return "".join(ch for ch in text if ch not in exclude						)

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

						return white_space_fix(remove_articles(remove_punc(lower(A						)						)						)						)





def 						lowercase__(A					,		A						)				->Optional[Any]:




						"""simple docstring"""



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





def 						lowercase__(A					,		A						)				->Any:




						"""simple docstring"""



						return normalize_answer(A						) == normalize_answer(A						)





def 						lowercase__(A					,		A					,		A						)				->List[Any]:




						"""simple docstring"""



						lowercase__				:      Optional[int]=       []
						for ground_truth in ground_truths:
												lowercase__				:      Any=       metric_fn(A					,		A						)
												scores_for_ground_truths.append(A						)
						return max(A						)





def 						lowercase__(A					,		A						)				->Optional[int]:




						"""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__				:      Optional[int]=       "Unanswered question " + qa["id"] + " will receive score 0."
																														print(A					,		file=sys.stderr						)
																														continue
																								lowercase__				:      Union[str, Any]=       [x["text"] for x in qa["answers"]]
																								lowercase__				:      str=       predictions[qa["id"]]
																								exact_match += metric_max_over_ground_truths(A					,		A					,		A						)
																								fa += metric_max_over_ground_truths(A					,		A					,		A						)

						lowercase__				:      List[str]=       100.0 * exact_match / total
						lowercase__				:      str=       100.0 * fa / total

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


if __name__ == "__main__":
			a :				Any      					=		"""1.1"""
			a :				str      					=		argparse.ArgumentParser(description="""Evaluation for SQuAD """ + expected_version)
			parser.add_argument("""dataset_file""", help="""Dataset file""")
			parser.add_argument("""prediction_file""", help="""Prediction File""")
			a :				Optional[Any]      					=		parser.parse_args()
			with open(args.dataset_file) as dataset_file:
						a :				Any      					=		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,
									)
						a :				Union[str, Any]      					=		dataset_json["""data"""]
			with open(args.prediction_file) as prediction_file:
						a :				Union[str, Any]      					=		json.load(prediction_file)
			print(json.dumps(evaluate(dataset, predictions)))














"""simple docstring"""







import sys

def _a (		_snake_case      ,       _snake_case							):







      """simple docstring"""






      if not numbers:
            return 0
      if target == 0 and target in numbers:
            return 0
      if not isinstance(_snake_case      ,       (list, tuple)							) or not all(
          isinstance(_snake_case      ,       _snake_case							) for number in numbers							):
            raise ValueError("""numbers must be an iterable of integers"""							)

      UpperCAmelCase							=       UpperCAmelCase							=       UpperCAmelCase							=       0
      UpperCAmelCase							=       sys.maxsize

      while right < len(_snake_case							):
            curr_sum += numbers[right]
            while curr_sum >= target and left <= right:
                  UpperCAmelCase							=       min(_snake_case      ,       right - left + 1							)
                  curr_sum -= numbers[left]
                  left += 1
            right += 1

      return 0 if min_len == sys.maxsize else min_len



