Skip to content

Instantly share code, notes, and snippets.

@aradzinski
Created July 16, 2019 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aradzinski/79a53440e527ed7d065d56b79114becc to your computer and use it in GitHub Desktop.
Save aradzinski/79a53440e527ed7d065d56b79114becc to your computer and use it in GitHub Desktop.
class LightSwitchModel extends NCModelFileAdapter("org/nlpcraft/examples/lightswitch/lightswitch_model.yaml") {
@NCIntent("id=act conv=false term(act)={groups @@ 'act'} term(loc)={id == 'ls:loc'}*")
def onMatch(
@NCIntentTerm("act") actTok: NCToken,
@NCIntentTerm("loc") locToks: List[NCToken]
): NCQueryResult = {
val status = if (actTok.getId == "ls:on") "on" else "off"
val locations = if (locToks.isEmpty) "entire house" else locToks.map(getOriginalText).mkString(", ")
// Add HomeKit, Arduino or other integration here.
// By default - just return a descriptive action string.
NCQueryResult.text(s"Lights '$status' in '${locations.toLowerCase}'.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment