Download Jar. Uses 3874K of libraries. Click here for Pure Java version (10868L/76K).
1 | !7 |
2 | |
3 | static int maxWords = 100000, topTenSize = 10; |
4 | static int maxWordLength = 100; |
5 | static MultiSetAndTopTen<S> mstt; |
6 | |
7 | p-subst { |
8 | tt(); centerHigherConsole(); saveConceptsQuietly(); |
9 | load('topTenSize); |
10 | |
11 | mstt = new MultiSetAndTopTen( |
12 | l_persistentTreeMap("Words + count"), |
13 | l_persistentList("Top Ten")); |
14 | |
15 | mstt.maxEntries = maxWords; |
16 | mstt.topTenTargetLength = topTenSize; |
17 | mstt.printTopTen(); |
18 | showControls(jcenteredline(jbutton("Show Text Area", f showTextArea))); |
19 | botIfMain(); |
20 | } |
21 | |
22 | svoid addWordHits(Collection<S> words) { |
23 | lock dbLock(); |
24 | for (S word : words) |
25 | mstt.add(shorten(word, maxWordLength)); |
26 | } |
27 | |
28 | svoid processText(S s) { |
29 | logQuoted("texts-posted.log", now() + " | " + s); |
30 | addWordHits(words2(s)); mstt.printTopTen(); |
31 | } |
32 | |
33 | answer { |
34 | if "top *" { topTenSize = parseInt($1); save('topTenSize); mstt.newTopTen(topTenSize); mstt.printTopTen(); ret "OK"; } |
35 | if "all alphabetic" { showTableWithSearcher(mstt.ms, "Alphabetic with count"); ret "OK"; } |
36 | processText(s); try answer "OK"; |
37 | } |
38 | |
39 | svoid showTextArea swing { |
40 | final JTextArea ta = jwordwraptextarea(); |
41 | showFrame(centerAndSouth(ta, jcenteredline(jbutton("Save words", r { processText(getText(ta)); disposeFrame(ta) })))); |
42 | } |
Began life as a copy of #1009450
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009456 |
Snippet name: | Word Collector with new MultiSetAndTopTen |
Eternal ID of this version: | #1009456/9 |
Text MD5: | 47f5502a4cceab4e9cbda132e25fad94 |
Transpilation MD5: | 9da949d74c6eede317ccf029d16323a7 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-09-27 16:34:51 |
Source code size: | 1252 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 553 / 1160 |
Version history: | 8 change(s) |
Referenced in: | [show references] |