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).

1  
!7
2  
3  
p-exp {
4  
  final IfThen rule = nlLogic_parseRuleWithMacros([[
5  
    i(can you $walk_on_water?)
6  
    && fact(nobody can $walk_on_water)
7  
    => say(no. nobody can $walk_on_water)
8  
  ]]);
9  
  final new NLLogicChecker_v3 c;
10  
  c.input = "can you look around corners?";
11  
12  
  final new NLLogicChecker_v2.Matching m;
13  
  m.verbose = true;
14  
  
15  
  final L<Exp> l = nlLogic_unrollAnd(rule.in);
16  
  if (l == null) ret with print("No conditions");
17  
  print("Conditions: " + l);
18  
  
19  
  // WORKS
20  
  c.iterate(first(l), m, r {
21  
    print("Got match: " + sfu(m.matches));
22  
    print("Remaining conditions: " + c.apply(nlLogic_and(dropFirst(l)), m);
23  
    print("Remaining rule: " + c.apply(IfThen(nlLogic_and(dropFirst(l)), rule.out), m));
24  
  });
25  
  
26  
  // WORKS in this case, but iterate is better
27  
  print("Method 2");
28  
  if (c.checkExpression(first(l), m)) {
29  
    print("Got match: " + sfu(m.matches));
30  
    print("Remaining: " + c.apply(nlLogic_and(dropFirst(l)), m));
31  
  }
32  
}

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: 315 / 779
Version history: 14 change(s)
Referenced in: [show references]