fix: singularize/pluralize regular -s nouns like gas/lens (fixes #123) - #127
Open
youdie006 wants to merge 1 commit into
Open
fix: singularize/pluralize regular -s nouns like gas/lens (fixes #123)#127youdie006 wants to merge 1 commit into
youdie006 wants to merge 1 commit into
Conversation
singularize() applies its rules first-match, front-to-back. For the small class of regular nouns whose singular already ends in -s and whose plural adds -es (gas/gases, lens/lenses), no -es rule matches, so the word falls through to the generic tail rule /s$/ -> '' and gets over-stripped (gases -> gase, lenses -> lense). The same generic rule also mangles the already-singular form (gas -> ga), breaking the singularize(pluralize(x)) === x round-trip. Add start-anchored, bidirectional rules for the safe -s -> -ses class gas|lens|bias|atlas|iris, following the existing summonses/nucleuses convention already in the file. Anchoring ^...$ keeps the bare protect rule from wrongly protecting words that merely end in the stem (sagas/omegas/cameras) and keeps houses -> house / buses -> bus working. Fixes dreamerslab#123.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #123.
Root cause
singularize()applies its rules first-match, front-to-back. For the small class of regular nouns whose singular already ends in-sand whose plural adds-es(gas/gases,lens/lenses), no-esrule matches, so the word falls through to the generic tail rule/s$/ -> ''and gets over-stripped:The same generic rule also mangles the already-singular form (
gas -> ga), so thesingularize(pluralize(x)) === xround-trip is broken as well.Fix
Adds start-anchored, bidirectional rules for the safe
-s->-sesclassgas|lens|bias|atlas|iris, following the existingsummonses/nucleusesconvention already in the file (anchored plural convert rule + singular protect rule, symmetric in both directions). Anchoring^...$is required so the bare protect rule does not wrongly protect words that merely end in the stem (sagas/omegas/cameras), and sohouses -> house/buses -> buskeep working.This is the same category as the recently merged #125 (
analyses -> analysis). If a narrower change is preferred, the class list trims cleanly to justgas|lens.Verification
gases/lensesassertions fail (gase/lense); with the fix, all tests pass.houses,buses), and the must-not-over-protect cases (sagas,omegas,cameras,analyses).npx vitest run-> 15 passed;npx tsc --noEmit-> clean.Note: this contribution was prepared with AI assistance and reviewed by me before submission.