Skip to content

Expand Adar month name recognition with dedicated resolver - #25

Merged
mjradwin merged 1 commit into
mainfrom
claude/adar-parser-robustness-9p3lxs
Aug 25, 2026
Merged

Expand Adar month name recognition with dedicated resolver#25
mjradwin merged 1 commit into
mainfrom
claude/adar-parser-robustness-9p3lxs

Conversation

@mjradwin

Copy link
Copy Markdown
Member

Summary

Refactored and expanded the Adar month name resolution logic to support a comprehensive set of transliterated and Hebrew spellings for both Adar I and Adar II, with improved documentation and test coverage.

Key Changes

  • Extracted adarFromName() function: Created a dedicated helper function that encapsulates all logic for resolving "Adar I vs Adar II" ambiguity from month name suffixes, replacing inline regex matching
  • Expanded Adar I recognition: Now accepts 'Alef'/'Aleph'/'Alaph', 'Rishon' (and variants), and Hebrew equivalents 'אלף' and 'ראשון' (with prefix matching for flexibility)
  • Expanded Adar II recognition: Now accepts 'Bet'/'Beit'/'Beis', 'Sheni'/'Sheini', and Hebrew equivalents 'ב' and 'שני'
  • Improved suffix parsing: Normalizes separators (spaces, hyphens, periods) and gershayim (׳״) when extracting the ordinal suffix, allowing formats like 'Adar-I', 'AdarI', and 'אדר א׳' to be treated equivalently
  • Enhanced documentation: Added comprehensive JSDoc comments explaining the Adar resolution logic, accepted spellings, and the convention that bare 'Adar' defaults to Adar II
  • Extended test coverage: Added 13 new test cases covering various Adar I and Adar II spellings, including edge cases like 'Adar Bogus' to verify the ambiguous-default behavior

Implementation Details

  • The adarFromName() function normalizes the suffix by removing the 'adar'/'אדר' stem and stripping separators/gershayim, then checks against recognized patterns for Adar I
  • All unrecognized suffixes (including bare 'Adar') deliberately default to Adar II, following the Hebrew calendar convention that an unqualified Adar refers to the second Adar in a leap year
  • The refactoring maintains backward compatibility while making the code more maintainable and the behavior more explicit

https://claude.ai/code/session_01954cvSHc23Ats2gn7GwuYG

The Adar ordinal was decided from the last character of the string via
`/(1|[^i]i|a|א)$/`, which silently inverted several spelled-out forms:
`Adar Sheini` ended in `ni` and matched `[^i]i$`, resolving to Adar I,
while `אדר ראשון` / `Adar Rishon` / `Adar Alef` fell through to the Adar II
default — landing a yahrzeit or anniversary on the wrong, adjacent month.

Replace the trailing-character test with `adarFromName`, which inspects the
ordinal after the `adar`/`אדר` stem (ignoring separators and gershayim) and
matches the ordinal explicitly: `1`/`i`/`a`/`alef`/`aleph`/`rishon`/`א`/
`ראשון`/`אלף` resolve to Adar I; the explicit second-Adar spellings and any
unrecognized or missing suffix ("Adar", "Adar Bogus") deliberately default
to Adar II, matching the convention that an unqualified Adar means the
second Adar in a leap year.

Also expand the monthFromName docs to cover nikud stripping, the leading
bet prefix, and the Adar II default for ambiguous names, and add
table-driven test coverage across the spellings.

Fixes #23

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01954cvSHc23Ats2gn7GwuYG
@mjradwin
mjradwin merged commit 8c88f36 into main Aug 25, 2026
4 checks passed
@mjradwin
mjradwin deleted the claude/adar-parser-robustness-9p3lxs branch August 25, 2026 20:39
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.

2 participants