static new ThreadLocal applyNLLogicFacts_v3_verbose; svoid applyNLLogicFacts_v3(S input, VF1 out) { applyNLLogicFacts_v3(input, out, mL_facts()); } svoid applyNLLogicFacts_v3(S input, VF1 out, LS facts) { applyNLLogicFacts_v3(input, out, facts, ai_mL_parsedLogicExamples()); } svoid applyNLLogicFacts_v3(S input, VF1 out, LS facts, L rules) { new NLLogicChecker_v2 c; c.matcher = new NLStringMatcher_dollarVars; addAll(c.facts, facts); c.input = input; applyNLLogicFacts_v3(c, out, rules); } svoid applyNLLogicFacts_v3(NLLogicChecker_v2 c, VF1 vfOut, L rules) { for (IfThen rule : rules) pcall { IfThen rule = idAndRule.b; new NLLogicChecker_v2.Matching m; m.verbose = isTrue(applyNLLogicFacts_v3_verbose!); if (m.verbose) print("Checking rule: " + rule); if (c.checkRule(rule, m)) { print("Matched " + quote(c.input) + " with rule " + quote(rule)); printStruct(m.matches); new SS matches; // matches made in evaluating RHS of rule for (Exp out : m.output) for (Exp e : nlLogic_unrollAnd(out)) if (e cast Func) callF(vfOut, c.apply(e, m)); else if (e cast Eq) { Exp r = e.right; S var = nlLogic_text(e.left); if (r cast Func) if (isStandardFunction(r.name) && r.arg instanceof Sentence && noJavaTokens(nlLogic_text(r.arg))) matches.put(var, str(callAndMake(r.name))); } } } }