Skip to content

pluralize(): safe -> saves, cafe -> caves, buzz -> buzzs, census unchanged, policeman -> policemans #129

Open

Description

@trackoor

pluralize gives a non-word or leaves the word unchanged for several common nouns. This is separate from the singularize reports in #123 and #128, and from the -s nouns in PR #127.

// npm i inflection@3.0.2, then node
const { pluralize } = require('inflection');

// -fe words that do not take -ves
console.log(pluralize('safe'));       // 'saves'      (expected 'safes')
console.log(pluralize('cafe'));       // 'caves'      (expected 'cafes')
console.log(pluralize('carafe'));     // 'caraves'    (expected 'carafes')

// -z / -zz
console.log(pluralize('buzz'));       // 'buzzs'      (expected 'buzzes')
console.log(pluralize('fez'));        // 'fezs'       (expected 'fezzes')

// -s nouns returned unchanged
console.log(pluralize('census'));     // 'census'     (expected 'censuses')
console.log(pluralize('gas'));        // 'gas'        (expected 'gases')
console.log(pluralize('lens'));       // 'lens'       (expected 'lenses')

// -man compounds (man -> men works on its own)
console.log(pluralize('policeman'));  // 'policemans' (expected 'policemen')
console.log(pluralize('fireman'));    // 'firemans'   (expected 'firemen')

// hard -ch
console.log(pluralize('stomach'));    // 'stomaches'  (expected 'stomachs')
console.log(pluralize('epoch'));      // 'epoches'    (expected 'epochs')
console.log(pluralize('monarch'));    // 'monarches'  (expected 'monarchs')

// f -> ves
console.log(pluralize('leaf'));       // 'leafs'      (expected 'leaves')
console.log(pluralize('thief'));      // 'thiefs'     (expected 'thieves')
console.log(pluralize('loaf'));       // 'loafs'      (expected 'loaves')

Actual: the values in the comments (saves, caves, caraves, buzzs, fezs, census, gas, lens, policemans, firemans, stomaches, epoches, monarches, leafs, thiefs, loafs).
Expected: the standard English plurals (safes, cafes, carafes, buzzes, fezzes, censuses, gases, lenses, policemen, firemen, stomachs, epochs, monarchs, leaves, thieves, loaves).

In src/inflection.ts, regex.singular.ffe (/(?:([^f])fe|([lr])f)$/gi) turns any non-ffe word ending in fe into ves and only converts -f after l or r, regex.singular.man (/^(m|wom)an$/gi) is start-anchored so -man compounds miss it, regex.singular.x (/(x|ch|ss|sh)$/gi) lacks z/zz and treats every -ch as -ches, and regex.singular.s (/s$/gi -> 's') leaves singular -s nouns unchanged unless listed earlier.

Version: inflection@3.0.2, also on master 0c37535.

Credit: https://ucsbplse.github.io/

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