Libraryless. Click here for Pure Java version (9286L/65K).
1 | !7 |
2 | |
3 | sclass InputGrouper > DynPrintLog { |
4 | InputChooser inputChooser = new(this); |
5 | transient Set<S> phrases; |
6 | transient LS groupings; |
7 | |
8 | start { |
9 | dm_onTopInput(r update); |
10 | } |
11 | |
12 | visualize { |
13 | ret northAndCenter(wrap(inputChooser), super.visualize()); |
14 | } |
15 | |
16 | void update { |
17 | if (inputChooser.update()) { |
18 | S s = inputChooser.input(); |
19 | phrases = getPhrases(); |
20 | S grouped = join(mapCodeTokens curlyBraceIfMoreThanOneToken(ai_tok_combinePhrases(javaTok(s), func(S s) { contains(phrases, s) }))); |
21 | setField(groupings := eq(grouped, s) ? emptyList() : ll(grouped)); |
22 | if (nempty(groupings)) { |
23 | print("Sending groupings"); |
24 | vmBus_send('newInputGroupings, module(), s, groupings); |
25 | } |
26 | print("< " + s); |
27 | print("> " + grouped); |
28 | } |
29 | } |
30 | |
31 | Set<S> getPhrases() { |
32 | Set<S> set = ciSet(); |
33 | set.addAll(collect input((L) dm_requireAndCallModule("#1020901/NounList", 'data))); |
34 | ret set; |
35 | } |
36 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1017160 |
Snippet name: | Grouper [Dyn Module, dev.] |
Eternal ID of this version: | #1017160/11 |
Text MD5: | bff6fc006d388c44b44d61d7c72a6331 |
Transpilation MD5: | 0f2ddc2a73616202b1695b14fe7b8d46 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-01-19 19:03:49 |
Source code size: | 986 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 321 / 664 |
Version history: | 10 change(s) |
Referenced in: | [show references] |