






"""simple docstring"""


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




def 				a (     UpperCamelCase_							:				Optional[Any]		)  ->		Any:

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

 def white_space_fix(UpperCamelCase_							:				Any		):
  return " ".join(text.split()		)

 def remove_punc(UpperCamelCase_							:				List[str]		):
  __A	:       List[Any]       =	set(string.punctuation		)
  return "".join(ch for ch in text if ch not in exclude		)

 def lower(UpperCamelCase_							:				Dict		):
  return text.lower()

 return white_space_fix(remove_articles(remove_punc(lower(UpperCamelCase_		)		)		)		)




def 				a (     UpperCamelCase_							:				Optional[int]     ,	UpperCamelCase_							:				Any		)  ->		str:
 __A	:       List[Any]       =	normalize_answer(UpperCamelCase_		).split()
 __A	:       Dict       =	normalize_answer(UpperCamelCase_		).split()
 __A	:       Union[str, Any]       =	Counter(UpperCamelCase_		) & Counter(UpperCamelCase_		)
 __A	:       int       =	sum(common.values()		)
 if num_same == 0:
  return 0
 __A	:       Union[str, Any]       =	1.0 * num_same / len(UpperCamelCase_		)
 __A	:       Any       =	1.0 * num_same / len(UpperCamelCase_		)
 __A	:       Optional[Any]       =	(2 * precision * recall) / (precision + recall)
 return fa




def 				a (     UpperCamelCase_							:				Optional[Any]     ,	UpperCamelCase_							:				Optional[Any]		)  ->		Tuple:
 return normalize_answer(UpperCamelCase_		) == normalize_answer(UpperCamelCase_		)




def 				a (     UpperCamelCase_							:				Optional[Any]     ,	UpperCamelCase_							:				Dict     ,	UpperCamelCase_							:				List[str]		)  ->		Optional[Any]:
 __A	:       Dict       =	[]
 for ground_truth in ground_truths:
  __A	:       Optional[int]       =	metric_fn(UpperCamelCase_     ,	UpperCamelCase_		)
  scores_for_ground_truths.append(UpperCamelCase_		)
 return max(UpperCamelCase_		)




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

 __A	:       Optional[Any]       =	100.0 * exact_match / total
 __A	:       Any       =	100.0 * fa / total

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


if __name__ == "__main__":
   _UpperCamelCase   :						List[Any]     						= """1.1"""
   _UpperCamelCase   :						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""")
   _UpperCamelCase   :						Optional[int]     						= parser.parse_args()
   with open(args.dataset_file) as dataset_file:
      _UpperCamelCase   :						Optional[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,
         )
      _UpperCamelCase   :						Dict     						= dataset_json["""data"""]
   with open(args.prediction_file) as prediction_file:
      _UpperCamelCase   :						Union[str, Any]     						= json.load(prediction_file)
   print(json.dumps(evaluate(dataset, predictions)))













"""simple docstring"""


from string import ascii_uppercase




def 				a (     UpperCamelCase_							:				str     ,	UpperCamelCase_							:				str     ,	UpperCamelCase_							:				bool = False     ,	UpperCamelCase_							:				str = ascii_uppercase		)  ->		str:
 __A	:       List[str]       =	keyword.upper()
 __A	:       str       =	plaintext.upper()
 __A	:       int       =	set(UpperCamelCase_		)

 # create a list of unique characters in the keyword - their order matters
 # it determines how we will map plaintext characters to the ciphertext
 __A	:       int       =	[]
 for char in keyword:
  if char in alphabet_set and char not in unique_chars:
   unique_chars.append(UpperCamelCase_		)
    # the number of those unique characters will determine the number of rows
 __A	:       Any       =	len(UpperCamelCase_		)

 # create a shifted version of the alphabet
 __A	:       str       =	unique_chars + [
     char for char in alphabet if char not in unique_chars
 ]

 # create a modified alphabet by splitting the shifted alphabet into rows
 __A	:       int       =	[
     shifted_alphabet[k : k + num_unique_chars_in_keyword]
     for k in range(0     ,	2_6     ,	UpperCamelCase_		)
 ]

 # map the alphabet characters to the modified alphabet characters
 # going 'vertically' through the modified alphabet - consider columns first
 __A	:       Any       =	{}
 __A	:       Union[str, Any]       =	0
 for column in range(UpperCamelCase_		):
  for row in modified_alphabet:
   # if current row (the last one) is too short, break out of loop
   if len(UpperCamelCase_		) <= column:
    break

   # map current letter to letter in modified alphabet
   __A	:       str       =	row[column]
   letter_index += 1

 if verbose:
  print(UpperCamelCase_		)
 # create the encrypted text by mapping the plaintext to the modified alphabet
 return "".join(mapping[char] if char in mapping else char for char in plaintext		)


if __name__ == "__main__":
   # example use
   print(mixed_keyword("""college""", """UNIVERSITY"""))





