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

!7

concept GFulfillment {
  !include #1022288
}

cmodule StatementFulfillments > DynCRUD<GFulfillment> {
  transient ReliableSingleThread rstSearch = dm_rst(this, r search);
  transient Flag cancel;
  
  transient GazelleContextCache_v2 contextCache;
  
  start {
    addCountToName();

    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);
      toConcepts(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!);
    
    L preprocessed = cast dm_call(gazelle_preprocessedLinesCRUD(), 'concepts);
    L<GazelleLine> preprocessedLines = map gazelle_importPreprocessedLine(preprocessed);
    new L<GazelleFulfillment> list2;
    gazelle_gatherFulfillments(preprocessedLines, list2, maxEntries := 1000, +cancel, ctx := contextCache!);
    for (GazelleFulfillment f : list2)
      f.context += " (preprocessed)";
    
    print("Scan yielded " + n2(list, "entry", "entries"));
    deleteConcepts(GFulfillment);
    toConcepts(list);
    toConcepts(list2);
  }
  
  void toConcepts(L<GazelleFulfillment> l) {
    Collection<S> fields = conceptFields(GFulfillment);
    if (l != null) for (GazelleFulfillment f : l) {
      GFulfillment c = ccopyFields2_fromGen(f, new GFulfillment, fields);
      assertSame(c._concepts, conceptsObject());
    }
  }

  // API
  
  L<GFulfillment> entriesForRule(S ruleID) {
    ret conceptsWhere GFulfillment(rule := ruleID);
  }
  
  L<GFulfillment> entriesForContext(S context) {
    ret conceptsWhere GFulfillment(+context);
  }
  
  void triggerSearch {
    rstSearch.trigger();
  }
}

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: 264 / 5673
Version history: 8 change(s)
Referenced in: [show references]