Skip to content

fix: pluralize and singularize compounds of man and woman - #130

Open
bardrop wants to merge 1 commit into
dreamerslab:masterfrom
bardrop-oss:fix-man-compounds
Open

bardrop wants to merge 1 commit into
dreamerslab:masterfrom
bardrop-oss:fix-man-compounds

Conversation

@bardrop

@bardrop bardrop commented Nov 19, 2026

Copy link
Copy Markdown

Fixes the -man part of #129.

pluralize('policeman')    // 'policemans'  -> 'policemen'
pluralize('gentleman')    // 'gentlemans'  -> 'gentlemen'
pluralize('policemen')    // 'policemens'  -> 'policemen'
singularize('policemen')  // 'policemen'   -> 'policeman'
singularize('firewomen')  // 'firewomen'   -> 'firewoman'

Cause

The man/men rules were ^(m|wom)an$ and ^(m|wom)en$, so they only matched the bare words. Compounds fell through to the generic -s rule.

Fix

  • Drop the ^ anchor from both rules.
  • Add two small lists so the wider rule does not catch the wrong words:
    • -man words that are not compounds of man: human (and superhuman etc.), German, Roman, Norman, shaman, talisman, caiman, ottoman, ... → still +s.
    • singular nouns that end in -men: specimen, omen, regimen, abdomen, stamen, semen, hymen, ... → still +s, and singularize leaves them alone.

Check

  • New tests fail on master (policemans, policemen) and pass now. npx vitest --run: 17 pass. tsc --noEmit clean.
  • Ran old vs new pluralize/singularize on every word in /usr/share/dict/words (lower and capitalized). Only words ending in man/men change. All the -man changes are compounds (fireman, chairman, fisherman, ...); the leftover -men changes are rare words like afikomen or clinamen.

lib/ is not committed (earlier fixes only touched src and test).

policeman -> policemen and policemen -> policeman. The man/men rules
were anchored to the whole word, so compounds fell through to the
generic -s rule (policemans, and policemen -> policemens).

Keep -man words that are not compounds of man (human, German, shaman,
talisman) and singular nouns that end in -men (specimen, omen) working.

Refs dreamerslab#129
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