This is an automated email from the ASF dual-hosted git repository. sergeykamov pushed a commit to branch NLPCRAFT-383 in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit b766c2b72a0b1138220a52e98f7b348b4170916d Author: Sergey Kamov <[email protected]> AuthorDate: Fri Aug 6 14:13:10 2021 +0300 WIP. --- nlpcraft-examples/solarsystem/pom.xml | 151 +++++++++++++++++++++ .../examples/solarsystem/SolarSystemModel.scala | 31 +++++ .../loaders/SolarSystemDiscoversValueLoader.scala | 24 ++++ .../loaders/SolarSystemPlanetsValueLoader.scala | 24 ++++ .../loaders/SolarSystemValueLoader.scala | 18 +++ .../solarsystem/tools/SolarSystemOpenDataApi.scala | 86 ++++++++++++ .../solarsystem/src/main/resources/probe.conf | 148 ++++++++++++++++++++ .../src/main/resources/solarsystem_model.yaml | 91 +++++++++++++ .../solarsystem/NCModelValidationSpec.scala | 35 +++++ .../solarsystem/NCSolarSystemModelSpec.scala | 31 +++++ pom.xml | 1 + 11 files changed, 640 insertions(+) diff --git a/nlpcraft-examples/solarsystem/pom.xml b/nlpcraft-examples/solarsystem/pom.xml new file mode 100644 index 0000000..23b4079 --- /dev/null +++ b/nlpcraft-examples/solarsystem/pom.xml @@ -0,0 +1,151 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <name>NLPCraft example Solar System</name> + <artifactId>nlpcraft-example-solarsystem</artifactId> + + <parent> + <artifactId>nlpcraft-parent</artifactId> + <groupId>org.apache.nlpcraft</groupId> + <version>0.9.0</version> + <relativePath>../../pom.xml</relativePath> + </parent> + + <properties> + <nlpcraft.server.module>nlpcraft</nlpcraft.server.module> + <nlpcraft.all.deps.jar>apache-${nlpcraft.server.module}-incubating-${project.version}-all-deps.jar</nlpcraft.all.deps.jar> + </properties> + + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nlpcraft</artifactId> + <version>${project.version}</version> + </dependency> + + <!-- Test dependencies. --> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nlpcraft</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>${maven.compiler.plugin.ver}</version> + <configuration> + <source>${java.ver}</source> + <target>${java.ver}</target> + </configuration> + </plugin> + <plugin> + <groupId>com.bazaarvoice.maven.plugins</groupId> + <artifactId>process-exec-maven-plugin</artifactId> + <version>${maven.bazaarvoice.plugin.ver}</version> + <executions> + <execution> + <id>pre-integration-test</id> + <phase>pre-integration-test</phase> + <goals> + <goal>start</goal> + </goals> + <configuration> + <!-- + Depending on the console config and how maven is run this will produce the output with ANSI colors. + To strip out ANSI escape sequences from the log file, see the following: + https://stackoverflow.com/questions/17998978/removing-colors-from-output + --> + <name>server</name> + <healthcheckUrl>http://localhost:8081/api/v1/health</healthcheckUrl> + <waitAfterLaunch>600</waitAfterLaunch> + <processLogFile>${project.build.directory}/server-${timestamp}.log</processLogFile> + <arguments> + <argument>${java.home}/bin/java</argument> + <argument>-Xmx4G</argument> + <argument>-Xms4G</argument> + <argument>--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED</argument> + <argument>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED</argument> + <argument>--add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED</argument> + <argument>--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED</argument> + <argument>--add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED</argument> + <argument>--add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED</argument> + <argument>--illegal-access=permit</argument> + <argument>-DNLPCRAFT_ANSI_COLOR_DISABLED=true</argument> <!-- Remove ANSI at least from NLPCraft output. --> + <argument>-Djdk.tls.client.protocols=TLSv1.2</argument> + <argument>-jar</argument> + <argument>${project.basedir}/../../${nlpcraft.server.module}/target/${nlpcraft.all.deps.jar}</argument> + <argument>-server</argument> + </arguments> + </configuration> + </execution> + <execution> + <id>stop-all</id> + <phase>post-integration-test</phase> + <goals> + <goal>stop-all</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${maven.surefire.plugin.ver}</version> + <configuration> + <!-- Skips all tests on phase `test`. --> + <skip>true</skip> + </configuration> + <executions> + <!-- All tests are defined as integration. --> + <execution> + <id>integration-tests</id> + <phase>integration-test</phase> + <goals> + <goal>test</goal> + </goals> + <configuration> + <skip>false</skip> + <!-- Mandatory part. --> + <includes> + <include>**/*.*</include> + </includes> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/SolarSystemModel.scala b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/SolarSystemModel.scala new file mode 100644 index 0000000..720c4bd --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/SolarSystemModel.scala @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nlpcraft.examples.solarsystem + +import com.typesafe.scalalogging.LazyLogging +import org.apache.nlpcraft.model.NCModelFileAdapter + +class SolarSystemModel extends NCModelFileAdapter("solarsystem_model.yaml") with LazyLogging { + override def onInit(): Unit = { + + } + + override def onDiscard(): Unit = { + super.onDiscard() + } +} diff --git a/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemDiscoversValueLoader.scala b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemDiscoversValueLoader.scala new file mode 100644 index 0000000..6afef19 --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemDiscoversValueLoader.scala @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nlpcraft.examples.solarsystem.loaders + +import org.apache.nlpcraft.examples.solarsystem.tools.SolarSystemOpenDataApi + +class SolarSystemDiscoversValueLoader extends SolarSystemValueLoader { + override def getData: Seq[String] = SolarSystemOpenDataApi.getInstance().getAllDiscovers +} diff --git a/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemPlanetsValueLoader.scala b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemPlanetsValueLoader.scala new file mode 100644 index 0000000..dd3c661 --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemPlanetsValueLoader.scala @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nlpcraft.examples.solarsystem.loaders + +import org.apache.nlpcraft.examples.solarsystem.tools.SolarSystemOpenDataApi + +class SolarSystemPlanetsValueLoader extends SolarSystemValueLoader { + override def getData: Seq[String] = SolarSystemOpenDataApi.getInstance().getAllPlanets +} diff --git a/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemValueLoader.scala b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemValueLoader.scala new file mode 100644 index 0000000..3996849 --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/loaders/SolarSystemValueLoader.scala @@ -0,0 +1,18 @@ +package org.apache.nlpcraft.examples.solarsystem.loaders + +import org.apache.nlpcraft.model.{NCElement, NCValue, NCValueLoader} + +import java.util +import scala.jdk.CollectionConverters.{SeqHasAsJava, SetHasAsJava} + +trait SolarSystemValueLoader extends NCValueLoader { + def getData: Seq[String] + + private def mkValue(v: String): NCValue = + new NCValue { + override def getName: String = v + override def getSynonyms: util.List[String] = Seq(v.toLowerCase).asJava + } + + override def load(owner: NCElement): util.Set[NCValue] = getData.map(mkValue).toSet.asJava +} diff --git a/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/tools/SolarSystemOpenDataApi.scala b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/tools/SolarSystemOpenDataApi.scala new file mode 100644 index 0000000..70b4f84 --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/java/org/apache/nlpcraft/examples/solarsystem/tools/SolarSystemOpenDataApi.scala @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nlpcraft.examples.solarsystem.tools + +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.scala.DefaultScalaModule +import org.apache.nlpcraft.examples.solarsystem.tools.SolarSystemOpenDataApi.BodiesBean + +import java.net.URI +import java.net.http.{HttpClient, HttpRequest, HttpResponse} +import java.net.http.HttpClient.Version + +object SolarSystemOpenDataApi { + case class BodiesBean(bodies: Seq[Map[String, Object]]) + + private var s: SolarSystemOpenDataApi = _ + + def getInstance(): SolarSystemOpenDataApi = { + this.synchronized { + if (s == null) { + s = new SolarSystemOpenDataApi + + s.start() + } + + s + } + } +} + +class SolarSystemOpenDataApi { + private final val URL_BODIES = "https://api.le-systeme-solaire.net/rest/bodies" + private final val MAPPER = new ObjectMapper().registerModule(DefaultScalaModule) + + private var client: HttpClient = _ + private var planets: Seq[String] = _ + private var discovers: Seq[String] = _ + + private def getBody(params: String*): Seq[Map[String, Object]] = { + val req = HttpRequest.newBuilder(URI.create(s"$URL_BODIES?data=${params.mkString(",")}")). + header("Content-Type", "application/json"). + GET(). + build() + + val respJs = client.sendAsync(req, HttpResponse.BodyHandlers.ofString()).get().body() + + MAPPER.readValue(respJs, classOf[BodiesBean]).bodies + } + + def start(): Unit = { + client = HttpClient.newBuilder.version(Version.HTTP_2).build + + val res = getBody("englishName,discoveredBy") + + def extract(name: String): Seq[String] = + res.map(_(name).asInstanceOf[String]).map(_.strip()).filter(_.nonEmpty).distinct + + planets = extract("englishName") + discovers = extract("discoveredBy") + } + + def stop(): Unit = { + planets = null + discovers = null + + client = null + } + + def getAllPlanets: Seq[String] = planets + def getAllDiscovers: Seq[String] = discovers +} diff --git a/nlpcraft-examples/solarsystem/src/main/resources/probe.conf b/nlpcraft-examples/solarsystem/src/main/resources/probe.conf new file mode 100644 index 0000000..faea33f --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/resources/probe.conf @@ -0,0 +1,148 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# +# 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/raw/external_config/external + extConfig { + # Mandatory. + extUrl = "https://github.com/apache/incubator-nlpcraft/raw/external_config/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 { + # Any arbitrary descriptive name. + id = "solarsystem" + + # 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 + + # 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.examples.solarsystem.SolarSystemModel + + # 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/solarsystem/src/main/resources/solarsystem_model.yaml b/nlpcraft-examples/solarsystem/src/main/resources/solarsystem_model.yaml new file mode 100644 index 0000000..954f2c0 --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/main/resources/solarsystem_model.yaml @@ -0,0 +1,91 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +id: "nlpcraft.solarsystem.ex" +name: "Solar System Example Model" +version: "1.0" +description: "NLI-powered Solar system data chat example model." +enabledBuiltInTokens: ["nlpcraft:num", "nlpcraft:limit", "nlpcraft:sort", "nlpcraft:relation", "nlpcraft:date"] + +permutateSynonyms: false +sparse: false + +elements: + - id: "prop:name" + groups: + - "prop" + description: "..." + synonyms: + - "name" + + - id: "prop:moon" + groups: + - "prop" + description: "..." + synonyms: + - "moon" + + - id: "prop:mass" + groups: + - "prop" + description: "..." + synonyms: + - "mass" + + - id: "prop:radius" + groups: + - "prop" + description: "..." + synonyms: + - "mass" + + - id: "prop:temperature" + groups: + - "prop" + description: "..." + synonyms: + - "{temperature|average temperature}" + + - id: "prop:discoveredBy" + groups: + - "prop" + description: "..." + synonyms: + - "{discovered {by|_}}" + + - id: "prop:discoveredDate" + groups: + - "prop" + description: "..." + synonyms: + - "{discovered {date|_}}" + + - id: "prop:discoveredDate" + groups: + - "prop" + description: "..." + synonyms: + - "{discovered {date|_}}" + + - id: "enum:planet" + description: "..." + + - id: "enum:discoverer" + description: "..." + +intents: + - "intent=ls term(act)={has(tok_groups(), 'prop')}" \ No newline at end of file diff --git a/nlpcraft-examples/solarsystem/src/test/java/org/apache/nlpcraft/examples/solarsystem/NCModelValidationSpec.scala b/nlpcraft-examples/solarsystem/src/test/java/org/apache/nlpcraft/examples/solarsystem/NCModelValidationSpec.scala new file mode 100644 index 0000000..bedc16d --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/test/java/org/apache/nlpcraft/examples/solarsystem/NCModelValidationSpec.scala @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nlpcraft.examples.solarsystem + +import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator +import org.junit.jupiter.api.{Assertions, Test} + +/** + * JUnit model validation. + */ +class NCModelValidationSpec { + @Test + def test(): Unit = { + // Instruct auto-validator what models to test. + System.setProperty("NLPCRAFT_TEST_MODELS", classOf[SolarSystemModel].getName) + + // Start model auto-validator. + Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error logs above.") + } +} diff --git a/nlpcraft-examples/solarsystem/src/test/java/org/apache/nlpcraft/examples/solarsystem/NCSolarSystemModelSpec.scala b/nlpcraft-examples/solarsystem/src/test/java/org/apache/nlpcraft/examples/solarsystem/NCSolarSystemModelSpec.scala new file mode 100644 index 0000000..1bd102f --- /dev/null +++ b/nlpcraft-examples/solarsystem/src/test/java/org/apache/nlpcraft/examples/solarsystem/NCSolarSystemModelSpec.scala @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nlpcraft.examples.solarsystem + +import org.apache.nlpcraft.{NCTestContext, NCTestEnvironment} +import org.junit.jupiter.api.Test + +/** + * + */ +@NCTestEnvironment(model = classOf[SolarSystemModel], startClient = true) +class NCSolarSystemModelSpec extends NCTestContext { + @Test + def test(): Unit = { + } +} diff --git a/pom.xml b/pom.xml index 4a6649e..4250d72 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,7 @@ <modules> <module>nlpcraft</module> + <module>nlpcraft-examples/solarsystem</module> </modules> <developers>
