diff --git a/generate/math_candidate_parser.py b/generate/math_candidate_parser.py index c4b2be69..f9022726 100644 --- a/generate/math_candidate_parser.py +++ b/generate/math_candidate_parser.py @@ -3088,7 +3088,13 @@ def _resolve_question_entity( def _infer_peer_pick_partition( problem_text: str | None, question_entity: str ) -> tuple[int, str, str] | None: - """Infer peer friend-count from the conditional clause in ``problem_text``.""" + """Infer peer friend-count from the conditional clause in ``problem_text``. + + Gate A2d's peer count is a count of people, not a general numeric value. + The regex shares ``_VALUE`` for local parser consistency, but admission is + narrower: only positive integer, unitless counts are allowed. Money, + slash-fraction, decimal, and other non-integer numeric surfaces refuse. + """ if problem_text is None: return None m = _PEER_PICK_CONDITIONAL_RE.search(problem_text) @@ -3098,12 +3104,15 @@ def _infer_peer_pick_partition( if entity != _normalize_entity(question_entity): return None count_token = m.group("count") + if count_token.startswith(("$", "¢", "€", "£", "¥", "₱")) or "/" in count_token: + return None resolved = _resolve_value(count_token) if resolved is None: return None - peer_count = int(resolved.value) - if peer_count <= 0: + value = resolved.value + if value <= 0 or value != int(value): return None + peer_count = int(value) return peer_count, count_token, entity diff --git a/tests/test_math_candidate_graph_peer_partition_question.py b/tests/test_math_candidate_graph_peer_partition_question.py index 3013eba4..e971f193 100644 --- a/tests/test_math_candidate_graph_peer_partition_question.py +++ b/tests/test_math_candidate_graph_peer_partition_question.py @@ -104,6 +104,26 @@ def test_confuser_friends_without_count_refuses(): assert res.answer is None +def test_confuser_fractional_friend_count_refuses(): + text = ( + "Lilibeth fills 6 baskets where each basket holds 50 strawberries. " + "If 3/2 of Lilibeth's friends pick the same amount as her, " + "how many strawberries do Lilibeth and her friends pick in all?" + ) + res = _run(text) + assert res.answer is None + + +def test_confuser_money_friend_count_refuses(): + text = ( + "Lilibeth fills 6 baskets where each basket holds 50 strawberries. " + "If $2 of Lilibeth's friends pick the same amount as her, " + "how many strawberries do Lilibeth and her friends pick in all?" + ) + res = _run(text) + assert res.answer is None + + def test_comparative_question_still_refuses(): text = ( "Francine has five full boxes of crayons and 5 loose crayons, "