!7 sclass DialogTree > DynModule { new Node root; transient JTree tree; class Node { LS text; new LinkedHashMap children; // flag final static int funny = 1, correctSentence = 2, probablyMine = 4; int flags; S language; S correctIf; *() {} *(LS *text) {} toString { ret text == null ? "" : joinWithSpace(text); } Node getOrCreate(LS text) { ret pairA(getOrCreate2(text)); } Pair getOrCreate2(LS text) { temp enter(); Node n = children.get(text); bool isNew = n == null; if (isNew) { children.put(text, n = new Node(text)); change(); } ret pair(n, isNew); } } void start { addCatLogToRoot(); onSpeechRecognized_withoutMyUtterances(voidfunc(fS s) { swing { Pair child = root.getOrCreate2(words(s)); if (child.b) // it's a new child jDynamicTree_addToNodeAndScroll(tree, root, child.a); } }); } JComponent visualize() { ret tree = jDynTree(root, func(Node n) -> L { temp enter(); ret valuesList(n.children); }); } void addCatLogToRoot { for (LS text : catLog_wordLists()) root.getOrCreate(text); } }