Uses 911K of libraries. Click here for Pure Java version (14869L/82K).
!7 concept Entry { S keyword, code; bool enabled = true; sS _fieldOrder = "keyword code enabled"; } set flag DynModule. cmodule KeywordToCode > DynCRUD<Entry> { afterVisualize { tablePopupMenuItemThreaded(table(), "Run", r { runEntry(selected(), "") }); } start { db(); dm_onTopInput(voidfunc(fS s) { thread { //print("KtC got: " + s); for (Entry e : list(Entry)) if (e.enabled && matchMethod(e.keyword, s)) runEntry(e, s); } }); } void runEntry(Entry e, S input) enter { if (e == null) ret; print("KtC running #" + e.id); S code = trim(e.code); bool say = startsWith(code, "="); if (say) code = substring(code, 1); try { temp tempSetTL(evalJava_prep_args, "fS s"); O result = dm_evalJava_withModule(code, input); if (say) dm_say(strOrNull(result)); } catch print _e { if (say) dm_say("Internal error, Sir"); } } // API bool matchMethod(S pat, S s) { ret matchX_vbar(pat, s); } bool isVoiceCommand(S s) { for (Entry e : list(Entry)) if (e.enabled && matchMethod(e.keyword, s)) true; false; } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
| Snippet ID: | #1018993 |
| Snippet name: | Voice Commands [formerly: "Keyword To Code"] |
| Eternal ID of this version: | #1018993/41 |
| Text MD5: | c1dc583a653cb240439ec3e14db66f90 |
| Transpilation MD5: | 757edcbd5374d5766788d5bbe72f7404 |
| Author: | stefan |
| Category: | javax / a.i. / gui |
| Type: | JavaX source code (Dynamic Module) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-01-18 22:56:30 |
| Source code size: | 1245 bytes / 56 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 969 / 12637 |
| Version history: | 40 change(s) |
| Referenced in: | #1019282 - DynCRUD - CRUD as Dyn Module #1026677 - dm_voiceCommandsCRUD |