!7 module CorrectRecognizedSpeech > DynPrintLog { Map> corrections = syncCIMap(); start { ownResource(watchStructureLog_fromStart(speechConfirmationLogFile(), voidfunc(O o) { if (o cast Map) { S heard = getString(o, 'heard), corrected = getString(o, 'corrected); if (empty(heard) || empty(corrected) || eqic(heard, corrected)) ret; MultiSet ms; synchronized(corrections) { ms = corrections.get(heard); if (ms == null) corrections.put(heard, ms = new MultiSet); } ms.add(corrected); } })); ownResource(onSpeechRecognized_withoutMyUtterancesAndTyped(voidfunc(fS s) enter { MultiSet ms = corrections.get(s); if (ms == null) ret; S corrected = ms.getMostPopularEntry(); if (nempty(corrected)) infoBox("Proposing correction: " + corrected); })); } }