protected List <PatternMatch> RecursiveMatch(AmbiguousPhrase subject, PatternMatch before, uint index)
        {
            List <PatternMatch> matches = matchers[(int)index].AllMatches(subject, before);

            if (matches != null)
            {
                if (index == matchers.Count - 1)
                {
                    return(matches);
                }

                List <PatternMatch> allMatches = new List <PatternMatch>();
                foreach (PatternMatch match in matches)
                {
                    List <PatternMatch> matchMatches = RecursiveMatch(subject, match, index + 1);
                    if (matchMatches != null)
                    {
                        allMatches.AddRange(matchMatches);
                    }
                }

                return(allMatches);
            }

            return(null);
        }
Пример #2
0
        public PatternMatch CloneWithEnd(AmbiguousPhrasePointer end)
        {
            PatternMatch match = new PatternMatch();
            match.dictionary = new Dictionary<string, string>(dictionary);
            match.start = start;
            match.end = end;

            return match;
        }
Пример #3
0
        public PatternMatch CloneWithEnd(AmbiguousPhrasePointer end)
        {
            PatternMatch match = new PatternMatch();

            match.dictionary = new Dictionary <string, string>(dictionary);
            match.start      = start;
            match.end        = end;

            return(match);
        }
        public override List<PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
        {
            List<PatternMatch> result = new List<PatternMatch>();
            if (caseSensitive) {
                if (pattern == subject.StringAt(before.End))
                    result.Add(before.MatchExtendedBy(1));
            } else
                if (pattern == subject.StringAt(before.End).ToLower())
                    result.Add(before.MatchExtendedBy(1));

            return result;
        }
        public override List <PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
        {
            List <PatternMatch> matches = new List <PatternMatch>();

            PatternMatch attempt = before;

            while (!attempt.End.Equals(subject.End))
            {
                matches.Add(attempt);
                AmbiguousPhrasePointer next = attempt.Start.PointerFurtheredBy(1);
                attempt = new PatternMatch(next);
            }

            return(matches);
        }
        public override List <PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
        {
            List <PatternMatch> result = new List <PatternMatch>();

            if (caseSensitive)
            {
                if (pattern == subject.StringAt(before.End))
                {
                    result.Add(before.MatchExtendedBy(1));
                }
            }
            else
            if (pattern == subject.StringAt(before.End).ToLower())
            {
                result.Add(before.MatchExtendedBy(1));
            }

            return(result);
        }
Пример #7
0
        protected List<PatternMatch> RecursiveMatch(AmbiguousPhrase subject, PatternMatch before, uint index)
        {
            List<PatternMatch> matches = matchers[(int) index].AllMatches(subject, before);
            if (matches != null) {
                if (index == matchers.Count - 1)
                    return matches;

                List<PatternMatch> allMatches = new List<PatternMatch>();
                foreach (PatternMatch match in matches) {
                    List<PatternMatch> matchMatches = RecursiveMatch(subject, match, index+1);
                    if (matchMatches != null)
                        allMatches.AddRange(matchMatches);
                }

                return allMatches;
            }

            return null;
        }
 public override List <PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
 {
     return(RecursiveMatch(subject, before, 0));
 }
 public virtual List <PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
 {
     return(null);
 }
        public List <PatternMatch> AllMatches(AmbiguousPhrase subject)
        {
            PatternMatch before = new PatternMatch();

            return(AllMatches(subject, before));
        }
Пример #11
0
 public virtual List<PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
 {
     return null;
 }
Пример #12
0
 public List<PatternMatch> AllMatches(AmbiguousPhrase subject)
 {
     PatternMatch before = new PatternMatch();
     return AllMatches(subject, before);
 }
Пример #13
0
 public override List<PatternMatch> AllMatches(AmbiguousPhrase subject, PatternMatch before)
 {
     return RecursiveMatch(subject, before, 0);
 }