public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
        {
            if (check is IParsedPhrase)
            {
                IParsedPhrase phrase = (IParsedPhrase)check;
                if (phrase.Part == "=P")
                {
                    // Match against each element
                    foreach (IParsedPhrase constituent in phrase.Branches)
                    {
                        Context child = new Context(context, context.Contents);
                        child.Map["$check"] = constituent;
                        ContinueToCallAgent.Instantiate(new ClauseVariable(salience, tagger, parser), child, succ, fail);
                    }
                }
                else if (phrase.Part == "FRAG" || phrase.Part == "S" || phrase.Part == "SBARQ")
                {
                    GroupPhrase   groupPhrase = new GroupPhrase(phrase);
                    IParsedPhrase last        = groupPhrase.GetBranch(groupPhrase.Count - 1);
                    if (last.Part == "." || last.Part == "?" || last.Part == "!" || last.Part == ";")
                    {
                        phrase = new GroupPhrase("?", groupPhrase.GetRange(0));
                    }

                    // Set up propogate-on-clear
                    ContinueToCallAgent cont = CallAgentWrapper.MakeContinuation(PropogateOnClear, succ, 100.0, 4, 10, "%clause", phrase);

                    // Do a match using my contents
                    Matcher.MatchAgainst(salience, context, phrase, new List <IParsedPhrase>(), cont, fail);
                }
            }

            return(true);
        }
        public override bool Match(object check, Context context, IContinuation succ, IFailure fail)
        {
            if (check is IParsedPhrase && ((IParsedPhrase)check).IsLeaf)
            {
                return(true);
            }

            // Match against each element
            foreach (IParsedPhrase constituent in ((IParsedPhrase)check).Branches)
            {
                // Set up propogate-on-clear
                ContinueToCallAgent cont = CallAgentWrapper.MakeContinuation(PropogateOnClear, succ, 100.0, 4, 10, "%phrase", check);

                if (variable == null || variable.IsMatch(constituent))
                {
                    Matcher.MatchAgainst(salience, context, constituent, new List <IParsedPhrase>(), cont, fail);
                }
                if (!(constituent.IsLeaf))
                {
                    Context child = new Context(context, context.Contents);
                    child.Map["$check"] = constituent;
                    ContinueToCallAgent.Instantiate(new PhraseVariable(salience, variable, tagger, parser), child, cont, fail);
                }
            }

            return(true);
        }