示例#1
0
        private static List <int> GetIndexOfCompatibleWord(string comp, string sen)
        {
            var result = new List <int>();

            if (sen.ContainsInsensitive(comp, true))
            {
                var indexes = sen.IndexesFrom(comp, true);
                AddUniqueValues(result, indexes);
            }

            VerbModel staticVerb = new VerbModel();

            if (VerbsController.Get().Any(v => v.Infinitive.EqualsNoCase(comp)))
            {
                staticVerb = VerbsController.Get().First(v => v.Infinitive.EqualsNoCase(comp));
                //else
                //    staticVerb = VerbsController.ConjugateUnknownVerb(comp);

                if (sen.ContainsInsensitive(staticVerb.Gerund, true))
                {
                    var indexes = sen.IndexesFrom(staticVerb.Gerund, true);
                    AddUniqueValues(result, indexes);
                }

                if (sen.ContainsInsensitive(staticVerb.Past, true))
                {
                    var indexes = sen.IndexesFrom(staticVerb.Past, true);
                    AddUniqueValues(result, indexes);
                }

                if (sen.ContainsInsensitive(staticVerb.PastParticiple, true))
                {
                    var indexes = sen.IndexesFrom(staticVerb.PastParticiple, true);
                    AddUniqueValues(result, indexes);
                }

                if (sen.ContainsInsensitive(staticVerb.Person, true))
                {
                    var indexes = sen.IndexesFrom(staticVerb.Person, true);
                    AddUniqueValues(result, indexes);
                }
            }

            var service = PluralizationService.CreateService(System.Globalization.CultureInfo.CurrentCulture);

            if (service.IsSingular(comp))
            {
                var plural = service.Pluralize(comp);
                if (sen.ContainsInsensitive(plural, true))
                {
                    var indexes = sen.IndexesFrom(plural, true);
                    AddUniqueValues(result, indexes);
                }
            }


            return(result);
        }
示例#2
0
        //private static bool DoesSenContainsComp(string comp, bool isVerb, string sentence)
        //{
        //    var compatible = GetCompatibleWord(comp, sentence);

        //    if (!compatible.IsEmpty())
        //        return true;

        //    return false;
        //}

        public static string GetCompatibleWord(string comp, string sen)
        {
            if (sen.ContainsInsensitive(comp))
            {
                return(comp);
            }

            VerbModel staticVerb = new VerbModel();

            if (VerbsController.Get().Any(v => v.Infinitive.EqualsNoCase(comp)))
            {
                staticVerb = VerbsController.Get().First(v => v.Infinitive.EqualsNoCase(comp));
                //else
                //    staticVerb = VerbsController.ConjugateUnknownVerb(comp);

                if (sen.ContainsInsensitive(staticVerb.Gerund))
                {
                    return(staticVerb.Gerund);
                }
                else if (sen.ContainsInsensitive(staticVerb.Past))
                {
                    return(staticVerb.Past);
                }
                else if (sen.ContainsInsensitive(staticVerb.PastParticiple))
                {
                    return(staticVerb.PastParticiple);
                }
                else if (sen.ContainsInsensitive(staticVerb.Person))
                {
                    return(staticVerb.Person);
                }
            }

            var service = PluralizationService.CreateService(System.Globalization.CultureInfo.CurrentCulture);

            if (service.IsSingular(comp))
            {
                var plural = service.Pluralize(comp);
                if (sen.ContainsInsensitive(plural))
                {
                    return(plural);
                }
            }

            return(string.Empty);
        }
示例#3
0
        public static bool IsVerb(this string word)
        {
            if (VerbsController.Get().Any(v => v.Infinitive.EqualsNoCase(word)))
                return true;

            if (VerbsController.Get().Any(v => v.Gerund.EqualsNoCase(word)))
                return true;

            if (VerbsController.Get().Any(v => v.Past.EqualsNoCase(word)))
                return true;

            if (VerbsController.Get().Any(v => v.PastParticiple.EqualsNoCase(word)))
                return true;

            if (VerbsController.Get().Any(v => v.Person.EqualsNoCase(word)))
                return true;

            return false;
        }