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-website.git
The following commit(s) were added to refs/heads/master by this push:
new 7a4436d WIP on docs refactoring for 0.7.0.
7a4436d is described below
commit 7a4436dee1aacdb7cced372ff39da0467d86db1c
Author: Aaron Radzinski <[email protected]>
AuthorDate: Tue Aug 18 21:55:38 2020 -0700
WIP on docs refactoring for 0.7.0.
---
examples/alarm_clock.html | 4 +-
examples/light_switch.html | 4 +-
examples/sql_model.html | 4 +-
examples/weather_bot.html | 4 +-
first-example.html | 181 ++++++++++++++++++---------------------------
5 files changed, 82 insertions(+), 115 deletions(-)
diff --git a/examples/alarm_clock.html b/examples/alarm_clock.html
index f87d433..aa0d027 100644
--- a/examples/alarm_clock.html
+++ b/examples/alarm_clock.html
@@ -422,10 +422,10 @@ class AlarmTest {
</li>
</ul>
<div class="bq info">
- <p><b>Embedded Prove</b></p>
+ <p><b>Embedded Probe</b></p>
<p>
This test uses <a href="/tools/embedded_probe.html">embedded
probe</a> which automatically
- start and stops the data probe from within the tests itself.
See lines 20 and 32 for details.
+ starts and stops the data probe from within the tests itself.
See lines 20 and 32 for details.
</p>
<p>
<b>NOTE:</b> when using test you don't need to start data
probe standalone in a previous step.
diff --git a/examples/light_switch.html b/examples/light_switch.html
index f37efcd..cf42211 100644
--- a/examples/light_switch.html
+++ b/examples/light_switch.html
@@ -391,10 +391,10 @@ class LightSwitchTest {
</li>
</ul>
<div class="bq info">
- <p><b>Embedded Prove</b></p>
+ <p><b>Embedded Probe</b></p>
<p>
This test uses <a href="/tools/embedded_probe.html">embedded
probe</a> which automatically
- start and stops the data probe from within the tests itself.
See lines 20 and 32 for details.
+ starts and stops the data probe from within the tests itself.
See lines 20 and 32 for details.
</p>
<p>
<b>NOTE:</b> when using test you don't need to start data
probe standalone in a previous step.
diff --git a/examples/sql_model.html b/examples/sql_model.html
index 90b07c6..9d283e0 100644
--- a/examples/sql_model.html
+++ b/examples/sql_model.html
@@ -337,10 +337,10 @@ Jul-05|08:40:47|INFO | Database
'jdbc:h2:tcp://localhost:9092/nlp2sql' is NOT in
provides additional utility of testing each input sentence against
the result SQL statement.
</p>
<div class="bq info">
- <p><b>Embedded Prove & H2 Autostart</b></p>
+ <p><b>Embedded Probe & H2 Autostart</b></p>
<p>
This test uses <a href="/tools/embedded_probe.html">embedded
probe</a> which automatically
- start and stops the data probe from within the tests itself.
This test also starts H2 database
+ starts and stops the data probe from within the tests itself.
This test also starts H2 database
automatically.
</p>
<p>
diff --git a/examples/weather_bot.html b/examples/weather_bot.html
index ba6863c..920fb73 100644
--- a/examples/weather_bot.html
+++ b/examples/weather_bot.html
@@ -492,10 +492,10 @@ class WeatherTest {
</li>
</ul>
<div class="bq info">
- <p><b>Embedded Prove</b></p>
+ <p><b>Embedded Probe</b></p>
<p>
This test uses <a href="/tools/embedded_probe.html">embedded
probe</a> which automatically
- start and stops the data probe from within the tests itself.
See lines 43 and 55 for details.
+ starts and stops the data probe from within the tests itself.
See lines 43 and 55 for details.
</p>
<p>
<b>NOTE:</b> when using test you don't need to start data
probe standalone in a previous step.
diff --git a/first-example.html b/first-example.html
index 3a9b26e..018693d 100644
--- a/first-example.html
+++ b/first-example.html
@@ -233,7 +233,7 @@ class LightSwitchModel extends
NCModelFileAdapter("examples/lightswitch_model.ya
annotation is optional, the list of samples serves two
important purposes:
<ul>
<li>
- It provides documentation for the intent by
providing examples of input sentences that this intent should match on.
+ It provides documentation for the intent by
listing examples of input sentences that this intent should match on.
</li>
<li>
It can also be used for auto-testing of the
model. See below the <a href="#test">testing</a>
@@ -256,40 +256,40 @@ class LightSwitchModel extends
NCModelFileAdapter("examples/lightswitch_model.ya
</li>
</ul>
</section>
- <section>
- <h3 class="section-title">Start Data Probe</h3>
- <p>
- NLPCraft data models get deployed into data probe. Let's start
data probe to deploy our newly
- created light switch data model. To start data probe we need to
configure Run Configuration in IDEA with
- the following parameters:
- </p>
- <ul>
- <li>
- <b>Main class:</b> <code>org.apache.nlpcraft.NCStart</code>
- </li>
- <li>
- <b>VM arguments:</b>
<code>-Dconfig.override_with_env_vars=true</code>
- </li>
- <li>
- <b>Environment variable:</b>
<code>CONFIG_FORCE_nlpcraft_probe_models.0=examples.LightSwitchModel</code>
- </li>
- <li>
- <b>Program arguments: </b> <code>-probe</code>
- </li>
- </ul>
- <div class="bq info">
- <p>
- <b>NOTE:</b> instead of supplying a <a
href="server-and-probe.html">full configuration file</a> we
- just use the default configuration and override one
configuration property using
- configuration override via environment variables.
- </p>
- </div>
- <p>
- Start this run configuration and make sure you have positive
console output indicating that our model
- has been successfully loaded and probe started.
- </p>
- </section>
- <section id="test">
+<!-- <section id="probe">-->
+<!-- <h3 class="section-title">Start Data Probe</h3>-->
+<!-- <p>-->
+<!-- NLPCraft data models get deployed into data probe. Let's start
data probe to deploy our newly-->
+<!-- created light switch data model. To start data probe we need
to configure Run Configuration in IDEA with-->
+<!-- the following parameters:-->
+<!-- </p>-->
+<!-- <ul>-->
+<!-- <li>-->
+<!-- <b>Main class:</b>
<code>org.apache.nlpcraft.NCStart</code>-->
+<!-- </li>-->
+<!-- <li>-->
+<!-- <b>VM arguments:</b>
<code>-Dconfig.override_with_env_vars=true</code>-->
+<!-- </li>-->
+<!-- <li>-->
+<!-- <b>Environment variable:</b>
<code>CONFIG_FORCE_nlpcraft_probe_models.0=examples.LightSwitchModel</code>-->
+<!-- </li>-->
+<!-- <li>-->
+<!-- <b>Program arguments: </b> <code>-probe</code>-->
+<!-- </li>-->
+<!-- </ul>-->
+<!-- <div class="bq info">-->
+<!-- <p>-->
+<!-- <b>NOTE:</b> instead of supplying a <a
href="server-and-probe.html">full configuration file</a> we-->
+<!-- just use the default configuration and override one
configuration property using-->
+<!-- configuration override via environment variables.-->
+<!-- </p>-->
+<!-- </div>-->
+<!-- <p>-->
+<!-- Start this run configuration and make sure you have positive
console output indicating that our model-->
+<!-- has been successfully loaded and probe started.-->
+<!-- </p>-->
+<!-- </section>-->
+ <section id="server">
<h3 class="section-title">Start REST Server</h3>
<p>
REST server listens for requests from client applications and
routes them to the requested data models
@@ -315,93 +315,58 @@ class LightSwitchModel extends
NCModelFileAdapter("examples/lightswitch_model.ya
convenient unit tests against your data model.
</p>
</section>
- <section>
+ <section id="test">
<h3 class="section-title">Testing</h3>
<p>
- Remember the <a target="javadoc"
href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a>
+ Let's develop a unit test for our model. Remember the <a
target="javadoc"
href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a>
annotation we have used in our Scala code next to intent
definition? Auto-testing utility is relying on it.
-
-
-
-
-
-
-
- NLPCraft comes with easy to use <a target="javadoc"
href="/apis/latest/org/apache/nlpcraft/model/test/package-summary.html">test
framework</a> for data models that can be used with
- any unit testing framework like JUnit or ScalaTest. It is
essentially a simplified
- version of Java REST client that is custom designed for data model
testing.
</p>
<p>
- We would like to test the following user requests:
+ Part of the <a href="/tools/test_framework.html">test
framework</a>, the auto-validator class <a
+ target="javadoc"
+
href="/apis/latest/org/apache/nlpcraft/model/tools/test/NCTestAutoModelValidator.html">NCTestAutoModelValidator</a>
takes one or more model IDs
+ (or class names) and performs validation. Validation consists of
starting an embedded probe with a given model,
+ scanning for <a target="javadoc"
href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a>
annotations
+ and their corresponding callback methods, submitting each sample
input
+ sentences from <a target="javadoc"
href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a>
+ annotation and checking that resulting intent matches the intent
the sample was attached to.
</p>
- <ul>
- <li><code>"Turn the lights off in the entire house."</code></li>
- <li><code>"Switch on the illumination in the master bedroom
closet."</code></li>
- <li><code>"Get the lights on."</code></li>
- <li><code>"Please, put the light out in the upstairs
bedroom."</code></li>
- <li><code>"Set the lights on in the entire house."</code></li>
- <li><code>"Turn the lights off in the guest bedroom."</code></li>
- <li><code>"Could you please switch off all the lights?"</code></li>
- <li><code>"Dial off illumination on the 2nd floor."</code></li>
- <li><code>"Please, no lights!"</code></li>
- <li><code>"Kill off all the lights now!"</code></li>
- <li><code>"No lights in the bedroom, please."</code></li>
- </ul>
<p>
- Let's create new Java class <code>LightSwitchTest.java</code> in
<code>src/<b>test</b>/java/examples</code>
- folder with the following code:
+ Note that auto-testing does not require any additional code to be
written - the class gathers all required information from the model
+ itself.
</p>
- <pre class="brush: java, highlight: [17]">
-package examples;
-
-import org.junit.jupiter.api.*;
-import org.apache.nlpcraft.common.*;
-import org.apache.nlpcraft.model.tools.test.*;
-import java.io.*;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-public class LightSwitchTest {
- private NCTestClient cli;
-
- @BeforeEach
- void setUp() throws NCException, IOException {
- cli = new NCTestClientBuilder().newBuilder().build();
-
- cli.open("nlpcraft.lightswitch.ex");
- }
-
- @AfterEach
- void tearDown() throws NCException, IOException {
- cli.close();
- }
-
- @Test
- public void test() throws NCException, IOException {
- assertTrue(cli.ask("Turn the lights off in the entire house.").isOk());
- assertTrue(cli.ask("Switch on the illumination in the master bedroom
closet.").isOk());
- assertTrue(cli.ask("Get the lights on.").isOk());
- assertTrue(cli.ask("Please, put the light out in the upstairs
bedroom.").isOk());
- assertTrue(cli.ask("Set the lights on in the entire house.").isOk());
- assertTrue(cli.ask("Turn the lights off in the guest
bedroom.").isOk());
- assertTrue(cli.ask("Could you please switch off all the
lights?").isOk());
- assertTrue(cli.ask("Dial off illumination on the 2nd floor.").isOk());
- assertTrue(cli.ask("Please, no lights!").isOk());
- assertTrue(cli.ask("Kill off all the lights now!").isOk());
- assertTrue(cli.ask("No lights in the bedroom, please.").isOk());
- }
-}
- </pre>
<p>
- Right click on this class in the project view and run it. You
should be getting standard output in
- JUnit panel as well as the lights status based on the above
requests.
+ Let's configure IDEA Runtime Configuration (remember - there's no
need to write any additional code here):
+ </p>
+ <ul>
+ <li>
+ <b>Main class:</b>
<code>org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator</code>
+ </li>
+ <li>
+ <b>VM options: </b>
<code>-DNLPCRAFT_TEST_MODELS=examples.LightSwitchModel</code>
+ </li>
+ </ul>
+ <div class="bq info">
+ <p><b>Embedded Probe</b></p>
+ <p>
+ This test (as well as manual test client from <a
href="/tools/test_framework.html">test framework</a>) use
+ <a href="/tools/embedded_probe.html">embedded probe</a> which
automatically
+ starts and stops the data probe from within the tests itself.
However, when not testing you will need
+ to start data probe separately.
+ </p>
+ <p>
+ <b>NOTE:</b> when using this test you don't need to start data
probe standalone.
+ </p>
+ </div>
+ <p>
+ Start this Runtime Configuration and you should be getting
standard log in the output console.
</p>
</section>
<section>
<h2 class="section-title">Congratulation! 👌</h2>
<p>
You've created your first data model, deployed it into the data
probe, started the
- REST server and tested the model using JUnit 5 and the built-in
test framework.
+ REST server and tested the model using built-in model
auto-validator.
</p>
</section>
</div>
@@ -410,6 +375,8 @@ public class LightSwitchTest {
<li class="side-nav-title">On This Page</li>
<li><a href="#setup">Project Setup</a></li>
<li><a href="#data_model">Data Model</a></li>
+ <li><a href="#server">Start Server</a></li>
+ <li><a href="#test">Testing</a></li>
{% include quick-links.html %}
</ul>
</div>