Skip to content

Support final (sofit) Hebrew letters in gematriyaStrToNum - #24

Merged
mjradwin merged 1 commit into
mainfrom
claude/hebrew-gematriya-final-letters-639kkc
Aug 23, 2026
Merged

Support final (sofit) Hebrew letters in gematriyaStrToNum#24
mjradwin merged 1 commit into
mainfrom
claude/hebrew-gematriya-final-letters-639kkc

Conversation

@mjradwin

Copy link
Copy Markdown
Member

Problem

gematriyaStrToNum silently ignored the five final (sofit) letters ך ם ן ף ץ, which dropped the tens digit of any Hebrew year ending in 20, 40, 50, 80, or 90:

gematriyaStrToNum('תש״ף'); // 700 — expected 780

Since a Hebrew year's last letter falls in final form, every such year collapsed onto its bare century. This surfaced through HDate.fromGematriyaString('א׳ שבט תש״ף'), which returned year 5700 instead of 5780 — an 80-year error with nothing to signal it. The round trip never caught it because gematriya() only ever emits the regular forms, but תש״ף is how 5780 is actually written in human-authored input.

Fixes #22.

Change

  • Map the five sofit letters to their base values (20/40/50/80/90) when parsing — the convention Hebrew dates use, with no ambiguity against existing keys.
  • Kept them in a separate sofit2num table rather than adding them to heb2num, because heb2num seeds the num2heb reverse map used by gematriya(); adding sofit keys there would clobber entries like num2heb[20] and corrupt emission. Parsing falls back with heb2num[ch] ?? sofit2num[ch], so number→string output is unaffected.
  • HDate.fromGematriyaString inherits the fix, since it delegates to gematriyaStrToNum.

Tests

  • gematriya.spec.ts: the six cases from the issue, plus a final/regular equivalence check (תש״ף === תש״פ).
  • hdate.spec.ts: end-to-end HDate.fromGematriyaString('א׳ שבט תש״ף')1 Sh'vat 5780.
  • Updated the JSDoc; the docExamples test auto-verifies the new @example.

Full suite passes, tsc and lint clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PdsgtSpAmYU8ChpqUo8fTH


Generated by Claude Code

gematriyaStrToNum silently ignored the five final letters (ך ם ן ף ץ),
which dropped the tens digit of any Hebrew year ending in 20, 40, 50, 80,
or 90 — e.g. תש״ף parsed as 700 instead of 780, an 80-year error with
nothing to signal it. This surfaced through HDate.fromGematriyaString,
since תש״ף is how 5780 is actually written in human input even though
gematriya() only ever emits the regular forms.

Map the sofit letters to their base values when parsing. They are kept in
a separate sofit2num table rather than added to heb2num so the num2heb
reverse map (and thus gematriya() output) is unaffected.

Fixes #22

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PdsgtSpAmYU8ChpqUo8fTH
@mjradwin
mjradwin merged commit 4215caf into main Aug 23, 2026
4 checks passed
@mjradwin
mjradwin deleted the claude/hebrew-gematriya-final-letters-639kkc branch August 23, 2026 19:36
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.

gematriyaStrToNum: ignoring final (sofit) letters silently drops the tens digit of a year (תש״ף reads as 5700)

2 participants