Libraryless. Click here for Pure Java version (24029L/180K).
1 | !7 |
2 | |
3 | set flag DynModule. |
4 | |
5 | sclass TestBot extends DynObjectTable<ExecutedRule> { |
6 | InputChooser inputChooser = new(this); |
7 | S source; |
8 | S inputAs = "Input:"; // "Input:" or "Fact:" |
9 | bool unsafeEvals; |
10 | |
11 | start { |
12 | dm_useLocalMechListCopies(); |
13 | inputChooser.delay = 1000; |
14 | itemToMap = itemToMap_ExecutedRule(); |
15 | } |
16 | |
17 | visualize { |
18 | ret withMargin(northAndCenter(vstackWithSpacing( |
19 | westAndCenter(dm_fieldComboBox('inputAs, |
20 | ll("Input:", "Fact:")), |
21 | wrap(inputChooser)), |
22 | withLabel("Rules mech lists (empty for default rules&facts):", |
23 | onEnter(dm_fieldTextField('source), rThread doIt)), |
24 | jrightalignedline(main.onChange(dm_fieldCheckBox("Allow unsafe evals", 'unsafeEvals), rThread doIt))), |
25 | super.visualize())); |
26 | } |
27 | |
28 | void doIt { update(inputChooser.input()); } |
29 | |
30 | void update { if (inputChooser.update()) update(inputChooser.input()); } |
31 | |
32 | void update(S input) { |
33 | temp enter(); |
34 | bool inputAsFact = cic(inputAs, 'fact); |
35 | NLLogicChecker_v2.staticVerbose = true; |
36 | temp tempSetTL(nlLogic_processInputOrFact_withFailed_allowUnsafeEvals, unsafeEvals); |
37 | L<ExecutedRule> l = nlLogic_processInputOrFact_withFailed(input, inputAsFact, |
38 | or2(trim(source), "<default>")); |
39 | |
40 | // Successful rules first |
41 | sortInPlaceByCalculatedField(l, func(ExecutedRule r) -> Int { |
42 | int n = r.failureLevel(); |
43 | ret n == 0 ? 0 : n < 0 ? 1 : Int.MAX_VALUE-n; |
44 | }); |
45 | printLength("l=", l); |
46 | setData(l); |
47 | } |
48 | } |
Began life as a copy of #1018272
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: | #1018323 |
Snippet name: | Test Bot v4 [with failed rules, Dyn Module] |
Eternal ID of this version: | #1018323/9 |
Text MD5: | 78b0476ce932910bd510852987a46d1a |
Transpilation MD5: | fbdf6b5fe12ac1648e8be1b9f4e64cfa |
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-19 22:05:34 |
Source code size: | 1530 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 370 / 581 |
Version history: | 8 change(s) |
Referenced in: | [show references] |