Skip to content

singularize() returns non-words for common plurals: shoes -> sho, toes -> to, pies -> py, cookies -> cooky, dives -> dife #128

Open

Description

@philppplik

Description

singularize() strips the wrong suffix from several common regular plurals and returns non-words. These are different from the -se nouns in #123 and from #112.

Reproduction

inflection 3.0.2, Node 22:

const inflection = require('inflection');

for (const w of ['shoes', 'toes', 'foes', 'canoes', 'pies', 'ties', 'lies', 'cookies', 'zombies', 'selfies', 'dives', 'cactus']) {
  console.log(w, '->', inflection.singularize(w));
}

Output:

shoes -> sho        (expected shoe)
toes -> to          (expected toe)
foes -> fo          (expected foe)
canoes -> cano      (expected canoe)
pies -> py          (expected pie)
ties -> ty          (expected tie)
lies -> ly          (expected lie)
cookies -> cooky    (expected cookie)
zombies -> zomby    (expected zombie)
selfies -> selfy    (expected selfie)
dives -> dife       (expected dive)
cactus -> cactu     (expected cactus, already singular)

For comparison, movies -> movie, hives -> hive and cave/caves work, so only some endings are affected.

Cause (as far as I can tell)

The generic -oes -> o rule (potatoes -> potato, heroes -> hero) catches shoes, toes, foes and canoes. The -ies -> y rule catches words where the ie is part of the stem (pies, ties, lies, cookies, zombies, selfies). The -ves -> fe/f rule makes dives -> dife. The final -s strip for cactus is a separate rule hit.

Suggested fix

Add exceptions to the singular rules, or add them to the irregular word list, for at least: shoe, toe, foe, canoe, pie, tie, lie, cookie, zombie, selfie, dive. Happy to send a PR with tests if you want one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions