static new ThreadLocal<Bool> applyNLLogicFacts_v2_verbose; svoid applyNLLogicFacts_v2(S input, VF1<? super S> postMessage) { applyNLLogicFacts_v2(input, postMessage, mL_facts()); } svoid applyNLLogicFacts_v2(S input, VF1<? super S> postMessage, LS facts) { applyNLLogicFacts_v2(input, postMessage, facts, ai_mL_parsedLogicExamples()); } svoid applyNLLogicFacts_v2(S input, VF1<? super S> postMessage, LS facts, L<Pair<S, IfThen>> rules) { new NLLogicChecker_v2 c; c.matcher = new NLStringMatcher_dollarVars; addAll(c.facts, facts); c.input = input; applyNLLogicFacts_v2(c, postMessage, rules); } svoid applyNLLogicFacts_v2(NLLogicChecker_v2 c, VF1<? super S> postMessage, L<Pair<S, IfThen>> rules) { for (Pair<S, IfThen> idAndRule : rules) pcall { IfThen rule = idAndRule.b; new NLLogicChecker_v2.Matching m; m.verbose = isTrue(applyNLLogicFacts_v2_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) { if (eq(e.name, "output") && e.arg instanceof Sentence) callF(postMessage, addAndReturn(c.posted, replaceVars(nlLogic_text(e.arg), matches))); } /*else if (e cast Eq) { // any sf as operator - disabled for security reasons, use eval() 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))); }*/ } } }
Began life as a copy of #1017647
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017652 |
Snippet name: | applyNLLogicFacts_v2 - with evaluating standard functions |
Eternal ID of this version: | #1017652/14 |
Text MD5: | fc353d644ee9d1df5f4f2d164c9ff1b8 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-20 17:43:29 |
Source code size: | 1875 bytes / 46 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 416 / 489 |
Version history: | 13 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1017761 - applyNLLogicFacts_v3 |