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/05/16 17:29:24 UTC

[incubator-nlpcraft] branch NLPCREAFT-321 updated: WIP.

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCREAFT-321
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCREAFT-321 by this push:
     new 295138e  WIP.
295138e is described below

commit 295138efb950843398acf380d2de0ba65f51d82e
Author: unknown <ar...@datalingvo.com>
AuthorDate: Sun May 16 10:29:10 2021 -0700

    WIP.
---
 .../lightswitch/LightSwitchScalaModel.scala        | 28 +++++++++++-----------
 .../scala/org/apache/nlpcraft/model/NCResult.java  |  9 ++++++-
 2 files changed, 22 insertions(+), 15 deletions(-)

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 fe178d8..115f8fe 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
@@ -42,20 +42,20 @@ class LightSwitchScalaModel extends NCModelFileAdapter("lightswitch_model.yaml")
     @NCIntentRef("ls")
     @NCIntentSample(Array(
         "Turn the lights off in the entire house.",
-        "Turn off all lights now"
-//        "Switch on the illumination in the master bedroom closet.",
-//        "Get the lights on.",
-//        "Lights up in the kitchen.",
-//        "Please, put the light out in the upstairs bedroom.",
-//        "Set the lights on in the entire house.",
-//        "Turn the lights off in the guest bedroom.",
-//        "Could you please switch off all the lights?",
-//        "Dial off illumination on the 2nd floor.",
-//        "Please, no lights!",
-//        "Kill off all the lights now!",
-//        "No lights in the bedroom, please.",
-//        "Light up the garage, please!",
-//        "Kill the illumination now!"
+        "Turn off all lights now",
+        "Switch on the illumination in the master bedroom closet.",
+        "Get the lights on.",
+        "Lights up in the kitchen.",
+        "Please, put the light out in the upstairs bedroom.",
+        "Set the lights on in the entire house.",
+        "Turn the lights off in the guest bedroom.",
+        "Could you please switch off all the lights?",
+        "Dial off illumination on the 2nd floor.",
+        "Please, no lights!",
+        "Kill off all the lights now!",
+        "No lights in the bedroom, please.",
+        "Light up the garage, please!",
+        "Kill the illumination now!"
     ))
     def onMatch(
         @NCIntentTerm("act") actTok: NCToken,
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
index ed93a07..67b9e99 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
@@ -22,6 +22,8 @@ import org.apache.nlpcraft.common.util.*;
 
 import java.io.Serializable;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Data model result returned from model intent callbacks. Result consists of the
@@ -54,7 +56,7 @@ import java.util.Collection;
  * accordingly. For example, the REST client interfacing between NLPCraft and Amazon Alexa or Apple HomeKit can only
  * accept {@code text} result type and ignore everything else.
  */
-public class NCResult implements Serializable {
+public class NCResult implements Serializable, NCMetadata {
     /** Data Model result text. */
     private String body;
 
@@ -66,6 +68,9 @@ public class NCResult implements Serializable {
 
     /** ID of the intent. */
     private String intentId;
+
+    /** Result's metadata. */
+    private final Map<String, Object> meta = new HashMap<>();
     
     /**
      * Creates new result with given body and type.
@@ -239,4 +244,6 @@ public class NCResult implements Serializable {
     public void setIntentId(String intentId) {
         this.intentId = intentId;
     }
+
+    @Override public Map<String, Object> getMetadata() { return meta; }
 }