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).

1  
!7
2  
3  
cmodule StatementFulfillments > DynObjectTable<GazelleFulfillment> {
4  
  transient ReliableSingleThread rstSearch = dm_rst(this, r search);
5  
  transient Flag cancel;
6  
  
7  
  transient GazelleContextCache_v2 contextCache;
8  
  
9  
  start {
10  
    set fieldsInOrder;
11  
    addCountToName();
12  
    set withSearcher;
13  
    
14  
    print("Making cache");
15  
    time "Made cache" {
16  
      contextCache = new GazelleContextCache_v2(this);
17  
      contextCache.grabRules = func -> L<T3<S>> { dm_gazelle_rulesOnFacts() };
18  
      ownResource(contextCache.listenToMessages());
19  
      contextCache.fill();
20  
    }
21  
22  
    dm_vmBus_onMessage_q('newDiscordLine, voidfunc(O line) {
23  
      new L<GazelleFulfillment> list;
24  
      gazelle_gatherFulfillments(ll(dm_discord_importLine(line)), list, maxEntries := 100);
25  
      addAll(list);
26  
    });
27  
    
28  
    dm_vmBus_onMessage('gazelleRuleCreated, rstSearch); // TODO: optimize
29  
  }
30  
  
31  
  visualize {
32  
    ret withCenteredButtons(super.visualize(), "Search Chat", rstSearch);
33  
  }
34  
  
35  
  void search {
36  
    new Flag cancel;
37  
    this.cancel = cancel;
38  
    new L<GazelleFulfillment> list;
39  
    
40  
    // "john doe is a guy"
41  
    L<GazelleLine> lines = dm_discord_allLines();
42  
    print("Scanning " + n2(lines, "line"));
43  
    
44  
    gazelle_gatherFulfillments(lines, list, maxEntries := 1000, +cancel, ctx := contextCache!);
45  
    
46  
    print("Scan yielded " + n2(list, "entry", "entries"));
47  
    setList(list);
48  
  }
49  
  
50  
  // API
51  
  
52  
  L<GazelleFulfillment> entriesForRule(S ruleID) {
53  
    ret filterWhere(list(), rule := ruleID);
54  
  }
55  
  
56  
  L<GazelleFulfillment> entriesForContext(S context) {
57  
    ret filterWhere(list(), +context);
58  
  }
59  
  
60  
  void triggerSearch {
61  
    rstSearch.trigger();
62  
  }
63  
}

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: 422 / 1398
Version history: 36 change(s)
Referenced in: [show references]