Skip to content

criteria: add build_quantity_criteria_parser for physical-quantity criteria - #5

Merged
m-messer merged 1 commit into
mainfrom
feat/quantity-criteria-grammar
Oct 16, 2026
Merged

m-messer merged 1 commit into
mainfrom
feat/quantity-criteria-grammar

Conversation

@m-messer

@m-messer m-messer commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Moves the physical-quantity criteria grammar out of compareExpressions into lambdafeedback.criteria. First of a stack: #6 and #7 build on it.

Changes

  • build_quantity_criteria_parser(reserved_expressions, token_list=, productions=) in the new quantity_grammar.py, with defaults QUANTITY_TOKENS / QUANTITY_PRODUCTIONS. It parses:
    • response matches answer, and =, <=, >=, <, > between quantities;
    • dimension(response) matches dimension(answer).
  • It was generate_criteria_parser in compareExpressions' physical-quantity context, and its parse trees are unchanged (operator labels keep their surrounding spaces, e.g. " matches ").
  • It takes the same arguments as build_criteria_parser, so either can fill the same slot. reserved_expressions isn't used yet: only response and answer scan as QUANTITY; other text is INPUT.
  • Exported from lambdafeedback.criteria; CHANGELOG entry under Added.

Downstream
Additive. compareExpressions can switch its physical-quantity context to this parser.

Verification

  • ruff, format and mypy are clean, and all four test suites pass.
  • New tests cover each relation, matching dimensions, and free text read as INPUT.

🤖 Generated with Claude Code

…ria, update tests, and document usage in changelog and module init.
@m-messer
m-messer merged commit bcf45e7 into main Oct 16, 2026
8 checks passed
@m-messer
m-messer deleted the feat/quantity-criteria-grammar branch October 16, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant