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

56
LINES

< > BotCompany Repo | #1010968 // "Peephole" Chat Analysis v1 [OK]

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

Download Jar. Libraryless. Click here for Pure Java version (10739L/70K).

1  
!7
2  
3  
p {
4  
  ILister lister = persistentListerReadOnly(chatTheoryModule());
5  
  L<S> msgs = lister.getList('globalIDList);
6  
  Map<S, Web> webs = lister.getHashMap('theoryForLineMap);
7  
  print("Have " + n(countNotNull(msgs), "msg") + ", " + n(webs, "web"));
8  
  //print("Missing msgs: " + elementsNotInMap(notNullOnly(msgs), webs));
9  
  //print("Extra webs: " + listMinusSet(keys(webs), msgs));
10  
  
11  
  new L<Pair<WebNode>> nodePairs;
12  
  
13  
  for (int i = 1; i+1 < l(msgs); i++) {
14  
    S id1 = msgs.get(i), id2 = msgs.get(i+1);
15  
    if (id1 == null || id2 == null) continue;
16  
    Web a = webs.get(id1);
17  
    Web b = webs.get(id2);
18  
    if (a == null || b == null) {
19  
      print("Missing webs at " + i);
20  
      continue;
21  
    }
22  
    //print("Have " + web_firstNode(a));
23  
    nodePairs.add(pair(web_firstNode(a), web_firstNode(b)));
24  
  }
25  
  
26  
  print("Have " + n(nodePairs, "node pair"));
27  
  
28  
  // Analysis
29  
  
30  
  new MultiMap<S, WebNode> index; // left text to right node
31  
  
32  
  for (Pair<WebNode> p : nodePairs) {
33  
    L<S> texts = web_texts(p.a);
34  
    for (S text : texts)
35  
      index.setPut(text, p.b);
36  
  }
37  
  print("Index size: " + index.keysSize() + " / " + index.size());
38  
  
39  
  MultiSet<S> ms = multiMapAsMultiSet(index);
40  
  
41  
  for (S key : ms.highestFirst()) {
42  
    L<WebNode> nodes = index.get(key);
43  
    if (l(nodes) < 2) continue;
44  
    
45  
    print(l(nodes) + " - testing key " + key);
46  
    L<S> common = web_commonTexts(nodes);
47  
    LL<S> l = map web_texts(nodes);
48  
    if (nempty(common)) {
49  
      print("  Always: " + common);
50  
      for (L x : l ) x.removeAll(common);
51  
    }
52  
    //Pair<S, Int> p = web_mostCommonTextWithCount(nodes);
53  
    Pair<S, Int> p = mostCommonWithCount(l);
54  
    if (p != null && p.b > 1) print("  Often: " + p.a + " (" + p.b + ")");
55  
  }
56  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1010968
Snippet name: "Peephole" Chat Analysis v1 [OK]
Eternal ID of this version: #1010968/21
Text MD5: c180cf6663876f3ba3be83577b85b76b
Transpilation MD5: a404ec9f707f1a5c95220d41e59f6a09
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-10 20:28:58
Source code size: 1777 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 501 / 1163
Version history: 20 change(s)
Referenced in: [show references]