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

56
LINES

< > BotCompany Repo | #1022283 // Gazelle: Preprocessed Chat Lines

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

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

!7

concept Entry {
  long msgID;
  S line;
  S preprocessed;
  S ruleIDs; // rule(s) used for preprocessing

  sS _fieldOrder = "msgID line preprocessed";
}

set flag DynModule.

cmodule GPreprocessedLines > DynCRUD<Entry> {
  transient int maxInterpretablesPerLine = 20;
  
  start {
    dbIndexing(Entry, 'msgID);
    addCountToName();
  }
  
  visualize {
    ret withCenteredButtons(super.visualize(), "Full Scan", rThread fullScan);
  }
  
  void fullScan enter {
    new L<Entry> list;
    new Flag interrupted;
    temp AutoCloseable action = dm_currentAction("Scanning chat", rRaiseFlag(interrupted));
    F0<GazelleEvalContext> contextMaker = new GazelleContextCache_v2().fill();
    L<GazelleLine> lines = dm_discord_allLines();
    for (GazelleLine line : iterateOverListSendingPercentage(voidfunc(O percent) { callOpt(action, 'setText, percent + "% - Scanning chat") }, reversed(lines))) {
      if (!licensed() || interrupted!) break;
      scanLine(line, +contextMaker);
    }
  }
  
  void scanLine(GazelleLine line, O... _) {
    new L<Entry> list;
    Collection<GInterpretable> l = takeFirst(maxInterpretablesPerLine, gazelle_preprocess(line.text, _));
    for (GInterpretable intp : l) {
      if (eq(intp.text, line.text)) continue;
      list.add(unlistedWithValues Entry(
        msgID := line.msgID,
        line := line.text,
        preprocessed := intp.text,
        ruleIDs := intp.ruleID));
    }
    replaceItemsForMessage(line.msgID, list);
  }
  
  void replaceItemsForMessage(long msgID, L<Entry> items) {
    deleteConceptsWhere Entry(+msgID);
    registerAll(items);
  }
}

Author comment

Began life as a copy of #1022191

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: #1022283
Snippet name: Gazelle: Preprocessed Chat Lines
Eternal ID of this version: #1022283/9
Text MD5: a417c9aa3b6d29a171ab19287fbce41b
Transpilation MD5: b1625f9a9354005c972790d9ec0d4b4c
Author: stefan
Category: javax / gazelle
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-12 20:41:33
Source code size: 1662 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 239 / 2859
Version history: 8 change(s)
Referenced in: [show references]