





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



def _a							(      lowerCamelCase:  str					)      ->		Dict:







      '''simple docstring'''






      def remove_articles(lowerCamelCase:  List[str]					):
            return re.sub(r'''\b(a|an|the)\b'''   ,							''' '''   ,							lowerCamelCase					)

      def white_space_fix(lowerCamelCase:  Tuple					):
            return " ".join(text.split()					)

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

      def lower(lowerCamelCase:  int					):
            return text.lower()

      return white_space_fix(remove_articles(remove_punc(lower(lowerCamelCase					)					)					)					)



def _a							(      lowerCamelCase:  Tuple   ,							lowerCamelCase:  List[Any]					)      ->		List[str]:







      '''simple docstring'''






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



def _a							(      lowerCamelCase:  List[Any]   ,							lowerCamelCase:  str					)      ->		Dict:







      '''simple docstring'''






      return normalize_answer(lowerCamelCase					) == normalize_answer(lowerCamelCase					)



def _a							(      lowerCamelCase:  Any   ,							lowerCamelCase:  int   ,							lowerCamelCase:  Tuple					)      ->		Tuple:







      '''simple docstring'''






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



def _a							(      lowerCamelCase:  Dict   ,							lowerCamelCase:  List[Any]					)      ->		Dict:







      '''simple docstring'''






      __A			  =							__A			  =							__A			  =							0
      __A			  =							[]
      for passage in dataset:
            for qa in passage["qas"]:
                  total += 1
                  if qa["id"] not in predictions:
                        __A			  =							F"""Unanswered question {qa['id']} will receive score 0."""
                        print(lowerCamelCase   ,							file=sys.stderr					)
                        continue

                  __A			  =							[x['''text'''] for x in qa['''answers''']]
                  __A			  =							predictions[qa['''id''']]

                  __A			  =							metric_max_over_ground_truths(lowerCamelCase   ,							lowerCamelCase   ,							lowerCamelCase					)
                  if int(_exact_match					) == 1:
                        correct_ids.append(qa['''id''']					)
                  exact_match += _exact_match

                  fa += metric_max_over_ground_truths(lowerCamelCase   ,							lowerCamelCase   ,							lowerCamelCase					)

      __A			  =							exact_match / total
      __A			  =							fa / total

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


if __name__ == "__main__":
       snake_case__   :				Tuple						=	'1.0'
       snake_case__   :				List[Any]						=	argparse.ArgumentParser('Official evaluation script for ReCoRD v1.0.')
       parser.add_argument('data_file', help='The dataset file in JSON format.')
       parser.add_argument('pred_file', help='The model prediction file in JSON format.')
       parser.add_argument('--output_correct_ids', action='store_true', help='Output the correctly answered query IDs.')
       snake_case__   :				List[Any]						=	parser.parse_args()

       with open(args.data_file) as data_file:
              snake_case__   :				Any						=	json.load(data_file)
              if dataset_json["version"] != expected_version:
                     print(
                         f'Evaluation expects v-{expected_version}, but got dataset with v-{dataset_json["version"]}',
                         file=sys.stderr,
                     )
              snake_case__   :				Optional[int]						=	dataset_json['data']

       with open(args.pred_file) as pred_file:
              snake_case__   :				int						=	json.load(pred_file)

       snake_case__		,       snake_case__   :				List[str]						=	evaluate(dataset, predictions)

       if args.output_correct_ids:
              print(f'Output {len(correct_ids)} correctly answered question IDs.')
              with open('correct_ids.json', 'w') as f:
                     json.dump(correct_ids, f)












def _a							(      lowerCamelCase:  List[Any]					)      ->		Optional[Any]:







      '''simple docstring'''






      __A			  =							[7_01, 3_01, 1_32, 57, 23, 10, 4, 1]
      for gap in gaps:
            for i in range(lowerCamelCase   ,							len(lowerCamelCase					)					):
                  __A			  =							collection[i]
                  __A			  =							i
                  while j >= gap and collection[j - gap] > insert_value:
                        __A			  =							collection[j - gap]
                        j -= gap
                  if j != i:
                        __A			  =							insert_value
      return collection


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

       testmod()
       snake_case__   :				Optional[int]						=	input('Enter numbers separated by a comma:\n').strip()
       snake_case__   :				int						=	[int(item) for item in user_input.split(',')]
       print(shell_sort(unsorted))





