!7 sclass InputGrouper > DynPrintLog { InputChooser inputChooser = new(this); transient Set phrases; transient LS groupings; start { dm_onTopInput(r update); } visualize { ret northAndCenter(wrap(inputChooser), super.visualize()); } void update { if (inputChooser.update()) { S s = inputChooser.input(); phrases = getPhrases(); S grouped = join(mapCodeTokens curlyBraceIfMoreThanOneToken(ai_tok_combinePhrases(javaTok(s), func(S s) { contains(phrases, s) }))); setField(groupings := eq(grouped, s) ? emptyList() : ll(grouped)); if (nempty(groupings)) { print("Sending groupings"); vmBus_send('newInputGroupings, module(), s, groupings); } print("< " + s); print("> " + grouped); } } Set getPhrases() { Set set = ciSet(); set.addAll(collect input((L) dm_requireAndCallModule("#1020901/NounList", 'data))); ret set; } }