fix(learning): keep a numeric mismatch open when an accepted answer may match

exact_verdict settled a final "incorrect" from the first key alone, so
"416,67" against "417,00" with an accepted "≈ 417" was incorrect at
confidence 1 although the accepted answer leaves it ambiguous. A final
incorrect now requires that no key is ambiguous.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
This commit is contained in:
Benjamin Schwing
2026-11-25 00:31:08 +00:00
parent a223dd9dd7
commit 943dd37c8c
2 changed files with 6 additions and 1 deletions

View File

@@ -118,7 +118,8 @@ def exact_verdict(question, answer):
# ambiguous reading may still be right, and multi-part answers may earn
# partial credit, so all of those stay semantic.
first = numeric[0]
if question.question_type == "short" and len(first.parts) == 1 and not first.ambiguous:
settled = len(first.parts) == 1 and not any(n.ambiguous for n in numeric)
if question.question_type == "short" and settled:
return Verdict(
result="incorrect",
confidence=1,

View File

@@ -391,6 +391,10 @@ class TestExactVerdictNumeric:
assert self._verdict(answer, expected) is None
assert self._verdict("1.251.000", "1.250").result == "incorrect"
def test_ambiguous_accepted_answer_keeps_the_mismatch_open(self):
assert self._verdict("416,67", "417,00", accepted=["≈ 417"]) is None
assert self._verdict("415,20", "417,00", accepted=["≈ 417"]).result == "incorrect"
def test_multi_part_mismatch_keeps_partial_credit_open(self):
assert self._verdict("a) 1.000; b) 260", "a) 1.000; b) 250") is None
assert self._verdict("1250", "Goodwill = 1.250; NCI = 300") is None