Uses 408K of libraries. Click here for Pure Java version (15445L/108K).
1 | !7 |
2 | |
3 | sclass DialogTree > DynModule { |
4 | new Node root; |
5 | transient JTree tree; |
6 | |
7 | class Node { |
8 | LS text; |
9 | new LinkedHashMap<LS, Node> children; |
10 | |
11 | // flag |
12 | final static int |
13 | funny = 1, |
14 | correctSentence = 2, |
15 | probablyMine = 4; |
16 | |
17 | int flags; |
18 | S language; |
19 | S correctIf; |
20 | |
21 | *() {} |
22 | *(LS *text) {} |
23 | |
24 | toString { |
25 | ret text == null ? "<ROOT>" : joinWithSpace(text); |
26 | } |
27 | |
28 | Node getOrCreate(LS text) { |
29 | ret pairA(getOrCreate2(text)); |
30 | } |
31 | |
32 | Pair<Node, Bool> getOrCreate2(LS text) { |
33 | temp enter(); |
34 | Node n = children.get(text); |
35 | bool isNew = n == null; |
36 | if (isNew) { |
37 | children.put(text, n = new Node(text)); |
38 | change(); |
39 | } |
40 | ret pair(n, isNew); |
41 | } |
42 | } |
43 | |
44 | void start { |
45 | addCatLogToRoot(); |
46 | onSpeechRecognized_withoutMyUtterances(voidfunc(fS s) { |
47 | swing { |
48 | Pair<Node, Bool> child = root.getOrCreate2(words(s)); |
49 | if (child.b) // it's a new child |
50 | jDynamicTree_addToNodeAndScroll(tree, root, child.a); |
51 | } |
52 | }); |
53 | } |
54 | |
55 | JComponent visualize() { |
56 | ret tree = jDynTree(root, func(Node n) -> L<Node> { |
57 | temp enter(); |
58 | ret valuesList(n.children); |
59 | }); |
60 | } |
61 | |
62 | void addCatLogToRoot { |
63 | for (LS text : catLog_wordLists()) |
64 | root.getOrCreate(text); |
65 | } |
66 | } |
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: | #1016799 |
Snippet name: | Dialog Tree v1 [Dyn Module] |
Eternal ID of this version: | #1016799/22 |
Text MD5: | f7fa6718e3fd22bda82521127e8f1d5b |
Transpilation MD5: | 38cc1e184144e3d4d5867b6408c6a498 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-07-05 13:37:27 |
Source code size: | 1390 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 550 / 1693 |
Version history: | 21 change(s) |
Referenced in: | [show references] |