




'''simple docstring'''





def UpperCAmelCase    (       UpperCAmelCase_   ,	UpperCAmelCase_   ,	UpperCAmelCase_						):
    if hue < 0 or hue > 360:
        raise Exception("""hue should be between 0 and 360"""						)

    if saturation < 0 or saturation > 1:
        raise Exception("""saturation should be between 0 and 1"""						)

    if value < 0 or value > 1:
        raise Exception("""value should be between 0 and 1"""						)

    _a				:							int							       =      value * saturation
    _a				:							Any							       =      hue / 60
    _a				:							str							       =      chroma * (1 - abs(hue_section % 2 - 1						))
    _a				:							Union[str, Any]							       =      value - chroma

    if hue_section >= 0 and hue_section <= 1:
        _a				:							Any							       =      round(255 * (chroma + match_value)						)
        _a				:							Optional[Any]							       =      round(255 * (second_largest_component + match_value)						)
        _a				:							int							       =      round(255 * (match_value)						)
    elif hue_section > 1 and hue_section <= 2:
        _a				:							List[Any]							       =      round(255 * (second_largest_component + match_value)						)
        _a				:							Tuple							       =      round(255 * (chroma + match_value)						)
        _a				:							Optional[int]							       =      round(255 * (match_value)						)
    elif hue_section > 2 and hue_section <= 3:
        _a				:							int							       =      round(255 * (match_value)						)
        _a				:							Any							       =      round(255 * (chroma + match_value)						)
        _a				:							str							       =      round(255 * (second_largest_component + match_value)						)
    elif hue_section > 3 and hue_section <= 4:
        _a				:							Union[str, Any]							       =      round(255 * (match_value)						)
        _a				:							Dict							       =      round(255 * (second_largest_component + match_value)						)
        _a				:							Union[str, Any]							       =      round(255 * (chroma + match_value)						)
    elif hue_section > 4 and hue_section <= 5:
        _a				:							int							       =      round(255 * (second_largest_component + match_value)						)
        _a				:							Dict							       =      round(255 * (match_value)						)
        _a				:							Dict							       =      round(255 * (chroma + match_value)						)
    else:
        _a				:							Dict							       =      round(255 * (chroma + match_value)						)
        _a				:							Tuple							       =      round(255 * (match_value)						)
        _a				:							int							       =      round(255 * (second_largest_component + match_value)						)

    return [red, green, blue]





def UpperCAmelCase    (       UpperCAmelCase_   ,	UpperCAmelCase_   ,	UpperCAmelCase_						):
    if red < 0 or red > 255:
        raise Exception("""red should be between 0 and 255"""						)

    if green < 0 or green > 255:
        raise Exception("""green should be between 0 and 255"""						)

    if blue < 0 or blue > 255:
        raise Exception("""blue should be between 0 and 255"""						)

    _a				:							Dict							       =      red / 255
    _a				:							Optional[Any]							       =      green / 255
    _a				:							Tuple							       =      blue / 255
    _a				:							Union[str, Any]							       =      max(UpperCAmelCase_   ,	UpperCAmelCase_   ,	UpperCAmelCase_						)
    _a				:							Tuple							       =      value - min(UpperCAmelCase_   ,	UpperCAmelCase_   ,	UpperCAmelCase_						)
    _a				:							Optional[int]							       =      0 if value == 0 else chroma / value

    if chroma == 0:
        _a				:							str							       =      0.0
    elif value == float_red:
        _a				:							str							       =      60 * (0 + (float_green - float_blue) / chroma)
    elif value == float_green:
        _a				:							str							       =      60 * (2 + (float_blue - float_red) / chroma)
    else:
        _a				:							Tuple							       =      60 * (4 + (float_red - float_green) / chroma)

    _a				:							List[str]							       =      (hue + 360) % 360

    return [hue, saturation, value]





def UpperCAmelCase    (       UpperCAmelCase_   ,	UpperCAmelCase_						):
    _a				:							Optional[int]							       =      abs(hsv_a[0] - hsv_a[0]						) < 0.2
    _a				:							List[str]							       =      abs(hsv_a[1] - hsv_a[1]						) < 0.002
    _a				:							int							       =      abs(hsv_a[2] - hsv_a[2]						) < 0.002

    return check_hue and check_saturation and check_value







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


def 						_UpperCAmelCase							( 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     ):
										_lowerCAmelCase         =       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 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

					return normalize_answer(snake_case     ) == normalize_answer(snake_case     )


def 						_UpperCAmelCase							( snake_case      ,		snake_case      ,		snake_case     ):





					"""simple docstring"""

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


def 						_UpperCAmelCase							( snake_case      ,		snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase         =       _lowerCAmelCase         =       _lowerCAmelCase         =       0
					for article in dataset:
										for paragraph in article["paragraphs"]:
															for qa in paragraph["qas"]:
																				total += 1
																				if qa["id"] not in predictions:
																									_lowerCAmelCase         =       """Unanswered question """ + qa["""id"""] + """ will receive score 0."""
																									print(snake_case      ,		file=sys.stderr     )
																									continue
																				_lowerCAmelCase         =       [x["""text"""] for x in qa["""answers"""]]
																				_lowerCAmelCase         =       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     )

					_lowerCAmelCase         =       100.0 * exact_match / total
					_lowerCAmelCase         =       100.0 * fa / total

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


if __name__ == "__main__":
	A__       =			"""1.1"""
	A__       =			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__       =			parser.parse_args()
	with open(args.dataset_file) as dataset_file:
		A__       =			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__       =			dataset_json["""data"""]
	with open(args.prediction_file) as prediction_file:
		A__       =			json.load(prediction_file)
	print(json.dumps(evaluate(dataset, predictions)))



