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

21
LINES

< > BotCompany Repo | #1027421 // pb_enableAutoPatterns - grab patterns from every rule, top-down parse every new fact

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9838L/64K).

svoid pb_enableAutoPatterns(PhilosophyBot1 bot, O... _) {
  optPar bool debug;
  if (debug)
    print("pb_enableAutoPatterns");
  Set<S> patterns = ciSet();
  IVF1<S> onFact = fact -> bot.addFacts(dm_topDownParseToGroupings(fact, patterns));
  IVF1<PhilosophyBot1.LogicRule> onRule = rule -> {
    LS l = uniquifyCI(map(lhs -> philosophyBot_varsToStars(bot, lhs), 
      stringsOnly(philosophyBot_allPartsOfLHS(rule))));
    if (debug)
      print("Patterns in " + rule + ": " + l);
    LS l2 = listMinusSet(l, patterns);
    if (nempty(l2)) {
      if (debug) print("Have new patterns: " + l2);
      patterns.addAll(l2);
      bot.updateCodeOnFact(onFact);
    }
  };
  bot.addCodeOnFact(onFact);
  bot.addCodeOnRule(onRule);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027421
Snippet name: pb_enableAutoPatterns - grab patterns from every rule, top-down parse every new fact
Eternal ID of this version: #1027421/11
Text MD5: 4d39fe3678dff34c13d3f7add9d416ca
Transpilation MD5: c1044caf86e79cfb087e87025aafd02b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-18 19:28:25
Source code size: 749 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 322
Version history: 10 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)