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

28
LINES

< > TinyBrain | #1018057 - ai_deriveFacts - just returns new facts

JavaX fragment (include)

sbool ai_deriveFacts_debug;

static Set<S> ai_deriveFacts(L<IfThen> rules, LS facts) {
  final new NLLogicChecker_v3 c;
  c.facts = facts;
  final new NLLogicChecker_v2.Matching m;
  m.verbose = ai_deriveFacts_debug;
  final new LinkedHashSet<S> outFacts;
  for (final IfThen rule : nlLogic_filterByRHSConstructs(rules, 'fact)) {
    if (ai_deriveFacts_debug)
      print("ai_deriveFacts: Checking " + rule);
    c.iterate(rule.in, m, r {
      if (ai_deriveFacts_debug)
        print("Got matches: " + sfu(m.matches));
        
      for (Exp e : nlLogic_unrollAnd(rule.out)) {
        e = c.apply(e, m);
        if (e cast Func)
          if (eq(e.name, "fact"))
            continue with outFacts.add(nlLogic_text(e.arg));
        if (c.checkHelper(e, m))
          continue;
        print("Ignoring unknown RHS element: " + e);
      }
    });
  }
  ret outFacts;
}

download  show line numbers  debug dex   

Travelled to 9 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, tvejysmllsmz

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: 81 / 103
Version history: 9 change(s)
Referenced in: [show]