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

37
LINES

< > BotCompany Repo | #1018321 // applyNLLogicFacts_v4_iterate_withFailed

JavaX fragment (include)

static new ThreadLocal<Bool> applyNLLogicFacts_v4_iterate_withFailed_verbose;

svoid applyNLLogicFacts_v4_iterate_withFailed(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, VF3<IfThen, NLLogicChecker_v2.Matching, Exp> onRuleFailed) {
  applyNLLogicFacts_v4_iterate_withFailed(input, onRuleFired, onRuleFailed, mL_facts());
}

svoid applyNLLogicFacts_v4_iterate_withFailed(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, VF3<IfThen, NLLogicChecker_v2.Matching, Exp> onRuleFailed, LS facts) {
  applyNLLogicFacts_v4_iterate_withFailed(input, onRuleFired, onRuleFailed, facts, ai_mL_parsedLogicExamples2());
}

svoid applyNLLogicFacts_v4_iterate_withFailed(S input, VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, VF3<IfThen, NLLogicChecker_v2.Matching, Exp> onRuleFailed, LS facts, L<IfThen> rules) {
  new NLLogicChecker_v2 c;
  //c.matcher = new NLStringMatcher_dollarVars;
  addAll(c.facts, facts);
  c.input = input;
  
  applyNLLogicFacts_v4_iterate_withFailed(c, onRuleFired, onRuleFailed, rules);
}

svoid applyNLLogicFacts_v4_iterate_withFailed(final NLLogicChecker_v2 c, final VF2<IfThen, NLLogicChecker_v2.Matching> onRuleFired, final VF3<IfThen, NLLogicChecker_v2.Matching, Exp> onRuleFailed, L<IfThen> rules) {
  c.rules = rules;
  for (final IfThen rule : rules) pcall {
    final new NLLogicChecker_v2.Matching m;
    m.verbose = isTrue(applyNLLogicFacts_v4_iterate_withFailed_verbose!);
    if (m.verbose)
      print("Checking rule (iterating): " + rule);
    nlLogic_iterate_withOnFail(c, rule.in, m, r {
      if (m.verbose) {
        print("Matched " + quote(c.input) + " with rule " + quote(rule));
        printStruct("  ", m.matches);
      }
      callF(onRuleFired, rule, m);
    }, voidfunc(Exp e) {
      callF(onRuleFailed, rule, m, e)
    });
  }
}

Author comment

Began life as a copy of #1018148

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: #1018321
Snippet name: applyNLLogicFacts_v4_iterate_withFailed
Eternal ID of this version: #1018321/6
Text MD5: be2969e95c9236593a3a104e49712465
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 18:03:31
Source code size: 1843 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 347 / 373
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018330 - applyNLLogicFacts_v4_iterate_withFailed2 - records satisfied conditions