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

45
LINES

< > BotCompany Repo | #1027748 // New Engine Spike with logic rule [dev.]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (4474L/24K).

!include once #1027630 // Msg

replace LogicRule with BasicLogicRule.

cmodule NewEngineSpike > DynPrintLog {
  L<Msg> msgs;
  bool verbose = true, printNonMatches = true;
  
  start-thread {
    if (empty(msgs))
      setField(msgs := mainCruddieLog());
    print("Have " + nMessages(msgs));
    pnlStruct(takeFirst(2, msgs));
    L<Msg> msgs2 = whereFieldIsTrue fromUser(msgs);
    new L props;
    for (Msg msg : takeFirst(5, msgs2))
      print(addAndReturn(props, ll(msg, "was understood correctly")));
    props.add(print(ll(get(msgs2, 5), "is a wrong recognition")));

    LogicRule rule = new(
      ll("$x", "is a wrong recognition"),
      ll("$x", "should be corrected"));

    for (O prop : props)
      applyLogicRuleToFact(rule, prop);
  }

  // define what a variable is
  bool isVar(O o) { ret o instanceof S && isDollarVar(o/S); }

  void applyLogicRuleToFact(LogicRule rule, O fact) {
    new LogicRuleApplier ap;
    ap.rule = rule;
    ap.fact = fact;
    ap.verbose = verbose;
    ap.printNonMatches = printNonMatches;
    ap.addRewrittenRHS = lambda2 addRewrittenRHS;
    ap.tools.isVar = lambda1 isVar;
    ap.run();
  }

  void addRewrittenRHS(O rhs, O trail) {
    print("Derived: " + rhs);
  }
}

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: #1027748
Snippet name: New Engine Spike with logic rule [dev.]
Eternal ID of this version: #1027748/14
Text MD5: 3a7c646bf43b67212e9aff13fe58064f
Transpilation MD5: e362c99b624fc193710c85695133d869
Author: stefan
Category:
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-10 00:29:38
Source code size: 1221 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 169 / 564
Version history: 13 change(s)
Referenced in: [show references]