


"""simple docstring"""







from __future__ import annotations

from collections import deque
from enum import Enum
from math import atana, degrees
from sys import maxsize






class  __A							(			_SCREAMING_SNAKE_CASE     ):






 """simple docstring"""




 __lowerCAmelCase					   =    1
 __lowerCAmelCase					   =    2
 __lowerCAmelCase					   =    3


 def __repr__(						self		)   ->	str:
     return f'''{self.__class__.__name__}.{self.name}'''

def _A		(		lowercase			,       lowercase			,       lowercase						):







    """simple docstring"""
    a						, a											=point
    return degrees(atana(y - miny			,       x - minx						)						)
def _A		(		lowercase			,       lowercase			,       lowercase						):







    """simple docstring"""
    a						, a											=starting
    a						, a											=via
    a						, a											=target
    a											=degrees(atana(ya - ya			,       xa - xa						)						)
    via_angle %= 3_60
    a											=degrees(atana(ya - ya			,       xa - xa						)						)
    target_angle %= 3_60
    # t-
    #  \ \
    #   \ v
    #    \|
    #     s
    # via_angle is always lower than target_angle, if direction is left.
    # If they are same, it means they are on a same line of convex hull.
    if target_angle > via_angle:
        return Direction.left
    elif target_angle == via_angle:
        return Direction.straight
    else:
        return Direction.right





def _A		(		lowercase						):







    """simple docstring"""

    if len(lowercase						) <= 2:
        # There is no convex hull
        raise ValueError('''graham_scan: argument must contain more than 3 points.'''						)
    if len(lowercase						) == 3:
        return points
    # find the lowest and the most left point
    a											=0
    a						, a											=maxsize, maxsize
    for i, point in enumerate(lowercase						):
        a											=point[0]
        a											=point[1]
        if y < miny:
            a											=y
            a											=x
            a											=i
        if y == miny and x < minx:
            a											=x
            a											=i

    # remove the lowest and the most left point from points for preparing for sort
    points.pop(lowercase						)

    a											=sorted(lowercase			,       key=lambda lowercase						: angle_comparer(lowercase			,       lowercase			,       lowercase						)						)
    # This insert actually costs complexity,
    # and you should instead add (minx, miny) into stack later.
    # I'm using insert just for easy understanding.
    sorted_points.insert(0			,       (minx, miny)						)

    a											=deque()
    stack.append(sorted_points[0]						)
    stack.append(sorted_points[1]						)
    stack.append(sorted_points[2]						)
    # In any ways, the first 3 points line are towards left.
    # Because we sort them the angle from minx, miny.
    a											=Direction.left

    for i in range(3			,       len(lowercase						)						):
        while True:
            a											=stack[-2]
            a											=stack[-1]
            a											=sorted_points[i]
            a											=check_direction(lowercase			,       lowercase			,       lowercase						)

            if next_direction == Direction.left:
                a											=Direction.left
                break
            if next_direction == Direction.straight:
                if current_direction == Direction.left:
                    # We keep current_direction as left.
                    # Because if the straight line keeps as straight,
                    # we want to know if this straight line is towards left.
                    break
                elif current_direction == Direction.right:
                    # If the straight line is towards right,
                    # every previous points on those straigh line is not convex hull.
                    stack.pop()
            if next_direction == Direction.right:
                stack.pop()
        stack.append(sorted_points[i]						)
    return list(lowercase						)



"""simple docstring"""







import argparse
import json
import re
import string
import sys
from collections import Counter
def _A		(		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						):
        a											=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 _A		(		lowercase			,       lowercase						):







    """simple docstring"""
    a											=normalize_answer(lowercase						).split()
    a											=normalize_answer(lowercase						).split()
    a											=Counter(lowercase						) & Counter(lowercase						)
    a											=sum(common.values()						)
    if num_same == 0:
        return 0
    a											=1.0 * num_same / len(lowercase						)
    a											=1.0 * num_same / len(lowercase						)
    a											=(2 * precision * recall) / (precision + recall)
    return fa
def _A		(		lowercase			,       lowercase						):







    """simple docstring"""
    return normalize_answer(lowercase						) == normalize_answer(lowercase						)
def _A		(		lowercase			,       lowercase			,       lowercase						):







    """simple docstring"""
    a											=[]
    for ground_truth in ground_truths:
        a											=metric_fn(lowercase			,       lowercase						)
        scores_for_ground_truths.append(lowercase						)
    return max(lowercase						)
def _A		(		lowercase			,       lowercase						):







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

    a											=100.0 * exact_match / total
    a											=100.0 * fa / total

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


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