// Adds a codelet to check this input against us public void Generate(Coderack coderack, IParsedPhrase input, IContinuation succ, IFailure fail, double weight) { double salience = maxSalience * score * weight; PatternTemplateSource checker = new PatternTemplateSource(this, coderack, salience, succ); Matcher.MatchAgainst(salience, pattern, input, new List <IParsedPhrase>(), checker, fail); }
public PatternTemplateSource(PatternTemplateSource parent, Coderack coderack, double salience, IContinuation succ) { pattern = parent.pattern; template = parent.template; score = parent.score; source = parent.source; this.coderack = coderack; this.salience = salience; this.succ = succ; }
public PatternTemplateSource(PatternTemplateSource parent, Coderack coderack, double salience, IContinuation succ) { pattern = parent.pattern; template = parent.template; score = parent.score; source = parent.source; this.coderack = coderack; this.salience = salience; this.succ = succ; }
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 IFailure MakeFailure(IParsedPhrase input, PatternTemplateSource patternTemplateSource, IContinuation succ, IFailure fail, Coderack coderack) { return new FailletWrapper(FailToTryToRescue, this, input, patternTemplateSource, succ, fail, coderack); }
// default is failure to rescue public virtual bool CallRescue(Coderack coderack, IParsedPhrase input, PatternTemplateSource patternTemplateSource, string reason, IContinuation skip, IContinuation succ, IFailure fail) { return fail.Fail(reason, skip); }
// Adds a codelet to check this input against us public void Generate(Coderack coderack, IParsedPhrase input, IContinuation succ, IFailure fail, double weight) { double salience = maxSalience * score * weight; PatternTemplateSource checker = new PatternTemplateSource(this, coderack, salience, succ); Matcher.MatchAgainst(salience, pattern, input, new List<IParsedPhrase>(), checker, fail); }