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

38
LINES

< > BotCompany Repo | #1018384 // NLLogic_MultiThreadedEngine

JavaX fragment (include)

1  
sclass NLLogic_MultiThreadedEngine {
2  
  bool unsafeEvals, showFailed;
3  
  F0<NLLogicChecker_v2> makeLogicChecker;
4  
  Pair<L<IfThen>, LS> rulesAndFacts;
5  
  MultiMap<Int, ExecutedRule> executedRules = treeMultiMap();
6  
  new MultiThreadStepper stepper;
7  
  new LinkedHashSet<S> inputs;
8  
  
9  
  *(Pair<L<IfThen>, LS> *rulesAndFacts) {}
10  
  
11  
  void processInput(S input) {
12  
    if (!inputs.add(input)) ret;
13  
14  
    temp tempSetTL(nlLogic_processInputOrFact_steppable_allowUnsafeEvals, unsafeEvals);
15  
    stepper.add(nlLogic_processInputOrFact_steppable(makeLogicChecker(), input, false /*inputAsFact*/, 
16  
      rulesAndFacts, new Collector<ExecutedRule>() {
17  
        bool add(ExecutedRule r) {
18  
          if (!showFailed && r.isFailed()) true;
19  
          executedRules.put(ai_executedRuleScorer().get(r), r);
20  
          for (S s : unnull(r.newInput))
21  
            processInput(s);
22  
          true;
23  
        }
24  
      }));
25  
  };
26  
  
27  
  void seedInput(S input) { processInput(input); }
28  
  
29  
  void fullRun {
30  
    stepAllWithStats_multiThreaded(stepper);
31  
  }
32  
  
33  
  NLLogicChecker_v2 makeLogicChecker() {
34  
    ret makeLogicChecker != null ? callF(makeLogicChecker) : new NLLogicChecker_v2;
35  
  }
36  
  
37  
  L<ExecutedRule> executedRules() { ret executedRules.allValues(); }
38  
}

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: 341 / 890
Version history: 7 change(s)
Referenced in: [show references]