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

28
LINES

< > BotCompany Repo | #1018057 // ai_deriveFacts - just returns new facts

JavaX fragment (include)

1  
sbool ai_deriveFacts_debug;
2  
3  
static Set<S> ai_deriveFacts(L<IfThen> rules, LS facts) {
4  
  final new NLLogicChecker_v3 c;
5  
  c.facts = facts;
6  
  final new NLLogicChecker_v2.Matching m;
7  
  m.verbose = ai_deriveFacts_debug;
8  
  final new LinkedHashSet<S> outFacts;
9  
  for (final IfThen rule : nlLogic_filterByRHSConstructs(rules, 'fact)) {
10  
    if (ai_deriveFacts_debug)
11  
      print("ai_deriveFacts: Checking " + rule);
12  
    c.iterate(rule.in, m, r {
13  
      if (ai_deriveFacts_debug)
14  
        print("Got matches: " + sfu(m.matches));
15  
        
16  
      for (Exp e : nlLogic_unrollAnd(rule.out)) {
17  
        e = c.apply(e, m);
18  
        if (e cast Func)
19  
          if (eq(e.name, "fact"))
20  
            continue with outFacts.add(nlLogic_text(e.arg));
21  
        if (c.checkHelper(e, m))
22  
          continue;
23  
        print("Ignoring unknown RHS element: " + e);
24  
      }
25  
    });
26  
  }
27  
  ret outFacts;
28  
}

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: #1018057
Snippet name: ai_deriveFacts - just returns new facts
Eternal ID of this version: #1018057/10
Text MD5: c743eff2d51141ecfaa92f1825a18583
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-10 19:39:08
Source code size: 896 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 483 / 518
Version history: 9 change(s)
Referenced in: [show references]