Skip to content

Fix singular_noun for words ending in -ss - #238

Open
bysiber wants to merge 1 commit into
jaraco:mainfrom
bysiber:fix-singular-noun-ss-words
Open

Fix singular_noun for words ending in -ss#238
bysiber wants to merge 1 commit into
jaraco:mainfrom
bysiber:fix-singular-noun-ss-words

Conversation

@bysiber

@bysiber bysiber commented Feb 22, 2026

Copy link
Copy Markdown

singular_noun returns wrong results for words ending in -ss:

>>> p.singular_noun("grass")
'gras'
>>> p.singular_noun("glass")
'glas'
>>> p.singular_noun("boss")
'bos'

The problem is the catch-all rule at the end of _sinoun that strips a trailing s from any word. Words ending in -ss (like "grass", "glass", "boss", "moss", "cross", "dress") are already singular, so they shouldn't reach this rule.

The fix adds a check for -ss endings right before the catch-all, returning False since these words are already singular. Their plural forms (grasses, glasses, etc.) are still handled correctly by the earlier -sses rules.

All 223 existing tests continue to pass plus 16 new ones covering the fix.

Fixes #235

Words like "grass", "glass", "boss", "moss", "cross", "dress" etc.
are already singular, but singular_noun() was stripping the final "s"
(e.g. "grass" → "gras") because the catch-all rule at the end of
_sinoun only checks for a trailing "s".

Added a guard for words ending in "ss" before the catch-all, so they
correctly return False. Their plural forms (-sses) are unaffected
since those are handled by earlier rules.

Fixes jaraco#235
@pacohope

Copy link
Copy Markdown

I'm using this library to normalise plurals in a fork of word_cloud. This bug is tripping me up because it's creating non-existent singular forms of words that are already singular. This is a really simple fix and has tests, too. It fixes the problem. Can it be merged, please?

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.

words ending with 'ss' singular_noun might not work

2 participants