!7 sS phrases = [[ United States of America God save the queen Bed and Breakfast ]]; sS inputs = [[ United States of Incarceration God shave the queen Bed and Butter ]]; /* Gazelle-style program (just for illustration): $x is said + $y is a phrase + $old, $new = gazelle_singleChangedWord($y, $x) + $capitalized = capitalizeWord($y, $old) => No no no. $capitalized! */ cmodule PhraseCorrector > DynPrintLogAndEnabled { class Engine implements Runnable { S input; LS phrases = tlft(main.phrases); Collection iterate__$x_is_said() { ret singletonUnlessNull(input); } Collection iterate__$y_is_a_phrase() { ret phrases; } // Gazelle-style program translated to JavaX: run { for ping (S $x : iterate__$x_is_said()) { for ping (S $y : iterate__$y_is_a_phrase()) { for single (unpair S $old, $new : gazelle_singleChangedWord($y, $x)) { for single (S $capitalized : capitalizeWord($y, $old)) { emit("No no no. \*$capitalized*/!"); } } } } } } void process(S input, bool speak) { temp tempSetTL(emit_print_prefix, "[Bot] "); temp speak ? tempSetTL(emit_onEmit, ll(vf dm_say)) : null; pcallF(setAll(new Engine, input := nlPrint("[User] ", input))); } start-thread { for (S input : tlft(inputs)) process(input, false); dm_onTopInput_q(voidfunc(S s) { if (enabled) process(s, true) }); } }