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

49
LINES

< > BotCompany Repo | #1010980 // "Peephole" Chat Analysis v2, make webs [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (15919L/112K).

!7

p {
  L<Pair<WebNode>> nodePairs = chatHistory_peepHole_nodePairs();
  print("Have " + n(nodePairs, "node pair"));
  
  // Analysis
  
  new MultiMap<S, WebNode> index; // left text to right node
  
  for (Pair<WebNode> p : nodePairs) {
    L<S> texts = web_texts(p.a);
    for (S text : texts)
      index.setPut(text, p.b);
  }
  print("Index size: " + index.keysSize() + " / " + index.size());
  
  MultiSet<S> ms = multiMapAsMultiSet(index);
  
  new L<Web> outWebs;
  
  for (S key : ms.highestFirst()) {
    L<WebNode> nodes = index.get(key);
    if (l(nodes) < 2) continue;
    
    print(l(nodes) + " - testing key " + key);
    L<S> common = web_commonTexts(nodes);
    LL<S> l = map web_texts(nodes);
    if (nempty(common)) {
      print("  Always: " + common);
      outWebs.add(webFromTriples2(key, ll("then", "checked " + n(nodes, "time")), common));
      for (L x : l ) x.removeAll(common);
    }
    //Pair<S, Int> p = web_mostCommonTextWithCount(nodes);
    Pair<S, Int> p = mostCommonWithCount(l);
    if (p != null && p.b > 1) {
      int percent = ratioToIntPercent(p.b, l(nodes));
      print("  Often (" + percent + "%): " + p.a + " (" + p.b + ")");
      outWebs.add(webFromTriples2(key, ll("then maybe", "(" + p.b + "/" + n(nodes, "time") + ")"), p.a));
    }
  }
  
  print("Made " + n(outWebs, "out web"));
  //showWeb(last(outWebs));
  if (isMain())
    showWeb(firstWebContaining(outWebs, "then maybe"));
  
  saveGZStructure("peephole-webs.structure.gz", outWebs);
}

Author comment

Began life as a copy of #1010968

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: #1010980
Snippet name: "Peephole" Chat Analysis v2, make webs [OK]
Eternal ID of this version: #1010980/18
Text MD5: 316f48d1354393aa49cea3b72541f9ae
Transpilation MD5: 94c221907bd2510614840ba9a3ecf523
Author: stefan
Category: javax / chat
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-11 02:23:07
Source code size: 1548 bytes / 49 lines
Pitched / IR pitched: No / No
Views / Downloads: 711 / 2223
Version history: 17 change(s)
Referenced in: #1010745 - Smart Bot (LIVE)
#1010989 - ai_chatAnalysis_peepHoleFile
#1011666 - Smart Bot with WebNode v3 (dev.)