1 | sclass NLLogicChecker_v1 {
|
2 | S input; |
3 | new L<S> facts; |
4 | |
5 | sclass Matching {
|
6 | SS matches; // var -> match |
7 | new L<Exp> output; |
8 | } |
9 | |
10 | bool checkRule(IfThen rule, Matching m) {
|
11 | if (rule == null) false; |
12 | if (!checkExpression(rule.in, m)) false; |
13 | m.output.add(rule.out); |
14 | true; |
15 | } |
16 | |
17 | bool checkExpression(Exp e, Matching m) {
|
18 | if (e cast And) |
19 | ret checkExpression(e.a, m) && checkExpression(e.b, m); |
20 | if (e cast Func) {
|
21 | if (eq(e.name, "input")) |
22 | ret match(join(((Sentence) e.arg).tok), input); |
23 | else if (eq(e.name, "fact")) {
|
24 | S pat = join(((Sentence) e.arg).tok); |
25 | for (S fact : facts) |
26 | if (match(pat, fact)) |
27 | true; |
28 | } |
29 | } |
30 | false; |
31 | } |
32 | } |
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: | 550 / 1131 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |