




'''simple docstring'''







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






def 		_lowercase		(     lowercase_  ):



		'''simple docstring'''







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

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

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

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

		return white_space_fix(remove_articles(remove_punc(lower(lowercase_  )  )  )  )






def 		_lowercase		(     lowercase_						,							lowercase_  ):



		'''simple docstring'''







		_snake_case     	=	normalize_answer(lowercase_  ).split()
		_snake_case     	=	normalize_answer(lowercase_  ).split()
		_snake_case     	=	Counter(lowercase_  ) & Counter(lowercase_  )
		_snake_case     	=	sum(common.values()  )
		if num_same == 0:
				return 0
		_snake_case     	=	1.0 * num_same / len(lowercase_  )
		_snake_case     	=	1.0 * num_same / len(lowercase_  )
		_snake_case     	=	(2 * precision * recall) / (precision + recall)
		return fa






def 		_lowercase		(     lowercase_						,							lowercase_  ):



		'''simple docstring'''







		return normalize_answer(lowercase_  ) == normalize_answer(lowercase_  )






def 		_lowercase		(     lowercase_						,							lowercase_						,							lowercase_  ):



		'''simple docstring'''







		_snake_case     	=	[]
		for ground_truth in ground_truths:
				_snake_case     	=	metric_fn(lowercase_						,							lowercase_  )
				scores_for_ground_truths.append(lowercase_  )
		return max(lowercase_  )






def 		_lowercase		(     lowercase_						,							lowercase_  ):



		'''simple docstring'''







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

		_snake_case     	=	100.0 * exact_match / total
		_snake_case     	=	100.0 * fa / total

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


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











'''simple docstring'''







import math





class 					lowerCamelCase_							:




					'''simple docstring'''






					def __init__(   self,  __UpperCamelCase,  __UpperCamelCase,  __UpperCamelCase			):
							_snake_case     	=	x
							_snake_case     	=	y
							_snake_case     	=	z






					def __repr__(   self			):
							return f'''Point({self.x}, {self.y}, {self.z})'''






def 		_lowercase		(     lowercase_						,							lowercase_  ):



		'''simple docstring'''







		return math.sqrt(abs((b.x - a.x) ** 2 + (b.y - a.y) ** 2 + (b.z - a.z) ** 2  )  )


if __name__ == "__main__":
						import doctest

						doctest.testmod()





