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

67
LINES

< > BotCompany Repo | #1021516 // Sentences from Simple Wikipedia (as list, with Gazelle analysis, dev.)

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

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

!7

sclass Line {
  S text, interpretation;
  
  sS _fieldOrder = "text interpretation";
}

cmodule SimpleWikipediaSentences > DynTableWithInput<Line> {
  S topic;
  
  start {
    set fieldsInOrder;
    dm_vmBus_onMessage_q('gazelleRulesChanged, r forceUpdate);
  }
  
  afterVisualize {
    tablePopupMenuItemsThreaded(table(),
      "Ignore", r ignoreLine,
      "Make rule...", r makeRule);
  }
  
  void update(S topic) {
    topic = trim(topic);
    setField(+topic);
    setModuleName(topic + " - Simple Wikipedia");
    final L<Line> data = cloneList_putInField Line('text, simpleWikipedia_sentencesForTopic(topic));
    
    fS _topic = topic;
    time "Interpret Lines" {
    //showText("Profile", poorMansProfileToString(r {
      LPair<S, Int> ignore = dm_gazelle_linesToIgnoreForSimpleWikipediaTopic(_topic);
      GazelleEvalContext ctx = dm_gazelle_stdEvalContext();
      for i over data: {
        Line l = data.get(i);
        if (contains(ignore, pair(l.text, i)))
          continue with l.interpretation = 'ignore;
          
        GazelleTree tree = new(l.text); 
        tree.ctx = ctx;
        dm_gazelle_getChildren(tree);
        if (nempty(tree.children))
          l.interpretation = first(tree.children).line;
      }
      setData(data);
    //}));
    }
  }
  
  void ignoreLine {
    int i = selectedIndex();
    Line line = selected();
    if (line == null) ret;
    LS context = collect text(subList(data(), 0, i));
    LS comments = ll(
      "out = action", 
      "from simple wikipedia topic " + optQuote(topic),
      "previous lines = " + quote(lines_rtrim(context)));
    dm_gazelle_addRuleWithComment(line.text + "\n=> ignore", lines_rtrim(comments));
  }
  
  void makeRule {
    Line line = selected();
    if (line == null) ret;
    dm_gazelle_newRuleDialog_3(line.text);
  }
}

Author comment

Began life as a copy of #1021503

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021516
Snippet name: Sentences from Simple Wikipedia (as list, with Gazelle analysis, dev.)
Eternal ID of this version: #1021516/18
Text MD5: b67057d7bce955cc882f34ff6397c8bf
Transpilation MD5: 8dd7c7189ccb3f4279396f9d91d2b159
Author: stefan
Category: javax / stefan's os / a.i.
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-17 15:48:07
Source code size: 1890 bytes / 67 lines
Pitched / IR pitched: No / No
Views / Downloads: 240 / 642
Version history: 17 change(s)
Referenced in: [show references]