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

50
LINES

< > BotCompany Repo | #1012051 // AI_SubSpace (phased out in favor of ActualThoughtSpace)

JavaX fragment (include)

sclass AI_SubSpace implements AI_PostHandler, AI_CacheChecker {
  int limit;
  new MultiMap<Symbol, WebNode> index;
  new HashMap<GlobalID, Web> websByID;
  new L<Web> webs;
  bool changed;
  
  *() {}
  *(int *limit) {}
  
  // existence of triple has already been checked
  public GlobalID postTriple(T3<Symbol> t) {
    if (limitReached()) fail("Subspace limit reached");
    Web web = webFromTriple(t);
    web.source = ai_currentMaker();
    addWeb(web);
    ret web.globalIDObj();
  }
  
  public GlobalID postTriple(T3<Symbol> t, bool verified) {
    ret postTriple(t); // XXX
  }
  
  void addWeb(Web web) {
    websByID.put(web.globalIDObj(), web);
    webs.add(web);
    changed = true;
    for (WebNode node : web_nodesAndRelations(web))
      for (S text : asSet(node.texts())) 
        index.put(symbol(ai_shortenForIndex(text)), node);
  }
  
  public bool hasTriple(Symbol a, Symbol b, Symbol c) {
    L<Web> webs = ai_withoutInvalidWebs(nodesToWebs(shortestList3(
      index.get(a),
      index.get(b),
      index.get(c))));
    ret webs_search_noVar_bool(webFromTriple(a, b, c), webs);
  }
  
  bool limitReached() {
    ret limit > 0 && l(websByID) >= limit;
  }
  
  L<WebNode> indexedNodes_rawLookup(Symbol s) {
    ret index.get(ai_shortenForIndex(s));
  }
  
  int numWebs() { ret l(websByID); }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1012051
Snippet name: AI_SubSpace (phased out in favor of ActualThoughtSpace)
Eternal ID of this version: #1012051/23
Text MD5: 3fcaf307c0e4efd6d4756a2eb60e8aec
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-16 13:58:33
Source code size: 1370 bytes / 50 lines
Pitched / IR pitched: No / No
Views / Downloads: 462 / 1081
Version history: 22 change(s)
Referenced in: [show references]