






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

def 			__lowerCamelCase     (						snake_case__						)				->    List[Any]:






						"""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__						):
												_SCREAMING_SNAKE_CASE       =    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 			__lowerCamelCase     (						snake_case__			,snake_case__						)				->    Dict:






						"""simple docstring"""





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

def 			__lowerCamelCase     (						snake_case__			,snake_case__						)				->    str:






						"""simple docstring"""





						return normalize_answer(snake_case__						) == normalize_answer(snake_case__						)

def 			__lowerCamelCase     (						snake_case__			,snake_case__			,snake_case__						)				->    Tuple:






						"""simple docstring"""





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

def 			__lowerCamelCase     (						snake_case__			,snake_case__						)				->    Tuple:






						"""simple docstring"""





						_SCREAMING_SNAKE_CASE       =    _SCREAMING_SNAKE_CASE       =    _SCREAMING_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:
																														_SCREAMING_SNAKE_CASE       =    """Unanswered question """ + qa["""id"""] + """ will receive score 0."""
																														print(snake_case__			,file=sys.stderr						)
																														continue
																								_SCREAMING_SNAKE_CASE       =    [x["""text"""] for x in qa["""answers"""]]
																								_SCREAMING_SNAKE_CASE       =    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__						)

						_SCREAMING_SNAKE_CASE       =    100.0 * exact_match / total
						_SCREAMING_SNAKE_CASE       =    100.0 * fa / total

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


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






# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
# or u belongs to V and v to U. We can also say that there is no edge that connects
# vertices of same set.
from queue import Queue


def 						_UpperCAmelCase							( snake_case     ):





					"""simple docstring"""

					_lowerCAmelCase         =       Queue()
					_lowerCAmelCase         =       [False] * len(snake_case     )
					_lowerCAmelCase         =       [-1] * len(snake_case     )

					def bfs():
										while not queue.empty():
															_lowerCAmelCase         =       queue.get()
															_lowerCAmelCase         =       True

															for neighbour in graph[u]:
																				if neighbour == u:
																									return False

																				if color[neighbour] == -1:
																									_lowerCAmelCase         =       1 - color[u]
																									queue.put(snake_case     )

																				elif color[neighbour] == color[u]:
																									return False

										return True

					for i in range(len(snake_case     )     ):
										if not visited[i]:
															queue.put(snake_case     )
															_lowerCAmelCase         =       0
															if bfs() is False:
																				return False

					return True


if __name__ == "__main__":
	# Adjacency List of graph
	print(check_bipartite({0: [1, 3], 1: [0, 2], 2: [1, 3], 3: [0, 2]}))



