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

20
LINES

< > BotCompany Repo | #1017647 // applyNLLogicFacts

JavaX fragment (include)

svoid applyNLLogicFacts(S input, VF1<? super S> postMessage) {
  new NLLogicChecker_v2 c;
  c.matcher = new NLStringMatcher_dollarVars;
  c.facts.addAll(mL("Random facts"));
  c.input = input;

  for (PairS idAndRule : combineWithGlobalIDs(splitAtEmptyLines(mL_raw("NL Logic Examples")))) pcall {
    S rule = idAndRule.b;
    NLLogicChecker_v2.Matching m = new NLLogicChecker_v2.Matching();
    if (c.checkRule(nlLogic_parseRule(rule), m)) {
      print("Matched " + quote(input) + " with rule " + quote(rule));
      printStruct(m.matches);
      for (Exp out : m.output)
        for (Exp e : nlLogic_unrollAnd(out))
          if (e cast Func)
            if (eq(e.name, "output") && e.arg instanceof Sentence)
              callF(postMessage, ((Sentence) e.arg).text());
    }
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017647
Snippet name: applyNLLogicFacts
Eternal ID of this version: #1017647/5
Text MD5: 821380d483406d40f01ad18861973f00
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-07-31 14:17:46
Source code size: 804 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 351
Version history: 4 change(s)
Referenced in: [show references]