use crate::EnglishCore;
use crate::grammar::*;
impl EnglishCore {
pub fn noun(word: &str, number: &Number) -> String {
match number {
Number::Singular => return word.to_string(),
Number::Plural => return EnglishCore::pluralize_noun(word),
}
}
pub fn add_possessive(word: &str) -> String {
if word.ends_with('s') {
format!("{word}'") } else {
format!("{word}'s") }
}
pub fn pluralize_noun(word: &str) -> String {
if let Some(irr) = EnglishCore::iter_replace_last(word, IRREGULAR_SUFFIXES) {
return irr;
}
format!("{}{}", word, "s")
}
}
const IRREGULAR_SUFFIXES: &[(&str, &str)] = &[
("mouse", "mice"),
("tooth", "teeth"),
("goose", "geese"),
("trix", "trices"),
("fish", "fish"),
("deer", "deer"),
("foot", "feet"),
("zoon", "zoa"),
("ese", "ese"),
("man", "men"),
("sis", "ses"),
("xis", "xes"),
("um", "a"),
("ch", "ches"),
("sh", "shes"),
("ay", "ays"),
("oy", "oys"),
("ey", "eys"),
("x", "xes"),
("s", "ses"),
("y", "ies"),
("f", "ves"),
];