From dd790a5bd408b60bf291bd682eebb0491965f515 Mon Sep 17 00:00:00 2001 From: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com> Date: Tue, 24 Nov 2026 21:55:19 +0000 Subject: [PATCH] fix(learning): leave multi-part numeric mismatches to the judge A deterministic "incorrect" for "a) 1.000; b) 260" against "a) 1.000; b) 250", or for an answer that omits a part, removed the partial credit the semantic judge can award per subtask. Only a single short number now gets a final numeric "incorrect"; every other mismatch falls through to the existing judge. Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com> --- deeptutor/learning/semantic_assessment.py | 8 +++++--- deeptutor/learning/tests/test_grading.py | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/deeptutor/learning/semantic_assessment.py b/deeptutor/learning/semantic_assessment.py index 1abb1a984..f5611b1a1 100644 --- a/deeptutor/learning/semantic_assessment.py +++ b/deeptutor/learning/semantic_assessment.py @@ -114,9 +114,11 @@ def exact_verdict(question, answer): confidence=1, feedback=question.explanation or "Matches the stored answer.", ) - # Only a short answer is the bare number itself; open answers may explain - # one, and an ambiguous separator has two readings, so both stay semantic. - if question.question_type == "short" and numeric[0].comparable and not numeric[0].ambiguous: + # Only a single short number is final: open answers may explain one, an + # 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: return Verdict( result="incorrect", confidence=1, diff --git a/deeptutor/learning/tests/test_grading.py b/deeptutor/learning/tests/test_grading.py index 20eb09dd8..738cfb0be 100644 --- a/deeptutor/learning/tests/test_grading.py +++ b/deeptutor/learning/tests/test_grading.py @@ -333,3 +333,8 @@ class TestExactVerdictNumeric: assert self._verdict("125000", "125.000") is None assert self._verdict("about 1250", "1250.50") is None assert self._verdict("1300", "1250.50", accepted=["ca. 1300"]).result == "correct" + + 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 + assert self._verdict("a) 1.000; b) 250", "a) 1.000; b) 250").result == "correct"