public override bool CallRescue(Coderack coderack, IParsedPhrase input, PatternTemplateSource patternTemplateSource, string reason, IContinuation skip, IContinuation succ, IFailure fail)
        {
            List <string> words = GroupPhrase.PhraseToTexts(input);

            bool          changed   = false;
            List <string> corrected = new List <string>();

            foreach (string word in words)
            {
                string correct = comparer.GetCorrects(word)[0];
                if (correct.ToLower() != word.ToLower())
                {
                    changed = true;
                }
                corrected.Add(correct);
            }

            if (changed)
            {
                IParsedPhrase correct  = parser.Parse(StringUtilities.JoinWords(corrected));
                IFailure      fallfail = fallback.MakeFailure(input, patternTemplateSource, succ, fail, coderack);
                patternTemplateSource.Generate(coderack, correct, succ, fallfail, weight);
                return(true);
            }
            else
            {
                return(fallback.CallRescue(coderack, input, patternTemplateSource, reason, skip, succ, fail));
            }
        }
        public static List <IContent> Produced(Context context, POSTagger tagger, GrammarParser parser)
        {
            List <IContent> result = new List <IContent>();

            foreach (IContent content in context.Contents)
            {
                if (content is Word)
                {
                    result.Add(content);
                }
                else if (content is Special && (content.Name.StartsWith("*") || content.Name.StartsWith("_")))
                {
                    List <IContent> words = GetStarValue(context, content.Name);
                    result.AddRange(words);
                }
                else if (content is Variable)
                {
                    IParsedPhrase phrase = ((Variable)content).Produce(context, tagger, parser);
                    if (phrase == null)
                    {
                        return(null);    // we failed!  don't use it!
                    }
                    List <string> words = GroupPhrase.PhraseToTexts(phrase);
                    foreach (string word in words)
                    {
                        result.Add(new Word(word));
                    }
                }
                else
                {
                    result.Add(content);
                }
            }

            return(result);
        }