Download Jar. Libraryless. Click here for Pure Java version (15919L/112K).
1 | !7 |
2 | |
3 | p { |
4 | L<Pair<WebNode>> nodePairs = chatHistory_peepHole_nodePairs(); |
5 | print("Have " + n(nodePairs, "node pair")); |
6 | |
7 | // Analysis |
8 | |
9 | new MultiMap<S, WebNode> index; // left text to right node |
10 | |
11 | for (Pair<WebNode> p : nodePairs) { |
12 | L<S> texts = web_texts(p.a); |
13 | for (S text : texts) |
14 | index.setPut(text, p.b); |
15 | } |
16 | print("Index size: " + index.keysSize() + " / " + index.size()); |
17 | |
18 | MultiSet<S> ms = multiMapAsMultiSet(index); |
19 | |
20 | new L<Web> outWebs; |
21 | |
22 | for (S key : ms.highestFirst()) { |
23 | L<WebNode> nodes = index.get(key); |
24 | if (l(nodes) < 2) continue; |
25 | |
26 | print(l(nodes) + " - testing key " + key); |
27 | L<S> common = web_commonTexts(nodes); |
28 | LL<S> l = map web_texts(nodes); |
29 | if (nempty(common)) { |
30 | print(" Always: " + common); |
31 | outWebs.add(webFromTriples2(key, ll("then", "checked " + n(nodes, "time")), common)); |
32 | for (L x : l ) x.removeAll(common); |
33 | } |
34 | //Pair<S, Int> p = web_mostCommonTextWithCount(nodes); |
35 | Pair<S, Int> p = mostCommonWithCount(l); |
36 | if (p != null && p.b > 1) { |
37 | int percent = ratioToIntPercent(p.b, l(nodes)); |
38 | print(" Often (" + percent + "%): " + p.a + " (" + p.b + ")"); |
39 | outWebs.add(webFromTriples2(key, ll("then maybe", "(" + p.b + "/" + n(nodes, "time") + ")"), p.a)); |
40 | } |
41 | } |
42 | |
43 | print("Made " + n(outWebs, "out web")); |
44 | //showWeb(last(outWebs)); |
45 | if (isMain()) |
46 | showWeb(firstWebContaining(outWebs, "then maybe")); |
47 | |
48 | saveGZStructure("peephole-webs.structure.gz", outWebs); |
49 | } |
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: | 712 / 2226 |
Version history: | 17 change(s) |
Referenced in: | [show references] |