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

32
LINES

< > BotCompany Repo | #1027763 // Test NewEngine [OK]

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

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

!include once #1027630 // Msg

cmodule NewEngineSpike > DynPrintLog {
  L<Msg> msgs;
  transient new NewEngine engine;

  start-thread {
    if (empty(msgs))
      setField(msgs := mainCruddieLog());
    print("Have " + nMessages(msgs));
    pnlStruct(takeFirst(2, msgs));
    L<Msg> msgs2 = whereFieldIsTrue fromUser(msgs);
    Msg wrongMsg = get(msgs2, 5);
    for (Msg msg : takeFirst(5, msgs2))
      engine.addFormattedFact("* was understood correctly", msg);
    engine.addFormattedFact("* is a wrong recognition", wrongMsg);

    engine.addLogicRule(new BasicLogicRule(
      ll(SymVar("$x"), Fragment("is a wrong recognition")),
      ll(SymVar("$x"), Fragment("should be corrected"))));
    engine.addLogicRule(new BasicLogicRule(
      ll("$x", Fragment("should be corrected")),
      ll("$x", Fragment("is a wrong recognition"))));

    engine.think();
    
    L facts = engine.factsInOrderOfDefinition();
    assertContains(facts, formatWithFragments("* should be corrected", wrongMsg));
    assertDoesntContain(facts, formatWithFragments("* should be corrected", first(msgs2)));
    print("OK");
  }
}

Author comment

Began life as a copy of #1027758

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: #1027763
Snippet name: Test NewEngine [OK]
Eternal ID of this version: #1027763/8
Text MD5: 0b42d962e6d60fb2128684f67938471d
Transpilation MD5: 3f18ac47159dd3de2ad36f2edc0f1100
Author: stefan
Category: javax / new gazelle
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-16 14:15:46
Source code size: 1146 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 244 / 903
Version history: 7 change(s)
Referenced in: #1027880 - More complex test of NewEngine [dev.]