Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = ["pytest>=8.0", "ruff>=0.5", "mypy>=1.10"]
dev = ["pytest>=8.0", "ruff>=0.5,<0.16", "mypy>=1.10"]

[build-system]
requires = ["hatchling"]
Expand Down
12 changes: 7 additions & 5 deletions src/trinity/adapters/drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def _maybe_unbox(segment: str) -> str:

#: Surrounding punctuation stripped from a token, EXCLUDING the signs ``+``/``-`` — a
#: leading sign is part of a number's value, not wrapping noise.
_STRIP_EDGE = "".join(c for c in string.punctuation if c not in "+-")
_STRIP_EDGE = "".join(c for c in string.punctuation if c not in "+-.")


def _normalize_token(raw: str) -> str:
Expand All @@ -157,10 +157,12 @@ def _normalize_token(raw: str) -> str:
except ValueError:
pass
core = raw.strip(_STRIP_EDGE)
try:
return str(float(core.replace(",", "")))
except ValueError:
return _PUNCT.sub("", raw)
for cand in (core, core.rstrip(".")):
try:
return str(float(cand.replace(",", "")))
except ValueError:
continue
return _PUNCT.sub("", raw)


def _split_internal_hyphens(token: str) -> list[str]:
Expand Down
2 changes: 2 additions & 0 deletions src/trinity/orchestration/reward.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ def normalize_math_answer(ans: str | None) -> str:
# (the product symbol) is intentionally left untouched.
s = re.sub(r"\\pi(?![a-zA-Z])", "pi", s)
s = s.replace("π", "pi")
s = s.replace("∞", "oo")
s = re.sub(r"\\infty(?![a-zA-Z])", "oo", s)
# The fraction normalizer wraps arbitrary operands, so ``\frac{\pi}{2}``
# becomes ``(pi)/(2)`` while ``\pi/2`` becomes ``pi/2``. Remove only
# standalone atomic operands adjacent to division — including a lone
Expand Down
Loading