Uses 911K of libraries. Click here for Pure Java version (8212L/41K).
!7 srecord Replacement(S in, S out) { // in = heard phrase, out = said phrase } cmodule ELEApplyRecognitionReplacements > ELESuggester { void process_impl(S input) { L<Replacement> l = getReplacements(); SS map = ciMapFromKeyAndValueField('in, 'out, l); FullPhraseCache phraseCache = makeFullPhraseCache(map(l, r -> r.in)); LS tok = javaTokNPunct(input); L<IntRange> 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<Replacement> getReplacements() { L l = dm_getConcepts(dm_require("#1026379/ELERecognitionReplacements")); ret shallowCloneListToClass Replacement(l); } }
Began life as a copy of #1026379
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1026395 |
Snippet name: | ELE: Apply Recognition Replacements [dev.] |
Eternal ID of this version: | #1026395/9 |
Text MD5: | 4e3de1d1bbb600bb3568013a5f797ec6 |
Transpilation MD5: | 9c14e71ae8ac0d80f4c5c1b20915ffdd |
Author: | stefan |
Category: | javax / speech recognition |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-01-22 14:57:36 |
Source code size: | 1141 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 246 / 568 |
Version history: | 8 change(s) |
Referenced in: | -