Skip to content

Instantly share code, notes, and snippets.

View aradzinski's full-sized avatar

Aaron Radzinski aradzinski

View GitHub Profile
package org.nlpcraft.examples.lightswitch;
import org.junit.jupiter.api.*;
import org.nlpcraft.common.*;
import org.nlpcraft.model.test.*;
import java.io.*;
import static org.junit.jupiter.api.Assertions.*;
class LightSwitchTest {
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.
@aradzinski
aradzinski / lightswitch_model.yml
Created July 16, 2019 17:39
LightSwich Model
id: "nlpcraft.lightswitch.ex"
name: "Light Switch Example Model"
version: "1.0"
description: "NLI-powered light switch example model."
macros:
- name: "<ACTION>"
macro: "{turn|switch|dial|control|let|set|get|put}"
- name: "<ENTIRE_OPT>"
macro: "{entire|full|whole|total|*}"
- name: "<LIGHT>"