Skip to content

split a list of text ordinals - #1259

Merged
spencermountain merged 1 commit into
spencermountain:devfrom
b84330808:fix-ordinal-list-split
Nov 2, 2026
Merged

spencermountain merged 1 commit into
spencermountain:devfrom
b84330808:fix-ordinal-list-split

Conversation

@b84330808

Copy link
Copy Markdown
Contributor

numbers() only split 'seventh fifth' when no match in the whole view had a tens word before an ordinal, so one 'twenty seventh' anywhere kept the others together:

nlp('the fifth, sixth and twenty-seventh').numbers().get()  // [0, 27]
nlp('first, second and twenty third').numbers().get()       // [0, 23]

An ordinal always ends its number, so splitting after it can't break up 'twenty first'; I dropped that check. These now give [5, 6, 27] and [1, 2, 23]. Running numbers() over the nlp-corpus sentences that contain ordinals gives the same output as before. Added a test to number-edge-cases.test.js; it fails on dev and passes with the change. The full suite and the plugin suites pass.

I used Claude Code to write this change.

numbers() only split 'seventh fifth' when no match in the whole document
had a tens word before an ordinal, so one 'twenty seventh' anywhere kept
'the fifth, sixth' together and parsed it as 0. An ordinal always ends
its number, so splitting after it can't break up 'twenty first'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@spencermountain
spencermountain merged commit 6a720bd into spencermountain:dev Nov 2, 2026
1 check passed
@spencermountain

Copy link
Copy Markdown
Owner

very nice!

@spencermountain spencermountain mentioned this pull request Nov 8, 2026
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