idiolect
idiolect copied to clipboard
Add more slots to `command.gram` and re-use Intent logic in `idear-lambda`
As I work through the commands in ASRControlLoop and convert to code for Lambda it occurred to me that a better way of going forward would to adapt the CMU Sphinx impl to re-use the logic that I'm writing for Lambda.
There are a couple of patterns which use slots, eg:
<jump_command> = jump <number> | end of line | beginning of line;
but fun applyAction(c: String): Any ignores the slot values.
Example - OpenView
class OpenView(val slots: Map<String, String>?): Intent {
override fun handleRequest(): LexFulfillmentResponse {
val view = slots?.get("View")
return when (view) {
"settings" -> openView(view, "ShowSettings")
"recent", "recent files" -> openView(view, "RecentFiles")
"terminal" -> openView(view, "ActivateTerminalToolWindow")
else -> elicitSlot(this.javaClass.simpleName!!,
"View",
"I know how to open \"settings\", \"recent files\" and the \"terminal\"")
}
}
private fun openView(view: String, action: String): LexFulfillmentResponse {
return fulfilled("opening" + view, mapOf("invokeAction" to action))
}
}