Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

57
LINES

< > BotCompany Repo | #1018355 // Test Bot v6 [rewriting input, Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (24310L/183K).

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, showFailed;
10  
  int maxEntries = 100;
11  
12  
  start {
13  
    dm_useLocalMechListCopies();
14  
    set transpileRaw_useDiskCache;
15  
    inputChooser.delay = 1000;
16  
    itemToMap = itemToMap_ExecutedRule();
17  
  }
18  
  
19  
  visualize {
20  
    ret withMargin(northAndCenter(vstackWithSpacing(
21  
      westAndCenter(dm_fieldComboBox('inputAs,
22  
        ll("Input:", "Fact:")),
23  
        wrap(inputChooser)),
24  
      withLabel("Rules mech lists (empty for default rules&facts):",
25  
        onEnter(dm_fieldTextField('source), rThread doIt)),
26  
      jrightalignedline(
27  
        main.onChange(dm_fieldCheckBox("Allow unsafe evals", 'unsafeEvals), rThread doIt),
28  
        main.onChange(dm_fieldCheckBox("Show failed rules", 'showFailed), rThread doIt),
29  
        jlabel("Show"), jminwidth(50, jLiveValueIntTextField(dm_fieldLiveValueWithNotify('maxEntries, r doIt))), jlabel("entries")
30  
      )),
31  
      super.visualize()));
32  
  }
33  
  
34  
  void doIt { updateMe(); }
35  
  
36  
  void update {
37  
    if (inputChooser.update())
38  
      update(inputChooser.input());
39  
  }
40  
  
41  
  void update(S input) enter {
42  
    final bool inputAsFact = cic(inputAs, 'fact);
43  
    print("Processing " + (inputAsFact ? "fact" : "input") + " " + input);
44  
    NLLogicChecker_v2.staticVerbose = true;
45  
    
46  
    NLLogic_MultiThreadedEngine engine = new(ai_rulesAndFactsFromMechLists(or2(trim(source), "<default>")));
47  
    engine.unsafeEvals = unsafeEvals;
48  
    engine.showFailed = showFailed;
49  
    engine.seedInput(input);
50  
    engine.fullRun();
51  
      
52  
    L<ExecutedRule> all = engine.executedRules();
53  
    L<ExecutedRule> l = takeFirst(maxEntries, all);
54  
    print("Showing " + l(l) + " out of " + l(all));
55  
    setData(l);
56  
  }
57  
}

Author comment

Began life as a copy of #1018348

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: #1018355
Snippet name: Test Bot v6 [rewriting input, Dyn Module]
Eternal ID of this version: #1018355/19
Text MD5: 023111b66da504c163a67c7ad08dd4ee
Transpilation MD5: cf1709dd7f89503b7f121f2ab17528e2
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-12-24 00:58:31
Source code size: 1876 bytes / 57 lines
Pitched / IR pitched: No / No
Views / Downloads: 475 / 5434
Version history: 18 change(s)
Referenced in: [show references]