Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

37
LINES

< > BotCompany Repo | #1018330 // applyNLLogicFacts_v4_iterate_withFailed2 - records satisfied conditions

JavaX fragment (include)

1  
static new ThreadLocal<Bool> applyNLLogicFacts_v4_iterate_withFailed2_verbose;
2  
3  
svoid applyNLLogicFacts_v4_iterate_withFailed2(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, VF4<IfThen, NLLogicChecker_v2.Matching, L<Exp>, Exp> onRuleFailed) {
4  
  applyNLLogicFacts_v4_iterate_withFailed2(input, onRuleFired, onRuleFailed, mL_facts());
5  
}
6  
7  
svoid applyNLLogicFacts_v4_iterate_withFailed2(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, VF4<IfThen, NLLogicChecker_v2.Matching, L<Exp>, Exp> onRuleFailed, LS facts) {
8  
  applyNLLogicFacts_v4_iterate_withFailed2(input, onRuleFired, onRuleFailed, facts, ai_mL_parsedLogicExamples2());
9  
}
10  
11  
svoid applyNLLogicFacts_v4_iterate_withFailed2(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, VF4<IfThen, NLLogicChecker_v2.Matching, L<Exp>, Exp> onRuleFailed, LS facts, L<IfThen> rules) {
12  
  new NLLogicChecker_v2 c;
13  
  //c.matcher = new NLStringMatcher_dollarVars;
14  
  addAll(c.facts, facts);
15  
  c.input = input;
16  
  
17  
  applyNLLogicFacts_v4_iterate_withFailed2(c, onRuleFired, onRuleFailed, rules);
18  
}
19  
20  
svoid applyNLLogicFacts_v4_iterate_withFailed2(final NLLogicChecker_v2 c, final VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, final VF4<IfThen, NLLogicChecker_v2.Matching, L<Exp>, Exp> onRuleFailed, L<IfThen> rules) {
21  
  c.rules = rules;
22  
  for (final IfThen rule : rules) pcall {
23  
    final new NLLogicChecker_v2.Matching m;
24  
    m.verbose = isTrue(applyNLLogicFacts_v4_iterate_withFailed2_verbose!);
25  
    if (m.verbose)
26  
      print("Checking rule (iterating): " + rule);
27  
    nlLogic_iterate_withOnFail2(c, rule.in, m, new L, r {
28  
      if (m.verbose) {
29  
        print("Matched " + quote(c.input) + " with rule " + quote(rule));
30  
        printStruct("  ", m.matches);
31  
      }
32  
      callF(onRuleFired, rule, m);
33  
    }, voidfunc(L<Exp> satisfiedConditions, Exp e) {
34  
      callF(onRuleFailed, rule, m, satisfiedConditions, e)
35  
    });
36  
  }
37  
}

Author comment

Began life as a copy of #1018321

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018330
Snippet name: applyNLLogicFacts_v4_iterate_withFailed2 - records satisfied conditions
Eternal ID of this version: #1018330/4
Text MD5: ea5a81ce368e32ae8352ab775600a16d
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-19 21:16:16
Source code size: 1941 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 335 / 369
Version history: 3 change(s)
Referenced in: [show references]