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

27
LINES

< > BotCompany Repo | #1018322 // nlLogic_processInputOrFact_withFailed

JavaX fragment (include)

// rulesMechListName = "<default>" => default rules & facts
static L<ExecutedRule> nlLogic_processInputOrFact_withFailed(S input, bool inputAsFact, S rulesMechListName) {
  ret nlLogic_processInputOrFact_withFailed(input, inputAsFact,
    eq(rulesMechListName, "<default>")
      ? ai_activeRulesAndFacts()
      : pair(ai_rulesFromMechLists(tok_splitAtComma(rulesMechListName)), emptyList(S)));
}

static new ThreadLocal<Bool> nlLogic_processInputOrFact_withFailed_allowUnsafeEvals;

static L<ExecutedRule> nlLogic_processInputOrFact_withFailed(S input, bool inputAsFact, Pair<L<IfThen>, LS> rulesAndFacts) {
  new NLLogicChecker_v3 c;
  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_withFailed_allowUnsafeEvals!);
  print("Have " + n2(rulesAndFacts.a, "rule"));
  c.useIterate = true;
  //c.staticVerbose = true;
  new L<RuleWithParams> battleSpace;
  nlLogic_fillBattleSpace_collector(c, listCollector(battleSpace), false);
  //print("l=" + l(battleSpace));
  ret map nlLogic_executedRuleFromRuleWithParams(battleSpace);
}

Author comment

Began life as a copy of #1018275

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: #1018322
Snippet name: nlLogic_processInputOrFact_withFailed
Eternal ID of this version: #1018322/5
Text MD5: a3ed55c149d5dba020efd3fb53c8181c
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-19 23:40:41
Source code size: 1342 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 241 / 282
Version history: 4 change(s)
Referenced in: [show references]