private static string GetAdverb(string adj) { foreach (KeyValuePair <string, string> irregular in _irregularAdverbs) { if (StringUtils.PartOf(adj, irregular.Key, 4)) { string prefix = adj.Substring(0, adj.LastIndexOf(irregular.Key, StringComparison.Ordinal)); return(prefix + irregular.Value); } } return(EnglishUtils.GetAdverb(adj)); }
public void GetAdverb() { foreach (string root in new[] { "cheap", "quick", "slow" }) { Assert.AreEqual(root + "ly", EnglishUtils.GetAdverb(root)); } foreach (string root in new[] { "easy", "angry", "happy", "lucky" }) { Assert.AreEqual(root.Substring(0, root.Length - 1) + "ily", EnglishUtils.GetAdverb(root)); } foreach (string root in new[] { "probable", "terrible", "gentle" }) { Assert.AreEqual(root.Substring(0, root.Length - 1) + "y", EnglishUtils.GetAdverb(root)); } foreach (string root in new[] { "basic", "tragic", "economic" }) { Assert.AreEqual(root + "ally", EnglishUtils.GetAdverb(root)); } }