Libraryless. Click here for Pure Java version (1270L/9K/28K).
1 | !752 |
2 | |
3 | answer { |
4 | exceptionToUser { |
5 | if (!tb()) null; |
6 | |
7 | if "how many lines" |
8 | ret lstr(getLog()); |
9 | |
10 | if "how many users" |
11 | ret lstr(getUsers()); |
12 | |
13 | if "how many different words" |
14 | ret lstr(getWords()); |
15 | |
16 | if "some users" |
17 | ret some(getUsers()); |
18 | |
19 | if "some words" |
20 | ret some(getWords()); |
21 | |
22 | if "longest message" |
23 | ret shorten(longest(getTexts()), 100); |
24 | } |
25 | } |
26 | |
27 | static L getLog() { |
28 | ret getTBLog(); |
29 | } |
30 | |
31 | static Set<S> getUsers() { |
32 | ret asTreeSet(collectField(getLog(), "userName")); |
33 | } |
34 | |
35 | static L<S> getTexts() { |
36 | ret collectField(getLog(), "text"); |
37 | } |
38 | |
39 | static Set<S> getWords() { |
40 | L<S> lines = getTexts(); |
41 | new TreeSet<S> set; |
42 | for (S text : lines) { |
43 | for (S t : codeTokens(nlTok(text))) { |
44 | if (isExtendedIdentifier(t)) |
45 | set.add(t.toLowerCase()); |
46 | } |
47 | } |
48 | ret set; |
49 | } |
50 | |
51 | static S some(Collection<S> c) { |
52 | ret join(" ", selectRandom(asList(c), 10)); |
53 | } |
54 | |
55 | static S longest(L<S> l) { |
56 | new Map<S, Integer> map; |
57 | for (S s : l) |
58 | map.put(s, l(s)); |
59 | ret highest(map); |
60 | } |
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: | #1002988 |
Snippet name: | Log Analysis (#talkingbots) |
Eternal ID of this version: | #1002988/1 |
Text MD5: | e633dcdd1937b89ff6e9bb76b902c8aa |
Transpilation MD5: | b1f858be37808703126a3b19204aa6f7 |
Author: | stefan |
Category: | eleu / nl |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-04-17 22:02:05 |
Source code size: | 1114 bytes / 60 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 766 / 848 |
Referenced in: | [show references] |