def f1_score(prediction, ground_truth):
prediction_tokens = normalize_answer(prediction).split()<EOL>ground_truth_tokens = normalize_answer(ground_truth).split()<EOL>common = Counter(prediction_tokens) & Counter(ground_truth_tokens)<EOL>num_same = sum(common.values())<EOL>if num_same == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0><EOL><DEDENT>precision = <NUM_LIT:1.0> * num_same / len(prediction_tokens)<EOL>recall = <NUM_LIT:1.0> * num_same / len(ground_truth_tokens)<EOL>f1 = (<NUM_LIT:2> * precision * recall) / (precision + recall)<EOL>return f1<EOL>
Calculate the F1 scores.