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)

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

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