pub fn pluralize(noun: &NounEntry) -> StringExpand description
Computes the plural form of a noun.
Returns the irregular plural if one is defined in the noun’s forms map under
the "plural" key. Otherwise, applies English pluralization rules:
- Sibilants (
-s,-x,-ch,-sh) → append-es(“box” → “boxes”) - Consonant +
y→ replaceywith-ies(“city” → “cities”) - Vowel +
y(-ay,-ey,-oy,-uy) → append-s(“day” → “days”) - Default → append
-s(“dog” → “dogs”)
§Arguments
noun- The noun entry containing the lemma and optional irregular forms.
§Examples
use logicaffeine_lexicon::runtime::{NounEntry, pluralize};
use std::collections::HashMap;
// Regular noun
let dog = NounEntry {
lemma: "dog".to_string(),
forms: HashMap::new(),
features: vec![],
sort: None,
};
assert_eq!(pluralize(&dog), "dogs");
// Irregular noun
let mouse = NounEntry {
lemma: "mouse".to_string(),
forms: [("plural".to_string(), "mice".to_string())].into(),
features: vec![],
sort: None,
};
assert_eq!(pluralize(&mouse), "mice");