1use crate::EnglishCore;
2use crate::grammar::*;
3
4impl EnglishCore {
5 pub fn noun(word: &str, number: &Number) -> String {
6 match number {
7 Number::Singular => return word.to_string(),
8 Number::Plural => return EnglishCore::pluralize_noun(word),
9 }
10 }
11 pub fn add_possessive(word: &str) -> String {
12 if word.ends_with('s') {
13 format!("{word}'") } else {
15 format!("{word}'s") }
17 }
18
19 pub fn pluralize_noun(word: &str) -> String {
20 if let Some(irr) = EnglishCore::iter_replace_last(word, IRREGULAR_SUFFIXES) {
21 return irr;
22 }
23 format!("{}{}", word, "s")
24 }
25}
26
27const IRREGULAR_SUFFIXES: &[(&str, &str)] = &[
30 ("mouse", "mice"),
33 ("tooth", "teeth"),
35 ("goose", "geese"),
36 ("trix", "trices"),
37 ("fish", "fish"),
38 ("deer", "deer"),
39 ("foot", "feet"),
41 ("zoon", "zoa"),
42 ("ese", "ese"),
43 ("man", "men"),
44 ("sis", "ses"),
48 ("xis", "xes"),
49 ("um", "a"),
55 ("ch", "ches"),
56 ("sh", "shes"),
57 ("ay", "ays"),
58 ("oy", "oys"),
60 ("ey", "eys"),
61 ("x", "xes"),
62 ("s", "ses"),
64 ("y", "ies"),
65 ("f", "ves"),
66];