Example #1
0
        private static Verb ComputeNewVerb(string word)
        {
            string pastTense = null;
            string pastPart  = null;
            string presPart  = EnglishUtils.GetPresentParticiple(word);
            string thirdPers = GetThirdPerson(word);

            foreach (KeyValuePair <string, string[]> irregular in _irregularVerbs)
            {
                if (StringUtils.PartOf(word, irregular.Key, '-'))
                {
                    string[] pasts = irregular.Value;
                    if (pasts[1].Length > 0)
                    {
                        string prefix = word.Substring(0, word.LastIndexOf(irregular.Key, StringComparison.Ordinal));
                        pastTense = prefix + pasts[0];
                        pastPart  = prefix + pasts[1];
                        break;
                    }
                }
            }

            if (pastTense == null)
            {
                pastTense = EnglishUtils.GetRegularPast(word);
                pastPart  = EnglishUtils.GetRegularPast(word);
            }

            return(new Verb(word, pastTense, pastPart, presPart, thirdPers));
        }
Example #2
0
        public void GetVerbForms()
        {
            //long vowel or diphthong followed by a consonant or ending in a consonant cluster
            foreach (string root in new[] { "paint", "claim", "devour", "play", "delight", "clamp", "lacquer" })
            {
                Assert.AreEqual(root + "ed", EnglishUtils.GetRegularPast(root));
                Assert.AreEqual(root + "ing", EnglishUtils.GetPresentParticiple(root));
                Assert.AreEqual(root + "s", EnglishUtils.GetThirdPerson(root));
            }

            //short vowel
            foreach (string root in new[] { "chat", "chop", "compel", "quiz", "squat", "quit", "equal", "whiz" })
            {
                char lastChar = root[root.Length - 1];
                Assert.AreEqual(root + lastChar + "ed", EnglishUtils.GetRegularPast(root));
                Assert.AreEqual(root + lastChar + "ing", EnglishUtils.GetPresentParticiple(root));
                if (!root.Equals("quiz") && !root.Equals("whiz")) //irregular third person
                {
                    Assert.AreEqual(root + "s", EnglishUtils.GetThirdPerson(root));
                }
            }

            //consonant followed by e
            foreach (string root in new[] { "dance", "save", "devote", "evolve", "quote" })
            {
                Assert.AreEqual(root + "d", EnglishUtils.GetRegularPast(root));
                Assert.AreEqual(root.Substring(0, root.Length - 1) + "ing", EnglishUtils.GetPresentParticiple(root));
                Assert.AreEqual(root + "s", EnglishUtils.GetThirdPerson(root));
            }

            //sibilants
            foreach (string root in new[] { "kiss", "bless", "box", "polish", "preach", "bias", "box" })
            {
                Assert.AreEqual(root + "ed", EnglishUtils.GetRegularPast(root));
                Assert.AreEqual(root + "ing", EnglishUtils.GetPresentParticiple(root));
                Assert.AreEqual(root + "es", EnglishUtils.GetThirdPerson(root));
            }

            //consonant followed by y
            foreach (string root in new[] { "comply", "copy", "magnify" })
            {
                Assert.AreEqual(root.Substring(0, root.Length - 1) + "ied", EnglishUtils.GetRegularPast(root));
                Assert.AreEqual(root + "ing", EnglishUtils.GetPresentParticiple(root));
                Assert.AreEqual(root.Substring(0, root.Length - 1) + "ies", EnglishUtils.GetThirdPerson(root));
            }
        }