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)

// rulesMechListName = "<default>" => default rules & facts
static Steppable nlLogic_processInputOrFact_steppable(S input, bool inputAsFact, S rulesMechListName, Collector<ExecutedRule> out) {
  ret nlLogic_processInputOrFact_steppable(input, inputAsFact,
    eq(rulesMechListName, "<default>")
      ? ai_activeRulesAndFacts()
      : pair(ai_rulesFromMechLists(tok_splitAtComma(rulesMechListName)), emptyList_asList(S)), out);
}

static new ThreadLocal<Bool> nlLogic_processInputOrFact_steppable_allowUnsafeEvals;

static Steppable nlLogic_processInputOrFact_steppable(S input, bool inputAsFact, Pair<L<IfThen>, LS> rulesAndFacts, final Collector<ExecutedRule> out) {
  ret nlLogic_processInputOrFact_steppable(new NLLogicChecker_v2, input, inputAsFact, rulesAndFacts, out);
}

static Steppable nlLogic_processInputOrFact_steppable(NLLogicChecker_v2 c, S input, bool inputAsFact, Pair<L<IfThen>, LS> rulesAndFacts, final Collector<ExecutedRule> out) {
  if (!inputAsFact) c.input = input;
  c.facts = reversed(rulesAndFacts.b);
  if (inputAsFact) c.facts = concatLists(ll(input), c.facts);
  c.rules = reversed(rulesAndFacts.a); // latest rules first!
  if (!inputAsFact)
    c.rules = [IfThen r : c.rules | ai_ruleAccessesInput(r)];
  c.allowUnsafeEvals = isTrue(nlLogic_processInputOrFact_steppable_allowUnsafeEvals!);
  print("Have " + n2(rulesAndFacts.a, "rule"));
  c.useIterate = true;
  //c.staticVerbose = true;
  ret nlLogic_fillBattleSpace_steppable(c, ai_ruleWithParamsCollector(out, c), false);
}

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: 345 / 397
Version history: 9 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018378 - nlLogic_collectExecutedRules_steppable