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

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


The following commit(s) were added to refs/heads/NLPCRAFT-396 by this push:
     new 792f60c  WIP on NLPCRAFT-396
792f60c is described below

commit 792f60c74d398dd911de13eacb114868453ae040
Author: Aaron Radzinski <[email protected]>
AuthorDate: Fri Aug 6 15:54:23 2021 -0700

    WIP on NLPCRAFT-396
---
 .../lightswitch/LightSwitchGroovyModel.groovy      | 36 +++++++++++++---------
 .../examples/lightswitch/LightSwitchJavaModel.java |  8 +++++
 .../examples/lightswitch/LightSwitchKotlinModel.kt | 36 +++++++++++++---------
 .../lightswitch/LightSwitchScalaModel.scala        |  7 +++++
 .../src/main/resources/lightswitch_model.yaml      |  9 +++---
 .../nlpcraft/model/tools/cmdline/NCCli.scala       | 17 ++++++++--
 .../model/tools/cmdline/NCCliCommands.scala        | 21 +++++++++----
 .../nlpcraft/server/probe/NCProbeManager.scala     |  9 +++---
 8 files changed, 99 insertions(+), 44 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 9c9e978..901605b 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
@@ -46,20 +46,28 @@ class LightSwitchGroovyModel extends NCModelFileAdapter {
      */
     @NCIntentRef("ls")
     @NCIntentSample([
-        "Turn the lights off in the entire house.",
-        "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 the lights off in the entire house.",
+            "Turn off all lights now",
+            "Switch on the illumination in the master bedroom closet.",
+            "Off the lights on the 1st floor",
+            "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.",
+            "Turn down lights in 1st floor bedroom",
+            "Lights on at second floor kitchen",
+            "Please, no lights!",
+            "Kill off all the lights now!",
+            "Down the lights in the garage",
+            "Lights down in the kitchen!",
+            "Turn up the illumination in garage and master bedroom",
+            "Turn down all the light now!",
+            "No lights in the bedroom, please.",
+            "Light up the garage, please!",
+            "Kill the illumination now!"
     ])
     NCResult onMatch(
         @NCIntentTerm("act") NCToken actTok,
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 0e28752..e25d6b8 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
@@ -50,7 +50,9 @@ public class LightSwitchJavaModel extends NCModelFileAdapter {
     @NCIntentRef("ls")
     @NCIntentSample({
         "Turn the lights off in the entire house.",
+        "Turn off all lights now",
         "Switch on the illumination in the master bedroom closet.",
+        "Off the lights on the 1st floor",
         "Get the lights on.",
         "Lights up in the kitchen.",
         "Please, put the light out in the upstairs bedroom.",
@@ -58,8 +60,14 @@ public class LightSwitchJavaModel extends NCModelFileAdapter 
{
         "Turn the lights off in the guest bedroom.",
         "Could you please switch off all the lights?",
         "Dial off illumination on the 2nd floor.",
+        "Turn down lights in 1st floor bedroom",
+        "Lights on at second floor kitchen",
         "Please, no lights!",
         "Kill off all the lights now!",
+        "Down the lights in the garage",
+        "Lights down in the kitchen!",
+        "Turn up the illumination in garage and master bedroom",
+        "Turn down all the light now!",
         "No lights in the bedroom, please.",
         "Light up the garage, please!",
         "Kill the illumination now!"
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 541ca04..c63f9ad 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
@@ -42,20 +42,28 @@ class LightSwitchKotlinModel : 
NCModelFileAdapter("lightswitch_model.yaml") {
      */
     @NCIntentRef("ls")
     @NCIntentSample(
-        "Turn the lights off in the entire house.",
-        "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 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.",
+            "Off the lights on the 1st floor",
+            "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.",
+            "Turn down lights in 1st floor bedroom",
+            "Lights on at second floor kitchen",
+            "Please, no lights!",
+            "Kill off all the lights now!",
+            "Down the lights in the garage",
+            "Lights down in the kitchen!",
+            "Turn up the illumination in garage and master bedroom",
+            "Turn down all the light now!",
+            "No lights in the bedroom, please.",
+            "Light up the garage, please!",
+            "Kill the illumination now!"
     )
     fun onMatch(
         @NCIntentTerm("act") actTok: NCToken,
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 f0a3df3..b314891 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
@@ -45,14 +45,21 @@ class LightSwitchScalaModel extends 
NCModelFileAdapter("lightswitch_model.yaml")
         "Turn off all lights now",
         "Switch on the illumination in the master bedroom closet.",
         "Get the lights on.",
+        "Off the lights on the 1st floor",
         "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.",
+        "Turn down lights in 1st floor bedroom",
+        "Lights on at second floor kitchen",
         "Please, no lights!",
         "Kill off all the lights now!",
+        "Down the lights in the garage",
+        "Lights down in the kitchen!",
+        "Turn up the illumination in garage and master bedroom",
+        "Turn down all the light now!",
         "No lights in the bedroom, please.",
         "Light up the garage, please!",
         "Kill the illumination now!"
diff --git 
a/nlpcraft-examples/lightswitch/src/main/resources/lightswitch_model.yaml 
b/nlpcraft-examples/lightswitch/src/main/resources/lightswitch_model.yaml
index 71b1e46..c79329a 100644
--- a/nlpcraft-examples/lightswitch/src/main/resources/lightswitch_model.yaml
+++ b/nlpcraft-examples/lightswitch/src/main/resources/lightswitch_model.yaml
@@ -27,7 +27,7 @@ macros:
   - name: "<ENTIRE_OPT>"
     macro: "{entire|full|whole|total|_}"
   - name: "<FLOOR_OPT>"
-    macro: "{upstairs|downstairs|{1st|2nd|3rd|4th|5th|top|ground} floor|_}"
+    macro: 
"{upstairs|downstairs|{1st|first|2nd|second|3rd|third|4th|fourth|5th|fifth|top|ground}
 floor|_}"
   - name: "<TYPE>"
     macro: "{room|closet|attic|loft|{store|storage} {room|_}}"
   - name: "<LIGHT>"
@@ -64,11 +64,12 @@ elements:
       - "act"
     description: "Light switch OFF action."
     synonyms:
-      - "<ACTION> <LIGHT> {off|out}"
-      - "{<ACTION>|<KILL>} {off|out} <LIGHT>"
+      - "<ACTION> <LIGHT> {off|out|down}"
+      - "{<ACTION>|<KILL>} {off|out|down} <LIGHT>"
       - "<KILL> <LIGHT>"
       - "<LIGHT> <KILL>"
-      - "no <LIGHT>"
+      - "{out|no|off|down} <LIGHT>"
+      - "<LIGHT> {out|off|down}"
 
 intents:
   - "intent=ls term(act)={has(tok_groups(), 'act')} term(loc)={tok_id() == 
'ls:loc'}*"
\ No newline at end of file
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 6c8bcf0..d1bb9c5 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -2813,7 +2813,7 @@ object NCCli extends NCCliBase {
                 if (!wasLastLineEmpty)
                     reader.printAbove("\n" + prompt1 + ":" + prompt2 + ":" + 
prompt3 + ":" + prompt4)
 
-                reader.readLine(s"${g(">")} ")
+                reader.readLine(s"${g(bo(">"))} ")
             }
             catch {
                 case _: UserInterruptException => "" // Ignore.
@@ -3195,7 +3195,20 @@ object NCCli extends NCCliBase {
 
                     execOsCmd(if (head.isEmpty) tail else head :: tail)
                 }
-                else {
+                else if (args.head.head == '@') {
+                    if (!repl)
+                        throw new IllegalStateException("This syntax is only 
available in REPL mode.")
+
+                    // A shortcut for the 'ask' command.
+                    ASK_CMD.body(
+                        ASK_CMD,
+                        Seq(
+                            Argument(ASK_CMD.params.find(_.id == "txt").get,
+                            Some(args.head.tail.strip + " " + 
args.tail.mkString(" ")))
+                        ),
+                        repl
+                    )
+                } else {
                     // Process 'no-ansi' and 'ansi' commands first.
                     processAnsi(args, repl)
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
index ae6a1e1..bda3ab1 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliCommands.scala
@@ -281,7 +281,9 @@ private [cmdline] object NCCliCommands {
                 s"Requires user to be already signed in. This command 
${bo("only makes sense in the REPL mode")} as " +
                 s"it requires user to be signed in. REPL session keeps the 
currently active access " +
                 s"token after user signed in. For command line mode, use 
${y("'rest'")} command with " +
-                s"corresponding parameters."
+                s"corresponding parameters. In REPL mode this command has a 
syntax shortcut providing a chatbot-like " +
+                s"interface: you can just type ${y("'@user input'")} and it 
will be automatically " +
+                s"replaced by ${y("'ask --txt=\"user input\"'")}."
             ),
             body = NCCli.cmdAsk,
             params = Seq(
@@ -293,7 +295,7 @@ private [cmdline] object NCCliCommands {
                     desc =
                         s"ID of the data model to send the request to. Note 
that this is optional ONLY if there is only one " +
                         s"connected probe and it has only one model deployed - 
which will be used by default. In all other " +
-                        s"cases - this parameter is mandatory." +
+                        s"cases - this parameter is mandatory. " +
                         s"In REPL mode, hit ${rv(" Tab ")} to see 
auto-suggestion for possible model IDs."
                 ),
                 Parameter(
@@ -320,20 +322,27 @@ private [cmdline] object NCCliCommands {
             examples = Seq(
                 Example(
                     usage = Seq(
-                        s"""> ask --txt="User request" --mdlId=my.model.id"""
+                        s"""> ask --txt="user input" --mdlId=my.model.id"""
                     ),
                     desc =
                         s"Issues ${y("'ask/sync'")} REST call with given text 
and model ID."
                 ),
                 Example(
                     usage = Seq(
-                        s"""> ask --txt="User text""""
+                        s"""> ask --txt="user input""""
                     ),
                     desc =
-                        s"Issues ${y("'ask/sync'")} REST call with given text 
and default model ID " +
+                        s"Issues ${y("'ask/sync'")} REST call with given 
${y("'user input'")} text and default model ID " +
                         s"(single connected probe that has a single model 
deployed)."
+                ),
+                Example(
+                    usage = Seq(
+                        s"> @user input"
+                    ),
+                    desc =
+                        s"Issues ${y("'ask/sync'")} REST call with given 
${y("'user input'")} text and default model ID " +
+                        s"(single connected probe that has a single model 
deployed). This shortcut syntax works only in REPL mode."
                 )
-
             )
         ),
         Command(
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
index 92238a2..cd0d5a5 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/probe/NCProbeManager.scala
@@ -1067,7 +1067,7 @@ object NCProbeManager extends NCService {
       * @param holder
       * @param parent
       */
-    private def processModelDataRequest(
+    private def processModelInfoRequest(
         mdlId: String, msg: NCProbeMessage, holder: ConcurrentHashMap[String, 
Promise[JavaMeta]], parent: Span = null
     ): Future[JavaMeta] = {
         val p = Promise[JavaMeta]()
@@ -1077,6 +1077,7 @@ object NCProbeManager extends NCService {
                 holder.put(msg.getGuid, p)
 
                 sendToProbe(probe.probeKey, msg, parent)
+
             case None =>
                 p.failure(new NCE(s"Probe not found for model: '$mdlId''"))
         }
@@ -1092,7 +1093,7 @@ object NCProbeManager extends NCService {
       */
     def getModelSynonymsInfo(mdlId: String, parent: Span = null): 
Future[JavaMeta] =
         startScopedSpan("getModelSynonymsInfo", parent, "mdlId" -> mdlId) { _ 
=>
-            processModelDataRequest(
+            processModelInfoRequest(
                 mdlId,
                 NCProbeMessage("S2P_MODEL_SYNS_INFO", "mdlId" -> mdlId),
                 modelsSynsInfo,
@@ -1109,7 +1110,7 @@ object NCProbeManager extends NCService {
       */
     def getModelElementInfo(mdlId: String, elmId: String, parent: Span = 
null): Future[JavaMeta] =
         startScopedSpan("getModelElementInfo", parent, "mdlId" -> mdlId, 
"elmId" -> elmId) { _ =>
-            processModelDataRequest(
+            processModelInfoRequest(
                 mdlId,
                 NCProbeMessage("S2P_MODEL_ELEMENT_INFO", "mdlId" -> mdlId, 
"elmId" -> elmId),
                 modelElmsInfo,
@@ -1146,7 +1147,7 @@ object NCProbeManager extends NCService {
 
     def getModelInfo(mdlId: String, parent: Span = null): Future[JavaMeta] =
         startScopedSpan("getModelInfo", parent, "mdlId" -> mdlId) { _ =>
-            processModelDataRequest(
+            processModelInfoRequest(
                 mdlId,
                 NCProbeMessage("S2P_MODEL_INFO", "mdlId" -> mdlId),
                 modelsInfo,

Reply via email to