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

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


The following commit(s) were added to refs/heads/NLPCRAFT-91-MODULES by this 
push:
     new f154930  WIP.
f154930 is described below

commit f154930461f1f519683ed20476e00df307f8b13f
Author: Sergey Kamov <[email protected]>
AuthorDate: Fri Apr 23 11:42:40 2021 +0300

    WIP.
---
 .../lightswitch/LightSwitchGroovyModel.groovy      |   7 +-
 .../examples/lightswitch/LightSwitchJavaModel.java |   5 +
 .../examples/lightswitch/LightSwitchKotlinModel.kt |   4 +
 .../lightswitch/NCTestExampleModelsSpec.scala      |   7 +-
 .../minecraft/src/main/resources/minecraft.yaml    |   4 +-
 .../minecraft/src/main/resources/nlpcraft.conf     | 160 +++++++++++++++------
 .../minecraft/NCTestExampleModelsSpec.scala        |   2 +-
 7 files changed, 139 insertions(+), 50 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 b8f0cc6..67788fb 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
@@ -61,7 +61,7 @@ class LightSwitchGroovyModel extends NCModelFileAdapter {
         "Light up the garage, please!",
         "Kill the illumination now!"
     ])
-    static NCResult onMatch(
+    NCResult onMatch(
         @NCIntentTerm("act") NCToken actTok,
         @NCIntentTerm("loc") List<NCToken> locToks) {
         String status = actTok.id == "ls:on" ? "on" : "off"
@@ -72,4 +72,9 @@ class LightSwitchGroovyModel extends NCModelFileAdapter {
         // By default - just return a descriptive action string.
         NCResult.text("Lights are [$status] in [${locations.toLowerCase()}].")
     }
+
+    @Override
+    String getId() {
+        return super.getId() + ".groovy"
+    }
 }
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 9b81e82..7d5086e 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
@@ -77,4 +77,9 @@ public class LightSwitchJavaModel extends NCModelFileAdapter {
         // By default - just return a descriptive action string.
         return NCResult.text("Lights are [" + status + "] in [" + 
locations.toLowerCase() + "].");
     }
+
+    @Override
+    public String getId() {
+        return super.getId() + ".java";
+    }
 }
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 cc87371..8aa28c9 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
@@ -72,4 +72,8 @@ class LightSwitchKotlinModel : 
NCModelFileAdapter("lightswitch_model.yaml") {
         // By default - just return a descriptive action string.
         return NCResult.text("Lights are [" + status + "] in [" + 
locations.toLowerCase() + "].")
     }
+
+    override fun getId(): String {
+        return super.getId() + ".kotlin"
+    }
 }
\ No newline at end of file
diff --git 
a/nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
 
b/nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
index ada9677..3aaf1a6 100644
--- 
a/nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
+++ 
b/nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
@@ -27,7 +27,12 @@ class NCTestExampleModelsSpec {
     @Test
     def test(): Unit = {
         // Instruct auto-validator what models to test.
-        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.lightswitch.LightSwitchJavaModel")
+        System.setProperty(
+            "NLPCRAFT_TEST_MODELS",
+                
"org.apache.nlpcraft.examples.lightswitch.LightSwitchJavaModel," +
+                
"org.apache.nlpcraft.examples.lightswitch.LightSwitchGroovyModel," +
+                
"org.apache.nlpcraft.examples.lightswitch.LightSwitchKotlinModel"
+        )
 
         // Start model auto-validator.
         Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
diff --git a/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml 
b/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml
index 2a40dcf..50cf792 100644
--- a/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml
+++ b/nlpcraft-examples/minecraft/src/main/resources/minecraft.yaml
@@ -35,11 +35,11 @@ elements:
   - id: mc:item
     metadata:
       mc:type: item
-    valueLoader: org.apache.nlpcraft.example.MinecraftObjectValueLoader
+    valueLoader: 
org.apache.nlpcraft.example.minecraft.MinecraftObjectValueLoader
   - id: mc:block
     metadata:
       mc:type: block
-    valueLoader: org.apache.nlpcraft.example.MinecraftObjectValueLoader
+    valueLoader: 
org.apache.nlpcraft.example.minecraft.MinecraftObjectValueLoader
 
   # Weather intent
   - id: weather:action
diff --git a/nlpcraft-examples/minecraft/src/main/resources/nlpcraft.conf 
b/nlpcraft-examples/minecraft/src/main/resources/nlpcraft.conf
index f9b4a44..a46f4a9 100644
--- a/nlpcraft-examples/minecraft/src/main/resources/nlpcraft.conf
+++ b/nlpcraft-examples/minecraft/src/main/resources/nlpcraft.conf
@@ -15,64 +15,134 @@
 # limitations under the License.
 #
 
-nlpcraft {
-    server {
-        lifecycle = ""
-        database {
-            jdbc {
-                url = "jdbc:ignite:thin://127.0.0.1/nlpcraft"
-                driver = org.apache.ignite.IgniteJdbcThinDriver
-            }
-            igniteDbInitialize = false
-            c3p0 {
-                maxStatements = 180
-                pool {
-                    initSize = 10
-                    minSize = 1
-                    maxSize = 50
-                    acquireIncrement = 2
-                }
-            }
-        }
-        rest {
-            host = "0.0.0.0"
-            port = 8081
-            apiImpl = "org.apache.nlpcraft.server.rest.NCBasicRestApi"
-        }
-        user {
-            pwdPoolBlowup = 3
-            timeoutScannerFreqMins = 1
-            accessTokenExpireTimeoutMins = 60
-        }
-        probe {
-            links {
-                upLink = "0.0.0.0:8201" # Server to probe data pipe.
-                downLink = "0.0.0.0:8202" # Probe to server data pipe.
-            }
-            pingTimeoutMs = 2000
-            soTimeoutMs = 5000
-            reconnectTimeoutMs = 5000
-        }
-        datesFormatStyle = MDY
-        tokenProviders = "nlpcraft"
-        ctxword.url="http://localhost:5000";
-    }
+#
+# This is joint configuration file for both the server and the data probes. 
Note that
+# server and probe configuration can be placed into separate files - each file 
containing only
+# 'nlpcraft.server' or 'nlpcraft.probe' sub-sections.
+#
+# You can also provide configuration properties or override the default ones 
via environment variables.
+# To use environment variables override:
+# 1. Set probe or server JVM system property 
-Dconfig.override_with_env_vars=true
+# 2. For each configuration 'x.y.z' set the environment variable 
CONFIG_FORCE_x_y_z=some_value
+#
+# Examples of environment variables:
+#   -- Overrides 'nlpcraft.sever.host' configuration property.
+#   CONFIG_FORCE_nlpcraft_server_rest_host="localhost"
+#
+#   -- Overrides 'nlpcraft.sever.models' configuration property.
+#   CONFIG_FORCE_nlpcraft_server_models="com.models.MyModel"
+#
+# See https://nlpcraft.apache.org/server-and-probe.html for more details.
+#
 
+# Common server/probe configuration root.
+nlpcraft {
+    # Basic NLP toolkit to use on both server and probes. Possible values:
+    # - 'opennlp'
+    # - 'stanford'
+    #
+    # NOTE: Stanford CoreNLP requires special installation due to its 
licensing.
+    # See https://nlpcraft.apache.org/integrations.html#stanford for more 
details.
     nlpEngine = "opennlp"
 
+    # External configuration resources.
+    #
+    # NOTE:
+    # ----
+    # Due to licensing restrictions of the official ASF release policy some of 
the
+    # configuration for NLPCraft cannot be shipped with the official Apache 
release.
+    # Instead, NLPCraft will attempt to download these configuration files 
from the
+    # external URL upon the first start.
+    #
+    # NLPCraft will attempt to download the missing configuration files from 
URL defined
+    # in 'nlpcraft.extConfig.extUrl' property and place them into 
'nlpcraft.extConfig.locDir'
+    # folder on the local file system. On subsequent starts, NLPCraft will 
check if the required
+    # file is already present locally and skip the download in such case. If 
'nlpcraft.extConfig.checkMd5'
+    # property is set to 'true' then on each start NLPCraft will check the 
checksum of each file
+    # locally and remote and will re-download such file if the MD5 checksums 
don't match.
+    #
+    # By default, the external configuration is stored in the main Git 
repository for NLPCraft
+    # project from where it will be downloaded ('/external' folder). See this 
folder in the Git
+    # repository for more information: 
https://github.com/apache/incubator-nlpcraft/tree/master/external
     extConfig {
+        # Mandatory.
         extUrl = 
"https://github.com/apache/incubator-nlpcraft/raw/master/external";
+
+        # Optional.
+        # Default value is $USER_HOME/.nlpcraft/extcfg
+        # locDir = ...
+
+        # If 'true', on each start NLPCraft will check the MD5 checksum of the 
each local and remote
+        # external configuration file and will re-download such file if the 
checksum doesn't match.
+        # Set it to 'false' to speed up the bootstrap of the NLPCraft server 
and the data probe if you
+        # are certain that all external configuration files are properly 
downloaded and available
+        # in 'nlpcraft.extConfig.locDir' local folder.
         checkMd5 = true
     }
+
+    # +---------------------+
+    # | Probe configuration. |
+    # +---------------------+
     probe {
-        id = "extended.examples"
+        # Any arbitrary descriptive name.
+        id = "minecraft"
+
+        # This is the default token (as in default company).
+        # Note that this token must match the probe token for the company this 
probe
+        # associated with. If changed from default, this token must be kept 
secure.
         token = "3141592653589793"
+
+        # These are default up-link and down-link endpoints that the probe 
will connect to.
+        # If changed - they need to be changed on both server and probe.
         upLink = "0.0.0.0:8201"   # Server to probe data pipe.
         downLink = "0.0.0.0:8202" # Probe to server data pipe.
+
+        # All JARs in this folder will be scanned for models.
+        # Safely ignored if 'null' - but then 'models' should have at least 
one element.
         jarsFolder = null
-        models =
-            """org.apache.nlpcraft.example.MinecraftModel"""
+
+        # Specifies fully qualifies model class names for the probe to start 
with.
+        #
+        # Note that following models require 'google' on the server side.
+        # See https://nlpcraft.apache.org/integrations.html#nlp for more 
details
+        # on how to configure 3rd party token providers:
+        models = org.apache.nlpcraft.example.minecraft.MinecraftModel
+
+        # Specify class names for probe life cycle components.
+        # Each class should extend 'NCProbeLifecycle' interface and provide a 
no-arg constructor.
+        #
+        # The following built-in OpenCensus exporters are supported as 
lifecycle components:
+        # - org.apache.nlpcraft.model.opencensus.NCJaegerExporter (traces)
+        # - org.apache.nlpcraft.model.opencensus.NCZipkinExporter (traces)
+        # - org.apache.nlpcraft.model.opencensus.NCPrometheusExporter (stats)
+        # - org.apache.nlpcraft.model.opencensus.NCStackdriverTraceExporter 
(traces)
+        # - org.apache.nlpcraft.model.opencensus.NCStackdriverStatsExporter 
(stats)
         lifecycle = ""
+
+        # Properties for built-in OpenCensus exporters.
+        # All configuration properties are optional unless otherwise specified.
+        # opencensus {
+        #     jaeger {
+        #         thriftUrl = "http://127.0.0.1:14268/api/traces";
+        #         serviceName = "nlpcraft-probe"
+        #     }
+        #     prometheus {
+        #         hostPort = "localhost:8889"
+        #         namespace = "nlpcraft-probe"
+        #     }
+        #     stackdriver {
+        #         # Mandatory Google project ID.
+        #         googleProjectId = "your_google_project_id"
+        #         metricsPrefix = "custom.googleapis.com/nlpcraft/probe"
+        #     }
+        #     zipkin {
+        #         v2Url = "http://127.0.0.1:9411/api/v2/spans";
+        #         serviceName = "nlpcraft-probe"
+        #     }
+        # }
+
+        # Maximum execution result size in bytes. Default value is 1M.
+        # When exceeded the request will be automatically rejected.
         resultMaxSizeBytes = 1048576
     }
 }
diff --git 
a/nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/minecraft/NCTestExampleModelsSpec.scala
 
b/nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/minecraft/NCTestExampleModelsSpec.scala
index 70fcda8..5c237e7 100644
--- 
a/nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/minecraft/NCTestExampleModelsSpec.scala
+++ 
b/nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/minecraft/NCTestExampleModelsSpec.scala
@@ -26,7 +26,7 @@ class NCTestExampleModelsSpec {
     @Test
     def test(): Unit = {
         // Instruct auto-validator what models to test.
-        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.example.MinecraftModel")
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.example.minecraft.MinecraftModel")
 
         // Start model auto-validator.
         Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")

Reply via email to