sclass NLLogicChecker_v1 { S input; new L<S> facts; sclass Matching { SS matches; // var -> match new L<Exp> output; } bool checkRule(IfThen rule, Matching m) { if (rule == null) false; if (!checkExpression(rule.in, m)) false; m.output.add(rule.out); true; } bool checkExpression(Exp e, Matching m) { if (e cast And) ret checkExpression(e.a, m) && checkExpression(e.b, m); if (e cast Func) { if (eq(e.name, "input")) ret match(join(((Sentence) e.arg).tok), input); else if (eq(e.name, "fact")) { S pat = join(((Sentence) e.arg).tok); for (S fact : facts) if (match(pat, fact)) true; } } false; } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017580 |
Snippet name: | NLLogicChecker_v1 |
Eternal ID of this version: | #1017580/4 |
Text MD5: | 49093ed184e567b5cccae2d9bf5efdf4 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-28 11:34:22 |
Source code size: | 763 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 333 / 899 |
Version history: | 3 change(s) |
Referenced in: | #1017587 - NLLogicChecker_v2 #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |