!7 sS phrases = [[ United States of America God save the queen Bed & Breakfast ]]; sS inputs = [[ United States of Incarceration God shave the queen Bed & Butter ]]; // Gazelle-style program sS rule = [[ $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; Set phrases = asCISet(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 ping (PairS temp1 : singletonUnlessNull(gazelle_singleChangedWord($y, $x))) { S $old, $new = unpair temp1; for ping (S $capitalized : singletonUnlessNull(capitalizeWord($y, $old))) { emit(format("No no no. \*$capitalized*/!")); } } } } } } void process(S input) { temp tempSetTL(emit_print_prefix, "[Bot] "); pcallF(setAll(new Engine, input := nlPrint("[User] ", input))); } start-thread { for (S input : tlft(inputs)) process(input); dm_onTopInput_q(voidfunc(S s) { if (enabled) process(s) }); } }