From 943dd37c8c5ce6342fa0ec63e8d0199172b51daa Mon Sep 17 00:00:00 2001 From: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com> Date: Wed, 25 Nov 2026 00:31:08 +0000 Subject: [PATCH] fix(learning): keep a numeric mismatch open when an accepted answer may match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- deeptutor/learning/semantic_assessment.py | 3 ++- deeptutor/learning/tests/test_grading.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/deeptutor/learning/semantic_assessment.py b/deeptutor/learning/semantic_assessment.py index f5611b1a1..a9619e02e 100644 --- a/deeptutor/learning/semantic_assessment.py +++ b/deeptutor/learning/semantic_assessment.py @@ -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, diff --git a/deeptutor/learning/tests/test_grading.py b/deeptutor/learning/tests/test_grading.py index f86c4733e..cfa0213cc 100644 --- a/deeptutor/learning/tests/test_grading.py +++ b/deeptutor/learning/tests/test_grading.py @@ -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