Files
wehub-resource-sync c3749daf48
Tests / test-linux (3.13) (push) Failing after 0s
Tests / test-linux (3.11) (push) Failing after 1s
Tests / lint (push) Failing after 0s
Tests / test-linux (3.9) (push) Failing after 1s
Docker / build (push) Failing after 1s
Docker / build-gpu (push) Failing after 2s
Tests / test-windows (push) Has been cancelled
Tests / test-macos (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:03:03 +08:00

17 lines
683 B
Python

"""Calibration scoring: exact-match against single-class label."""
from __future__ import annotations
def score(predicted: str, label: str, classes: list[str]) -> dict:
"""Return {"correct": bool, "predicted_normalized": str}."""
p = predicted.strip().lower().strip(".,;:'\"")
target = label.strip().lower()
correct = p == target
if not correct:
for c in classes:
if p == c.strip().lower():
# Predicted a valid class, just not the target.
return {"correct": False, "predicted_normalized": p}
return {"correct": False, "predicted_normalized": p}
return {"correct": True, "predicted_normalized": p}