private static string GetNounPlural(string noun) { foreach (KeyValuePair <string, string> irregular in _irregularPlurals) { if (StringUtils.PartOf(noun, irregular.Key, 4, "man")) { string prefix = noun.Substring(0, noun.LastIndexOf(irregular.Key, StringComparison.Ordinal)); return(prefix + irregular.Value); } } return(EnglishUtils.GetNounPlural(noun)); }
public void GetNounPlural() { foreach (string root in new[] { "file", "centre", "girl", "book", "computer", "ambition", "chief", "spoof", "cliff", "journey", "boy", "radio", "stereo", "video" }) { Assert.AreEqual(root + "s", EnglishUtils.GetNounPlural(root)); } foreach (string root in new[] { "wash", "box", "match", "glass", "bus", "business", "coach", "peach" }) { Assert.AreEqual(root + "es", EnglishUtils.GetNounPlural(root)); } foreach (string root in new[] { "country", "baby", "body", "memory" }) { Assert.AreEqual(root.Substring(0, root.Length - 1) + "ies", EnglishUtils.GetNounPlural(root)); } }