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

82
LINES

< > BotCompany Repo | #1022289 // Gazelle: Statement Fulfillments v2 [as CRUD]

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

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

1  
!7
2  
3  
concept GFulfillment {
4  
  !include #1022288
5  
}
6  
7  
cmodule StatementFulfillments > DynCRUD<GFulfillment> {
8  
  transient ReliableSingleThread rstSearch = dm_rst(this, r search);
9  
  transient Flag cancel;
10  
  
11  
  transient GazelleContextCache_v2 contextCache;
12  
  
13  
  start {
14  
    addCountToName();
15  
16  
    print("Making cache");
17  
    time "Made cache" {
18  
      contextCache = new GazelleContextCache_v2(this);
19  
      contextCache.grabRules = func -> L<T3<S>> { dm_gazelle_rulesOnFacts() };
20  
      ownResource(contextCache.listenToMessages());
21  
      contextCache.fill();
22  
    }
23  
24  
    dm_vmBus_onMessage_q('newDiscordLine, voidfunc(O line) {
25  
      new L<GazelleFulfillment> list;
26  
      gazelle_gatherFulfillments(ll(dm_discord_importLine(line)), list, maxEntries := 100);
27  
      toConcepts(list);
28  
    });
29  
    
30  
    dm_vmBus_onMessage('gazelleRuleCreated, rstSearch); // TODO: optimize
31  
  }
32  
  
33  
  visualize {
34  
    ret withCenteredButtons(super.visualize(), "Search Chat", rstSearch);
35  
  }
36  
  
37  
  void search {
38  
    new Flag cancel;
39  
    this.cancel = cancel;
40  
    new L<GazelleFulfillment> list;
41  
    
42  
    // "john doe is a guy"
43  
    L<GazelleLine> lines = dm_discord_allLines();
44  
    print("Scanning " + n2(lines, "line"));
45  
    
46  
    gazelle_gatherFulfillments(lines, list, maxEntries := 1000, +cancel, ctx := contextCache!);
47  
    
48  
    L preprocessed = cast dm_call(gazelle_preprocessedLinesCRUD(), 'concepts);
49  
    L<GazelleLine> preprocessedLines = map gazelle_importPreprocessedLine(preprocessed);
50  
    new L<GazelleFulfillment> list2;
51  
    gazelle_gatherFulfillments(preprocessedLines, list2, maxEntries := 1000, +cancel, ctx := contextCache!);
52  
    for (GazelleFulfillment f : list2)
53  
      f.context += " (preprocessed)";
54  
    
55  
    print("Scan yielded " + n2(list, "entry", "entries"));
56  
    deleteConcepts(GFulfillment);
57  
    toConcepts(list);
58  
    toConcepts(list2);
59  
  }
60  
  
61  
  void toConcepts(L<GazelleFulfillment> l) {
62  
    Collection<S> fields = conceptFields(GFulfillment);
63  
    if (l != null) for (GazelleFulfillment f : l) {
64  
      GFulfillment c = ccopyFields2_fromGen(f, new GFulfillment, fields);
65  
      assertSame(c._concepts, conceptsObject());
66  
    }
67  
  }
68  
69  
  // API
70  
  
71  
  L<GFulfillment> entriesForRule(S ruleID) {
72  
    ret conceptsWhere GFulfillment(rule := ruleID);
73  
  }
74  
  
75  
  L<GFulfillment> entriesForContext(S context) {
76  
    ret conceptsWhere GFulfillment(+context);
77  
  }
78  
  
79  
  void triggerSearch {
80  
    rstSearch.trigger();
81  
  }
82  
}

Author comment

Began life as a copy of #1021745

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: #1022289
Snippet name: Gazelle: Statement Fulfillments v2 [as CRUD]
Eternal ID of this version: #1022289/9
Text MD5: f1a93d18ae89f374aa0c832cd6baa68f
Transpilation MD5: 7a68d4d6fa313e84016edd6d2056640e
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:43:47
Source code size: 2474 bytes / 82 lines
Pitched / IR pitched: No / No
Views / Downloads: 338 / 5766
Version history: 8 change(s)
Referenced in: [show references]