in src/utils/str.py [0:0]
def f1_score(prediction, ground_truth, term='f1score'):
normalized_prediction = normalize_statement(prediction)
normalized_ground_truth = normalize_statement(ground_truth)
prediction = normalized_prediction.split()
ground_truth = normalized_ground_truth.split()
res_dict = {'f1score': 0, 'recall': 0, 'precision': 0, 'all': [0, 0, 0]}
common = Counter(prediction) & Counter(ground_truth)
num_same = sum(common.values())
if num_same != 0:
precision = 1.0 * num_same / len(prediction)
recall = 1.0 * num_same / len(ground_truth)
f1 = (2 * precision * recall) / (precision + recall)
res_dict['precision'], res_dict['recall'], res_dict['f1score'] = precision, recall, f1
res_dict['all'] = [precision, recall, f1]
return res_dict[term]