Fix singularization of words ending in -ives - #351
Open
dylanpulver wants to merge 1 commit into
Open
Conversation
The generic rule ([^fo])ves$ -> \1fe turned every -ives plural into -ife, so explosives singularized to explosife and adhesives to adhesife. A whitelist of tive/hive/drive/dive/olive had grown in front of it one word at a time, which is why archives and olives happened to work while the rest of the family did not. Replaced that whitelist with explicit knives/wives/lives rules plus a general (ive)s$ rule, which is two rules shorter and covers the whole family.
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.
([^fo])ves$->\1feturns every-ivesplural into-ife, so on 2.1.0:Only knife, wife and life lose the
v; every other-ivenoun keeps it.archivesandolivescome out right today only because the(hive)s$and(olive)s$entries in front of that rule catch them, a whitelist that grew one word at a time ((dive)s$for issue #44,(olive)s$in #67).This replaces the five-entry whitelist with three rules: explicit
knives/wives/lives, then a general(ive)s$. Net two rules fewer.Measurement. Oracle: no English singular ending in
-veloses thevwhen pluralized, sosingularize($w.'s') === $wmust hold. Corpus: the 2,487 words matching^[a-z]{3,}ve$in/usr/share/dict/words.(sive)s$to the whitelistThe middle row is worth stating: the smaller fix, one more whitelist entry in the style of the existing ones, passes the full suite, phpcs and phpstan, and passes two of the three cases added here. It is only distinguishable by corpus size and by
reflexives, which is why that case is in the test data.Blast radius, bounded rather than asserted: across 471,282 strings, output changes for exactly 482; every one ends in
ives, every one changes-ifeto-ive, and no word whose output was already correct changes.The remaining 332 misses are the separate
([lr])ves$family (nerves->nerf). Untouched on purpose, different rule.Checks. phpunit 1213 -> 1223 green both sides; phpcs clean; phpstan no errors;
composer validate --strictvalid. No expectation changed. Does not overlap #350, which touchesgetIrregular().Disclosure: prepared with AI assistance (Claude Opus 5,
claude-opus-5). I have reviewed the diff and verified every measurement above myself.