!7 srecord Replacement(S in, S out) { // in = heard phrase, out = said phrase } cmodule ELEApplyRecognitionReplacements > ELESuggester { void process_impl(S input) { L l = getReplacements(); SS map = ciMapFromKeyAndValueField('in, 'out, l); FullPhraseCache phraseCache = makeFullPhraseCache(map(l, r -> r.in)); LS tok = javaTokNPunct(input); L ranges = fullPhraseCache_tokenRanges(phraseCache, tok); if (empty(ranges)) ret; print("Found replaceable phrases: " + getJoinedTokenRangesWithoutN(tok, ranges)); tok = cloneList(tok); for (IntRange r : ranges) { S in = joinSubList(tok, r); S replaced = map.get(in); if (replaced == null) continue with print("punctuation problem with " + quote(in)); replaceTokens(tok, r.start, r.end, replaced); } S s = join(tok); print("All replacements applied: " + s); showSuggestions(input, ll(s)); } L getReplacements() { L l = dm_getConcepts(dm_require("#1026379/ELERecognitionReplacements")); ret shallowCloneListToClass Replacement(l); } }