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

27
LINES

< > BotCompany Repo | #1018346 // nlLogic_processInputOrFact_steppable - only safe evals by default

JavaX fragment (include)

1  
// rulesMechListName = "<default>" => default rules & facts
2  
static Steppable nlLogic_processInputOrFact_steppable(S input, bool inputAsFact, S rulesMechListName, Collector<ExecutedRule> out) {
3  
  ret nlLogic_processInputOrFact_steppable(input, inputAsFact,
4  
    eq(rulesMechListName, "<default>")
5  
      ? ai_activeRulesAndFacts()
6  
      : pair(ai_rulesFromMechLists(tok_splitAtComma(rulesMechListName)), emptyList_asList(S)), out);
7  
}
8  
9  
static new ThreadLocal<Bool> nlLogic_processInputOrFact_steppable_allowUnsafeEvals;
10  
11  
static Steppable nlLogic_processInputOrFact_steppable(S input, bool inputAsFact, Pair<L<IfThen>, LS> rulesAndFacts, final Collector<ExecutedRule> out) {
12  
  ret nlLogic_processInputOrFact_steppable(new NLLogicChecker_v2, input, inputAsFact, rulesAndFacts, out);
13  
}
14  
15  
static Steppable nlLogic_processInputOrFact_steppable(NLLogicChecker_v2 c, S input, bool inputAsFact, Pair<L<IfThen>, LS> rulesAndFacts, final Collector<ExecutedRule> out) {
16  
  if (!inputAsFact) c.input = input;
17  
  c.facts = reversed(rulesAndFacts.b);
18  
  if (inputAsFact) c.facts = concatLists(ll(input), c.facts);
19  
  c.rules = reversed(rulesAndFacts.a); // latest rules first!
20  
  if (!inputAsFact)
21  
    c.rules = [IfThen r : c.rules | ai_ruleAccessesInput(r)];
22  
  c.allowUnsafeEvals = isTrue(nlLogic_processInputOrFact_steppable_allowUnsafeEvals!);
23  
  print("Have " + n2(rulesAndFacts.a, "rule"));
24  
  c.useIterate = true;
25  
  //c.staticVerbose = true;
26  
  ret nlLogic_fillBattleSpace_steppable(c, ai_ruleWithParamsCollector(out, c), false);
27  
}

Author comment

Began life as a copy of #1018322

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: #1018346
Snippet name: nlLogic_processInputOrFact_steppable - only safe evals by default
Eternal ID of this version: #1018346/10
Text MD5: 9d0ac63c1c77da7bf3fdcc165193c6c7
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-31 23:17:09
Source code size: 1536 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 344 / 396
Version history: 9 change(s)
Referenced in: [show references]