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

33
LINES

< > BotCompany Repo | #1017806 // applyNLLogicFacts_v4 - only calls onRuleFired

JavaX fragment (include)

1  
static new ThreadLocal<Bool> applyNLLogicFacts_v4_verbose;
2  
3  
svoid applyNLLogicFacts_v4(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired) {
4  
  applyNLLogicFacts_v4(input, onRuleFired, mL_facts());
5  
}
6  
7  
svoid applyNLLogicFacts_v4(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, LS facts) {
8  
  applyNLLogicFacts_v4(input, onRuleFired, facts, ai_mL_parsedLogicExamples2());
9  
}
10  
11  
svoid applyNLLogicFacts_v4(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, 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(c, onRuleFired, rules);
18  
}
19  
20  
svoid applyNLLogicFacts_v4(NLLogicChecker_v2 c, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, L<IfThen> rules) {
21  
  c.rules = rules;
22  
  for (IfThen rule : rules) pcall {
23  
    new NLLogicChecker_v2.Matching m;
24  
    m.verbose = isTrue(applyNLLogicFacts_v4_verbose!);
25  
    if (m.verbose)
26  
      print("Checking rule: " + rule);
27  
    if (c.checkRule(rule, m)) {
28  
      print("Matched " + quote(c.input) + " with rule " + quote(rule));
29  
      printStruct(m.matches);
30  
      callF(onRuleFired, rule, m);
31  
    }
32  
  }
33  
}

Author comment

Began life as a copy of #1017761

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: #1017806
Snippet name: applyNLLogicFacts_v4 - only calls onRuleFired
Eternal ID of this version: #1017806/5
Text MD5: aec3e21a0daa3e7fbfb96cff69b95822
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-25 20:36:02
Source code size: 1222 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 343 / 423
Version history: 4 change(s)
Referenced in: [show references]