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

50
LINES

< > BotCompany Repo | #1018302 // Logic Tester [with direct input of rules & facts, Dyn Module]

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

Uses 911K of libraries. Click here for Pure Java version (19615L/109K).

!7

set flag DynModule.

cmodule TestBot > DynObjectTable<ExecutedRule> {
  InputChooser inputChooser = new(this);
  S source, facts, rules;
  S inputAs = "Input:"; // "Input:" or "Fact:"
  bool allowUnsafeEvals;
  
  start {
    dm_useLocalMechListCopies();
    set transpileRaw_useDiskCache;
    inputChooser.delay = 1000;
    itemToMap = itemToMap_ExecutedRule_v2();
  }
  
  visualize {
    ret withMargin(northCenterAndSouth(vstackWithSpacing(
      westCenterAndEast(dm_fieldComboBox('inputAs,
        ll("Input:", "Fact:")),
        wrap(inputChooser),
        withLeftMargin(jbutton("Compute", rThread compute)))
      ),
      jvsplit(super.visualize(),
        jhsplit(
          withTitle("Facts", jLiveValueWordWrapTypeWriterTextArea_bothWays(dm_fieldLiveValue('facts))),
          withTitle("Rules", jLiveValueWordWrapTypeWriterTextArea_bothWays(dm_fieldLiveValue('rules))), 0.5, 100), 0.2, 100
      ),
      dm_fieldCheckBox('allowUnsafeEvals)));
  }
  
  void compute { update(inputChooser.input()); }
  
  void update { if (inputChooser.update()) update(inputChooser.input()); }
  
  void update(S input) {
    temp enter();
    bool inputAsFact = cic(inputAs, 'fact);
    NLLogicChecker_v2.staticVerbose = true;
    
    L<IfThen> theRules = ai_parseRulesWithMacros(rules);
    theRules = map nlLogic_rawSentencesToFacts(theRules);
    LS theFacts = tlft(facts);
    
    NLLogicChecker_v2.staticVerbose = true;
    temp tempSetTL(nlLogic_processInputOrFact_allowUnsafeEvals, allowUnsafeEvals);
    setData(nlLogic_processInputOrFact(input, inputAsFact, pair(theRules, theFacts)));
  }
}

Author comment

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: #1018302
Snippet name: Logic Tester [with direct input of rules & facts, Dyn Module]
Eternal ID of this version: #1018302/17
Text MD5: 57ef9c332c6816cfdc9ccf9fe0c26981
Transpilation MD5: e1148ad0135e23bd0aada770bf80a59f
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: 2019-02-10 21:32:43
Source code size: 1654 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 308 / 998
Version history: 16 change(s)
Referenced in: [show references]