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

28
LINES

< > BotCompany Repo | #1018275 // nlLogic_processInputOrFact

JavaX fragment (include)

1  
// rulesMechListName = "<default>" => default rules & facts
2  
static L<ExecutedRule> nlLogic_processInputOrFact(S input, bool inputAsFact, S rulesMechListName) {
3  
  ret nlLogic_processInputOrFact(input, inputAsFact,
4  
    eq(rulesMechListName, "<default>")
5  
      ? ai_activeRulesAndFacts()
6  
      : pair(ai_rulesFromMechList(trim(rulesMechListName)), (LS) emptyList()));
7  
}
8  
9  
static new ThreadLocal<Bool> nlLogic_processInputOrFact_allowUnsafeEvals;
10  
11  
static L<ExecutedRule> nlLogic_processInputOrFact(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  
  if (!isTrue(nlLogic_processInputOrFact_allowUnsafeEvals!))
20  
    c.rules = nlLogic_safeLHSEvalsOnly/*_verbose*/(c.rules);
21  
  print("Have " + n2(rulesAndFacts.a, "rule"));
22  
  c.useIterate = true;
23  
  //c.staticVerbose = true;
24  
  new L<RuleWithParams> battleSpace;
25  
  nlLogic_fillBattleSpace(c, battleSpace, false);
26  
  //print("l=" + l(battleSpace));
27  
  ret map nlLogic_executedRuleFromRuleWithParams(battleSpace);
28  
}

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: #1018275
Snippet name: nlLogic_processInputOrFact
Eternal ID of this version: #1018275/11
Text MD5: 443d185213cc5b00297b898eae606262
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-10 21:35:49
Source code size: 1299 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 443 / 493
Version history: 10 change(s)
Referenced in: [show references]