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 eb14120  Misc. fixes.
eb14120 is described below

commit eb141206887dfb98988db069e92df325f6e24f38
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Wed Oct 28 20:21:09 2020 -0700

    Misc. fixes.
---
 .../org/apache/nlpcraft/common/util/NCUtils.scala  |  2 +-
 .../examples/lightswitch/LightSwitchModel.scala    |  1 +
 .../examples/lightswitch/lightswitch_model.yaml    |  4 ++--
 .../nlpcraft/examples/time/TimeModelApp.java       |  5 ++---
 .../model/tools/embedded/NCEmbeddedProbe.java      | 23 +++++++++++-----------
 .../test/impl/NCTestAutoModelValidatorImpl.scala   | 15 +++++++-------
 .../probe/mgrs/deploy/NCDeployManager.scala        |  2 +-
 .../scala/org/apache/nlpcraft/NCTestContext.scala  | 17 ++++++++--------
 .../nlpcraft/model/intent/dsl/NCDslSpec.scala      |  8 ++++----
 9 files changed, 39 insertions(+), 38 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
index 9d0349a..80686ae 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
@@ -1377,7 +1377,7 @@ object NCUtils extends LazyLogging {
                     s"$errMsg $ansiCyanFg->$ansiReset ($fileName:$lineNum)"
 
             msg.split("\n").foreach(line ⇒ {
-                val s = s"${" " * indent}${if (first) ansiBlue("+- ") else "  
"}${line.trim}"
+                val s = s"${" " * indent}${if (first) ansiBlue("+- ") else "   
"}${line}"
 
                 if (err) logger.error(s) else logger.warn(s)
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
index 261b239..26b248a 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
@@ -44,6 +44,7 @@ class LightSwitchModel extends 
NCModelFileAdapter("org/apache/nlpcraft/examples/
         "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.",
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
index 44419c5..a8239b0 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml
@@ -40,8 +40,8 @@ elements:
       - "act"
     description: "Light switch ON action."
     synonyms:
-      - "<ACTION> <LIGHT>"
-      - "<ACTION> on <LIGHT>"
+      - "<ACTION> {on|up|*} <LIGHT> {on|up|*}"
+      - "<LIGHT> {on|up}"
 
   - id: "ls:off"
     groups:
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java
index 3800b2f..fd82494 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModelApp.java
@@ -32,8 +32,7 @@ public class TimeModelApp {
      */
     public static void main(String[] args) throws Exception {
         // Start the data probe "in place" with 'TimeModel' model.
-        NCEmbeddedProbe.start(TimeModel.class);
-
-        Thread.currentThread().join();
+        if (NCEmbeddedProbe.start(TimeModel.class))
+            Thread.currentThread().join();
     }
 }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
index 5a62b8a..56e81ad 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/embedded/NCEmbeddedProbe.java
@@ -81,13 +81,21 @@ public class NCEmbeddedProbe {
     }
 
     /**
+     *
+     * @param classes
+     */
+    private static void checkModelClasses(Class<? extends NCModel>[] classes) {
+        if (classes.length == 0)
+            throw new NCException("At least one model class must be provided 
when starting embedded probe.");
+    }
+
+    /**
      * Start the embedded probe with given configuration file. It is 
equivalent to starting a probe using
      * <code>-config=cfgFile</code> command line argument.
      *
      * @param cfgFile Configuration file path. It should be either a full path 
or the file name
      *      that can be found in the current working directory or on the 
classpath as a class loader
      *      resource.
-     * @throws NCException Thrown in case of any errors starting the data 
probe.
      * @return Whether or not probe started ok.
      */
     public static boolean start(String cfgFile) {
@@ -99,19 +107,10 @@ public class NCEmbeddedProbe {
     }
 
     /**
-     *
-     * @param classes
-     */
-    private static void checkModelClasses(Class<? extends NCModel>[] classes) {
-        if (classes.length == 0)
-            throw new NCException("At least one model class must be provided 
when starting embedded probe.");
-    }
-
-    /**
      * Starts the embedded probe with default configuration and specified 
models to deploy.
      * 
      * @param mdlClasses One or more data model classes to be deployed by the 
embedded probe.
-     * @throws NCException Thrown in case of any errors starting the data 
probe.
+     * @throws NCException Thrown if given list of models is empty.
      * @return  Whether or not probe started ok.
      */
     @SafeVarargs
@@ -133,7 +132,7 @@ public class NCEmbeddedProbe {
      * @param upLink Probe up-link to the server.
      * @param dnLink Probe down-link from the server.
      * @param mdlClasses One or more data model classes to be deployed by the 
embedded probe.
-     * @throws NCException Thrown in case of any errors starting the data 
probe.
+     * @throws NCException Thrown if given list of models is empty.
      * @return  Whether or not probe started ok.
      */
     @SafeVarargs
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
index 2f2c1e9..9f6dda2 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
@@ -52,13 +52,14 @@ private [test] object NCTestAutoModelValidatorImpl extends 
LazyLogging {
     def isValidForModelIds(mdlIds: Array[String]): Boolean = 
isValid(getClasses(mdlIds))
 
     @throws[Exception]
-    private def isValid(classes: Seq[Class[_ <: NCModel]]) = {
-        NCEmbeddedProbe.start(classes: _*)
-
-        try
-            process(NCModelManager.getAllModels().map(p ⇒ p.model.getId → 
p.samples.toMap).toMap.filter(_._2.nonEmpty))
-        finally
-            NCEmbeddedProbe.stop()
+    private def isValid(classes: Seq[Class[_ <: NCModel]]): Boolean = {
+        if (NCEmbeddedProbe.start(classes: _*))
+            try
+                process(NCModelManager.getAllModels().map(p ⇒ p.model.getId → 
p.samples.toMap).toMap.filter(_._2.nonEmpty))
+            finally
+                NCEmbeddedProbe.stop()
+        else
+            false
     }
 
     /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index 339dd27..5b936b0 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -514,7 +514,7 @@ object NCDeployManager extends NCService with 
DecorateAsScala {
                 )
             )
         catch {
-            case e: Throwable ⇒ throw new NCE(s"Failed to instantiate model 
for: $clsName", e)
+            case e: Throwable ⇒ throw new NCE(s"Failed to instantiate model: 
$clsName", e)
         }
 
     /**
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
index 892541f..1c3eccc 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
@@ -74,15 +74,16 @@ abstract class NCTestContext {
 
                 probeStarted = false
 
-                NCEmbeddedProbe.start(ann.model())
-
-                probeStarted = true
-
-                if (ann.startClient()) {
-                    cli = new NCTestClientBuilder().newBuilder.build
-
-                    cli.open(NCModelManager.getAllModels().head.model.getId)
+                if (NCEmbeddedProbe.start(ann.model())) {
+                    probeStarted = true
+                
+                    if (ann.startClient()) {
+                        cli = new NCTestClientBuilder().newBuilder.build
+                        
+                        
cli.open(NCModelManager.getAllModels().head.model.getId)
+                    }
                 }
+                
             case None ⇒ // No-op.
         }
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
index 801f7e7..0da445d 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
@@ -36,11 +36,11 @@ class NCDslSpec {
     @throws[IOException]
     private[dsl] def setUp(): Unit = {
         // Start embedded probe with the test model.
-        NCEmbeddedProbe.start(classOf[NCDslTestModel])
+        if (NCEmbeddedProbe.start(classOf[NCDslTestModel])) {
+            cli = new NCTestClientBuilder().newBuilder.build
 
-        cli = new NCTestClientBuilder().newBuilder.build
-
-        cli.open("nlpcraft.dsl.test")
+            cli.open("nlpcraft.dsl.test")
+        }
     }
 
     @AfterEach

Reply via email to