You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/07/18 22:07:22 UTC
[incubator-nlpcraft] branch master updated: Improved LightSwitch
example.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master by this push:
new 7893028 Improved LightSwitch example.
7893028 is described below
commit 789302823268a0fdbc278e1eb41d1208bdb7a01e
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sun Jul 18 15:07:10 2021 -0700
Improved LightSwitch example.
---
.../apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy | 2 +-
.../org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java | 2 +-
.../org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt | 2 +-
.../apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
index 67788fb..55d2393 100644
--- a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
+++ b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
@@ -65,7 +65,7 @@ class LightSwitchGroovyModel extends NCModelFileAdapter {
@NCIntentTerm("act") NCToken actTok,
@NCIntentTerm("loc") List<NCToken> locToks) {
String status = actTok.id == "ls:on" ? "on" : "off"
- String locations = locToks ? locToks.collect{ it.meta("nlpcraft:nlp:origtext") }.join(", ") : "entire house"
+ String locations = locToks ? locToks.collect{ it.getOriginalText() }.join(", ") : "entire house"
// Add HomeKit, Arduino or other integration here.
diff --git a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
index 7d5086e..0e28752 100644
--- a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
+++ b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
@@ -70,7 +70,7 @@ public class LightSwitchJavaModel extends NCModelFileAdapter {
String status = actTok.getId().equals("ls:on") ? "on" : "off";
String locations = locToks.isEmpty() ?
"entire house" :
- locToks.stream().map(t -> (String)t.meta("nlpcraft:nlp:origtext")).collect(Collectors.joining(", "));
+ locToks.stream().map(NCToken::getOriginalText).collect(Collectors.joining(", "));
// Add HomeKit, Arduino or other integration here.
diff --git a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
index 3ef6e0d..541ca04 100644
--- a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
+++ b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
@@ -63,7 +63,7 @@ class LightSwitchKotlinModel : NCModelFileAdapter("lightswitch_model.yaml") {
): NCResult {
val status = if (actTok.id == "ls:on") "on" else "off"
val locations = if (locToks.isEmpty()) "entire house" else locToks.stream()
- .map { t: NCToken -> t.meta("nlpcraft:nlp:origtext") as String }
+ .map { t: NCToken -> t.originalText }
.collect(Collectors.joining(", "))
// Add HomeKit, Arduino or other integration here.
diff --git a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
index 115f8fe..f0a3df3 100644
--- a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
+++ b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
@@ -66,7 +66,7 @@ class LightSwitchScalaModel extends NCModelFileAdapter("lightswitch_model.yaml")
if (locToks.isEmpty)
"entire house"
else
- locToks.map(_.meta[String]("nlpcraft:nlp:origtext")).mkString(", ")
+ locToks.map(_.getOriginalText).mkString(", ")
// Add HomeKit, Arduino or other integration here.