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

38
LINES

< > BotCompany Repo | #1018384 // NLLogic_MultiThreadedEngine

JavaX fragment (include)

sclass NLLogic_MultiThreadedEngine {
  bool unsafeEvals, showFailed;
  F0<NLLogicChecker_v2> makeLogicChecker;
  Pair<L<IfThen>, LS> rulesAndFacts;
  MultiMap<Int, ExecutedRule> executedRules = treeMultiMap();
  new MultiThreadStepper stepper;
  new LinkedHashSet<S> inputs;
  
  *(Pair<L<IfThen>, LS> *rulesAndFacts) {}
  
  void processInput(S input) {
    if (!inputs.add(input)) ret;

    temp tempSetTL(nlLogic_processInputOrFact_steppable_allowUnsafeEvals, unsafeEvals);
    stepper.add(nlLogic_processInputOrFact_steppable(makeLogicChecker(), input, false /*inputAsFact*/, 
      rulesAndFacts, new Collector<ExecutedRule>() {
        bool add(ExecutedRule r) {
          if (!showFailed && r.isFailed()) true;
          executedRules.put(ai_executedRuleScorer().get(r), r);
          for (S s : unnull(r.newInput))
            processInput(s);
          true;
        }
      }));
  };
  
  void seedInput(S input) { processInput(input); }
  
  void fullRun {
    stepAllWithStats_multiThreaded(stepper);
  }
  
  NLLogicChecker_v2 makeLogicChecker() {
    ret makeLogicChecker != null ? callF(makeLogicChecker) : new NLLogicChecker_v2;
  }
  
  L<ExecutedRule> executedRules() { ret executedRules.allValues(); }
}

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: #1018384
Snippet name: NLLogic_MultiThreadedEngine
Eternal ID of this version: #1018384/8
Text MD5: 51a66105201f732271b6509a2318b124
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-23 18:36:48
Source code size: 1259 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 340 / 888
Version history: 7 change(s)
Referenced in: [show references]