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

55
LINES

< > BotCompany Repo | #1027184 // Winograd Trails Tree [inspect trails in tree]

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

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

!7

cmodule TrailsTree {
  switchable S solverModule;
  transient O root;
  transient JTree tree;
  transient SingleComponentPanel scp;

  visual scp = singleComponentPanel(makeTree());
  
  JTree makeTree() {
    ret tree = jDynamicTree(root, lambda1 getChildren);
  }
  
  L getChildren(O o) {
    print("getChildren " + o);
    /*if (isShortNamed LogicRule(o)) {
      o = getOpt trail(o);
      if (o cast S)
        ret ll(o);
    }*/
    if (o instanceof Pair) {
      O b = o/Pair.b; 
      print('shortName, shortName(b));
      if (isShortNamed LogicRule(b)) {
        O trail = get trail(b);
        print(+trail);
        ret getChildren(trail);
      }
      o = b;
    }
    if (o cast Map)
      ret mapToPairs(o);
    if (o cast L)
      ret o;
    null;
  }
  
  start {
    if (empty(solverModule))
      setField(solverModule := (S) vmBus_query winogradSolver());
      
    virtual PhilosophyBot1 engine = dm_rget engine(solverModule);
    L<virtual LogicRule> logicRules = cloneList((Cl) rget logicRules(engine));
    Map<Int, virtual LogicRule> logicRuleIndex = indexByField n(logicRules);
    L<WithTrail<S>> trails = shallowImportAll((Iterable) rcall deducedFactsWithTrails(engine));
    setField(root := concatLists(
      map(logicRules, lambda1 ruleToNode),
      map withTrailToPair(trails)));
  }
  
  O ruleToNode(virtual LogicRule rule) {
    ret pair(rule, get trail(rule));
  }
}

Author comment

Began life as a copy of #1027108

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: #1027184
Snippet name: Winograd Trails Tree [inspect trails in tree]
Eternal ID of this version: #1027184/20
Text MD5: 30f9ede63205f8b44c56fa71ddfdb1f0
Transpilation MD5: 55c12bd9f6dabb99e7d5671bfa9cfcd1
Author: stefan
Category: javax / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-25 01:56:22
Source code size: 1465 bytes / 55 lines
Pitched / IR pitched: No / No
Views / Downloads: 257 / 577
Version history: 19 change(s)
Referenced in: