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

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


The following commit(s) were added to refs/heads/NLPCRAFT-41 by this push:
     new f6e071c  WIP.
     new e5f470f  Merge branch 'NLPCRAFT-41' of 
https://github.com/apache/incubator-nlpcraft into NLPCRAFT-41
f6e071c is described below

commit f6e071cd2914f8c88eea8031ae4e7b2e8575341e
Author: Aaron Radzinski <[email protected]>
AuthorDate: Thu Sep 10 20:23:19 2020 -0700

    WIP.
---
 nlpcraft/src/main/resources/nlpcraft.conf            | 13 +++++--------
 .../nlpcraft/probe/mgrs/cmd/NCCommandManager.scala   |  8 +++-----
 .../mgrs/conversation/NCConversationDescriptor.scala |  6 +++---
 .../nlpcraft/probe/mgrs/deploy/NCDeployManager.scala |  6 ++----
 ...datorSpec.scala => NCTestExampleModelsSpec.scala} | 20 +++++++++++++++++---
 .../impl/NCSqlModelGeneratorImplSpec.scala}          |  6 +++---
 6 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/nlpcraft/src/main/resources/nlpcraft.conf 
b/nlpcraft/src/main/resources/nlpcraft.conf
index 7ef1e8f..4b6bf1c 100644
--- a/nlpcraft/src/main/resources/nlpcraft.conf
+++ b/nlpcraft/src/main/resources/nlpcraft.conf
@@ -235,11 +235,11 @@ nlpcraft {
         # NOTE:
         # -----
         # There are separate configurations for single ('model') or multiple 
models ('models')
-        # for the probe to start with. It is done so for easy overriding via 
system properties of these
-        # values due to HOCON limitations in dealing with array value 
overriding:
+        # for the probe to start with. It is done so for easy HOCON overriding 
via environment variables
+        # due to HOCON limitations in dealing with array value overriding:
         #
         #   - If this value is specified the 'models' value is ignored.
-        #   - if this value is 'null' then the 'models' configuration will be 
taken in.
+        #   - If this value is 'null' then the 'models' configuration will be 
taken in.
         #   - Class name must be on the active class path for the probe.
         #   - Both 'model' and 'models' can be empty but then 'jarsFolder' 
must be provided.
         #
@@ -250,8 +250,8 @@ nlpcraft {
         # NOTE:
         # -----
         # There are separate configurations for single ('model') or multiple 
models ('models')
-        # for the probe to start with. It is done so for easy overriding via 
system properties of these
-        # values due to HOCON limitations in dealing with array value 
overriding:
+        # for the probe to start with. It is done so for easy HOCON overriding 
via environment variables
+        # due to HOCON limitations in dealing with array value overriding:
         #
         #   - This configuration is ignored if 'model' property is set (not 
'null').
         #   - Class names must be on the active class path for the probe.
@@ -309,9 +309,6 @@ nlpcraft {
         # Maximum execution result size in bytes. Default value is 1M.
         # When exceeded the request will be automatically rejected.
         resultMaxSizeBytes = 1048576
-
-        // TODO:
-        synonymsWarnValue = 10000
     }
 
     # Basic NLP toolkit to use on both server and probes. Possible values:
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
index f53aa6e..05c4367 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
@@ -24,7 +24,7 @@ import com.google.gson.Gson
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common.nlp.NCNlpSentence
 import org.apache.nlpcraft.common.util.NCUtils
-import org.apache.nlpcraft.common.{NCE, NCService}
+import org.apache.nlpcraft.common.NCService
 import org.apache.nlpcraft.model.NCToken
 import org.apache.nlpcraft.probe.mgrs.NCProbeMessage
 import org.apache.nlpcraft.probe.mgrs.conn.NCConnectionManager
@@ -111,10 +111,8 @@ object NCCommandManager extends NCService {
                         val mdlData = NCModelManager.getModelData(mdlId)
 
                         val macros = 
mdlData.model.getMacros.asInstanceOf[Serializable]
-                        val syns = mdlData.model.getElements.asScala.
-                            map(p ⇒ p.getId → 
p.getSynonyms).toMap.asJava.asInstanceOf[Serializable]
-                        val samples = mdlData.samples.map(p ⇒ p._1 → 
p._2.asJava).
-                            asJava.asInstanceOf[Serializable]
+                        val syns = mdlData.model.getElements.asScala.map(p ⇒ 
p.getId → p.getSynonyms).toMap.asJava.asInstanceOf[Serializable]
+                        val samples = mdlData.samples.map(p ⇒ p._1 → 
p._2.asJava).asJava.asInstanceOf[Serializable]
 
                         NCConnectionManager.send(
                             NCProbeMessage(
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationDescriptor.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationDescriptor.scala
index 7fad7f7..49a6621 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationDescriptor.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversationDescriptor.scala
@@ -86,7 +86,7 @@ case class NCConversationDescriptor(usrId: Long, mdlId: 
String) extends LazyLogg
             if (now - lastUpdateTstamp > CONV_CLEAR_DELAY) {
                 stm.clear()
 
-                logger.info(s"Conversation reset by timeout [" +
+                logger.info(s"Conversation is reset by timeout [" +
                     s"usrId=$usrId, " +
                     s"mdlId=$mdlId" +
                 s"]")
@@ -94,7 +94,7 @@ case class NCConversationDescriptor(usrId: Long, mdlId: 
String) extends LazyLogg
             else if (attempt > MAX_DEPTH) {
                 stm.clear()
         
-                logger.info(s"Conversation reset after too many unsuccessful 
requests [" +
+                logger.info(s"Conversation is reset after too many 
unsuccessful requests [" +
                     s"usrId=$usrId, " +
                     s"mdlId=$mdlId" +
                 s"]")
@@ -112,7 +112,7 @@ case class NCConversationDescriptor(usrId: Long, mdlId: 
String) extends LazyLogg
                         item.holders --= delHs
 
                         logger.info(
-                            s"Conversation stale tokens removed [" +
+                            s"Conversation overridden tokens removed [" +
                                 s"usrId=$usrId, " +
                                 s"mdlId=$mdlId, " +
                                 s"srvReqId=${item.srvReqId}, " +
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 20837a0..ced2d43 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
@@ -93,9 +93,7 @@ object NCDeployManager extends NCService with DecorateAsScala 
{
         def model: Option[String] = getStringOpt(s"$pre.model")
         def models: Seq[String] = getStringList(s"$pre.models")
         def jarsFolder: Option[String] = getStringOpt(s"$pre.jarsFolder")
-
-        // TODO: property name.
-        def synonymsWarnValue: Int = getInt(s"$pre.synonymsWarnValue")
+        def maxSynonymCount: Int = getInt(s"$pre.maxSynonymCount")
     }
 
     /**
@@ -935,7 +933,7 @@ object NCDeployManager extends NCService with 
DecorateAsScala {
 
             if (size == 0)
                 logger.warn(s"Element '$elemId' doesn't have synonyms 
[modelId=$mdlId]")
-            else if (size > Config.synonymsWarnValue)
+            else if (size > Config.maxSynonymCount)
                 logger.warn(
                     s"Element '$elemId' has too many ($size) synonyms. " +
                         s"Make sure this is truly necessary [modelId=$mdlId]"
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestAutoModelValidatorSpec.scala
 b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestExampleModelsSpec.scala
similarity index 56%
rename from 
nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestAutoModelValidatorSpec.scala
rename to 
nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestExampleModelsSpec.scala
index 22a5dee..46156c2 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestAutoModelValidatorSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestExampleModelsSpec.scala
@@ -21,9 +21,23 @@ import 
org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
 import org.junit.jupiter.api.{Assertions, Test}
 
 /**
-  * JUnit wrapper for `NCTestAutoModelValidator` mode validator.
+  * JUnit example models validation.
   */
-class NCTestAutoModelValidatorSpec {
+class NCTestExampleModelsSpec {
     @Test
-    def test(): Unit = 
Assertions.assertTrue(NCTestAutoModelValidator.isValid(), "See error logs 
above.")
+    def test(): Unit = {
+        val models = "" +
+            "org.apache.nlpcraft.examples.alarm.AlarmModel," +
+            "org.apache.nlpcraft.examples.time.TimeModel," +
+            "org.apache.nlpcraft.examples.lightswitch.LightSwitchModel," +
+            "org.apache.nlpcraft.examples.echo.EchoModel," +
+            "org.apache.nlpcraft.examples.weather.WeatherModel," +
+            "org.apache.nlpcraft.examples.time.TimeModel"
+
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", models)
+
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImplSpec.scala
similarity index 96%
rename from 
nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
rename to 
nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImplSpec.scala
index e51b51f..3d75592 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlModelGeneratorImplSpec.scala
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.model.tools
+package org.apache.nlpcraft.model.tools.sqlgen.impl
 
 import org.junit.jupiter.api.Assertions.assertTrue
 import org.junit.jupiter.api.Test
@@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test
 /**
  * SQL model engine test.
  */
-class NCSqlModelEngineSpec {
+class NCSqlModelGeneratorImplSpec {
     /**
-     * Copy of the private method from 'NCSqlModelEngine'.
+     * Copy of the private method from 'NCSqlModelGeneratorImpl'.
      *
      * @param s
      * @return

Reply via email to