1 | static new ThreadLocal<Bool> applyNLLogicFacts_v3_verbose; |
2 | static ThreadLocal<VF2<IfThen, NLLogicChecker_v2.Matching>> applyNLLogicFacts_v3_onRuleFired = new ThreadLocal; |
3 | |
4 | svoid applyNLLogicFacts_v3(S input, VF1<Exp> out) { |
5 | applyNLLogicFacts_v3(input, out, mL_facts()); |
6 | } |
7 | |
8 | svoid applyNLLogicFacts_v3(S input, VF1<Exp> out, LS facts) { |
9 | applyNLLogicFacts_v3(input, out, facts, ai_mL_parsedLogicExamples2()); |
10 | } |
11 | |
12 | svoid applyNLLogicFacts_v3(S input, VF1<Exp> out, LS facts, L<IfThen> rules) { |
13 | new NLLogicChecker_v3 c; |
14 | c.matcher = new NLStringMatcher_dollarVars; |
15 | addAll(c.facts, facts); |
16 | c.input = input; |
17 | |
18 | applyNLLogicFacts_v3(c, out, rules); |
19 | } |
20 | |
21 | svoid applyNLLogicFacts_v3(NLLogicChecker_v2 c, VF1<Exp> vfOut, L<IfThen> rules) { |
22 | VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired = optParam(applyNLLogicFacts_v3_onRuleFired); |
23 | |
24 | for (IfThen rule : rules) pcall { |
25 | new NLLogicChecker_v2.Matching m; |
26 | m.verbose = isTrue(applyNLLogicFacts_v3_verbose!); |
27 | if (m.verbose) |
28 | print("Checking rule: " + rule); |
29 | if (c.checkRule(rule, m)) { |
30 | if (m.verbose) { |
31 | print("Matched " + quote(c.input) + " with rule " + quote(rule)); |
32 | printStruct(m.matches); |
33 | } |
34 | callF(onRuleFired, rule, m); |
35 | |
36 | new SS matches; // matches made in evaluating RHS of rule |
37 | for (Exp out : m.output) |
38 | for (Exp e : nlLogic_unrollAnd(out)) |
39 | if (e cast Func) |
40 | callF(vfOut, c.apply(e, m)); |
41 | /*else if (e cast Eq) { |
42 | Exp r = e.right; |
43 | S var = nlLogic_text(e.left); |
44 | if (r cast Func) |
45 | if (isStandardFunction(r.name) && r.arg instanceof Sentence && noJavaTokens(nlLogic_text(r.arg))) |
46 | matches.put(var, str(callAndMake(r.name))); |
47 | }*/ |
48 | } |
49 | } |
50 | } |
Began life as a copy of #1017652
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: | #1017761 |
Snippet name: | applyNLLogicFacts_v3 |
Eternal ID of this version: | #1017761/17 |
Text MD5: | 86506ab54c7ad9aa21e7c75c01e28d53 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-09-16 13:58:16 |
Source code size: | 1827 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 443 / 534 |
Version history: | 16 change(s) |
Referenced in: | [show references] |