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

32
LINES

< > BotCompany Repo | #1017930 // Partial rule evaluation Spike 1 [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (16550L/121K).

!7

p-exp {
  final IfThen rule = nlLogic_parseRuleWithMacros([[
    i(can you $walk_on_water?)
    && fact(nobody can $walk_on_water)
    => say(no. nobody can $walk_on_water)
  ]]);
  final new NLLogicChecker_v3 c;
  c.input = "can you look around corners?";

  final new NLLogicChecker_v2.Matching m;
  m.verbose = true;
  
  final L<Exp> l = nlLogic_unrollAnd(rule.in);
  if (l == null) ret with print("No conditions");
  print("Conditions: " + l);
  
  // WORKS
  c.iterate(first(l), m, r {
    print("Got match: " + sfu(m.matches));
    print("Remaining conditions: " + c.apply(nlLogic_and(dropFirst(l)), m);
    print("Remaining rule: " + c.apply(IfThen(nlLogic_and(dropFirst(l)), rule.out), m));
  });
  
  // WORKS in this case, but iterate is better
  print("Method 2");
  if (c.checkExpression(first(l), m)) {
    print("Got match: " + sfu(m.matches));
    print("Remaining: " + c.apply(nlLogic_and(dropFirst(l)), m));
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017930
Snippet name: Partial rule evaluation Spike 1 [OK]
Eternal ID of this version: #1017930/15
Text MD5: 158d16c1c91243026a70ed99e22d3d55
Transpilation MD5: bf151843b94c8c5ff4087ddb25dee1a7
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-04 17:23:08
Source code size: 966 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 468 / 1149
Version history: 14 change(s)
Referenced in: #1020037 - Partial rule evaluation Spike 2 [OK]