Libraryless. Compilation Failed (23592L/178K).
1 | !7 |
2 | |
3 | sclass Suggestion {
|
4 | RuleWithParams rule; |
5 | S output; |
6 | S facts; |
7 | S newInput; |
8 | |
9 | *() {}
|
10 | *(RuleWithParams *rule, S *output, S *facts, S *newInput) {}
|
11 | } |
12 | |
13 | sclass TestBot extends DynObjectTable<RuleWithParams> {
|
14 | InputChooser inputChooser = new(this); |
15 | S source; |
16 | S inputAs = "Input:"; // "Input:" or "Fact:" |
17 | |
18 | start { inputChooser.delay = 1000; }
|
19 | |
20 | visualize {
|
21 | ret withMargin(northAndCenter(vstackWithSpacing( |
22 | westAndCenter(dm_fieldComboBox('inputAs,
|
23 | ll("Input:", "Fact:")),
|
24 | wrap(inputChooser)), |
25 | withLabel("Rules mech list (empty for default rules&facts):",
|
26 | onEnter(dm_fieldTextField('source), rThread { update(inputChooser.input()) }))),
|
27 | super.visualize())); |
28 | } |
29 | |
30 | void update { if (inputChooser.update()) update(inputChooser.input()); }
|
31 | |
32 | void update(S input) {
|
33 | temp enter(); |
34 | new NLLogicChecker_v3 c; |
35 | bool inputAsFact = cic(inputAs, 'fact); |
36 | if (!inputAsFact) c.input = input; |
37 | Pair<L<IfThen>, LS> rulesAndFacts; |
38 | if (empty(trim(source))) |
39 | rulesAndFacts = ai_activeRulesAndFacts(); |
40 | else |
41 | rulesAndFacts = pair(ai_parseRulesWithMacros(mL_raw(trim(source))), emptyList(S)); |
42 | c.facts = reversed(rulesAndFacts.b); |
43 | if (inputAsFact) c.facts = concatLists(ll(input), c.facts); |
44 | c.rules = reversed(rulesAndFacts.a); // latest rules first! |
45 | if (!inputAsFact) |
46 | c.rules = [IfThen r : c.rules | ai_ruleAccessesInput(r)]; |
47 | c.rules = nlLogic_safeLHSEvalsOnly_verbose(c.rules); |
48 | print("Have " + n2(rulesAndFacts.a, "rule"));
|
49 | c.useIterate = true; |
50 | c.staticVerbose = true; |
51 | new L<RuleWithParams> battleSpace; |
52 | nlLogic_fillBattleSpace(c, battleSpace, false); |
53 | //print("l=" + l(battleSpace));
|
54 | setData(map(battleSpace, func(RuleWithParams r) -> Suggestion {
|
55 | L<Exp> l = nlLogic_unrollAndApplyRuleWithParams(r); |
56 | ret Suggestion(r, |
57 | nullIfEmpty(join("|", nlLogic_certainOperatorArgs(l, 'output, 'say))),
|
58 | nullIfEmpty(join("|", nlLogic_certainOperatorArgs(l, 'fact))),
|
59 | nullIfEmpty(join("|", nlLogic_certainOperatorArgs(l, 'input))));
|
60 | })); |
61 | } |
62 | } |
Began life as a copy of #1018152
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1018254 |
| Snippet name: | Test Bot v2 [Dyn Module, with rules selection, OK] |
| Eternal ID of this version: | #1018254/22 |
| Text MD5: | c6ba36e6b0b02009fa90667060782a0e |
| Transpilation MD5: | 6d2b343ea9f61bb431fe2e1278385bf8 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-09-13 14:20:37 |
| Source code size: | 2166 bytes / 62 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 649 / 922 |
| Version history: | 21 change(s) |
| Referenced in: | [show references] |