def compute_metrics()

in accuracy.py [0:0]


def compute_metrics(category):
    total_match = sum(category["match"].values())
    total_missing = sum(category["missing"].values())
    total_extra = sum(category["extra"].values())

    total = total_match + total_missing + total_extra

    precision = total_match / (total_match + total_extra) if (total_match + total_extra) > 0 else 0
    recall = total_match / (total_match + total_missing) if (total_match + total_missing) > 0 else 0
    f1_score = 2 * (precision * recall) / (precision + recall) if (precision + recall) > 0 else 0
    accuracy = (total_match / total) if total > 0 else 0

    return {
        "precision": precision * 100,
        "recall": recall * 100,
        "f1_score": f1_score * 100,
        "accuracy": accuracy * 100,
    }