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

63
LINES

< > BotCompany Repo | #1021745 // Gazelle: Statement Fulfillments (OLD, use v2 instead!)

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

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

!7

cmodule StatementFulfillments > DynObjectTable<GazelleFulfillment> {
  transient ReliableSingleThread rstSearch = dm_rst(this, r search);
  transient Flag cancel;
  
  transient GazelleContextCache_v2 contextCache;
  
  start {
    set fieldsInOrder;
    addCountToName();
    set withSearcher;
    
    print("Making cache");
    time "Made cache" {
      contextCache = new GazelleContextCache_v2(this);
      contextCache.grabRules = func -> L<T3<S>> { dm_gazelle_rulesOnFacts() };
      ownResource(contextCache.listenToMessages());
      contextCache.fill();
    }

    dm_vmBus_onMessage_q('newDiscordLine, voidfunc(O line) {
      new L<GazelleFulfillment> list;
      gazelle_gatherFulfillments(ll(dm_discord_importLine(line)), list, maxEntries := 100);
      addAll(list);
    });
    
    dm_vmBus_onMessage('gazelleRuleCreated, rstSearch); // TODO: optimize
  }
  
  visualize {
    ret withCenteredButtons(super.visualize(), "Search Chat", rstSearch);
  }
  
  void search {
    new Flag cancel;
    this.cancel = cancel;
    new L<GazelleFulfillment> list;
    
    // "john doe is a guy"
    L<GazelleLine> lines = dm_discord_allLines();
    print("Scanning " + n2(lines, "line"));
    
    gazelle_gatherFulfillments(lines, list, maxEntries := 1000, +cancel, ctx := contextCache!);
    
    print("Scan yielded " + n2(list, "entry", "entries"));
    setList(list);
  }
  
  // API
  
  L<GazelleFulfillment> entriesForRule(S ruleID) {
    ret filterWhere(list(), rule := ruleID);
  }
  
  L<GazelleFulfillment> entriesForContext(S context) {
    ret filterWhere(list(), +context);
  }
  
  void triggerSearch {
    rstSearch.trigger();
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1021745
Snippet name: Gazelle: Statement Fulfillments (OLD, use v2 instead!)
Eternal ID of this version: #1021745/37
Text MD5: f967b907b011508da4a411c237e06c73
Transpilation MD5: e8b3d91c380f3c59673be363125295e9
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: 2019-03-12 21:41:09
Source code size: 1722 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 350 / 1304
Version history: 36 change(s)
Referenced in: [show references]