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

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


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

commit a5345231a40ff87c6a056865aebfc5dcd07dabe7
Author: skhdl <[email protected]>
AuthorDate: Mon Oct 17 10:24:24 2022 +0400

    WIP.
---
 examples/light_switch.html | 66 +++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 60 insertions(+), 6 deletions(-)

diff --git a/examples/light_switch.html b/examples/light_switch.html
index e66022f..d61c4f1 100644
--- a/examples/light_switch.html
+++ b/examples/light_switch.html
@@ -58,8 +58,8 @@ fa_icon: fa-cube
         <p>Create the following files so that resulting project structure 
would look like the following:</p>
         <ul>
             <li><code>lightswitch_model.yaml</code> - YAML configuration file, 
which contains model description.</li>
-            <li><code>LightSwitchScalaModel.scala</code> - Scala class, model 
implementation.</li>
-            <li><code>LightSwitchScalaModelSpec.scala</code> - Scala tests 
class, which allows to test your model.</li>
+            <li><code>LightSwitchModel.scala</code> - Scala class, model 
implementation.</li>
+            <li><code>LightSwitchModelSpec.scala</code> - Scala tests class, 
which allows to test your model.</li>
         </ul>
         <pre class="brush: plain, highlight: [7, 10, 14]">
             |  build.sbt
@@ -71,11 +71,11 @@ fa_icon: fa-cube
                 |   |  lightswitch_model.yaml
                 |   \--scala
                 |       \--demo
-                |          LightSwitchScalaModel.scala
+                |          LightSwitchModel.scala
                 \---test
                     \---scala
                         \---demo
-                            LightSwitchScalaModelSpec.scala
+                            LightSwitchModelSpec.scala
         </pre>
     </section>
     <section id="model">
@@ -156,7 +156,7 @@ fa_icon: fa-cube
             import org.apache.nlpcraft.*
             import org.apache.nlpcraft.annotations.*
 
-            class LightSwitchScalaModel extends NCModelAdapter(
+            class LightSwitchModel extends NCModelAdapter(
                 NCModelConfig("nlpcraft.lightswitch.java.ex", "LightSwitch 
Example Model", "1.0"),
                 new NCPipelineBuilder().withSemantic("en", 
"lightswitch_model.yaml").build
             ):
@@ -209,8 +209,62 @@ fa_icon: fa-cube
     <section id="testing">
         <h2 class="section-title">Testing <a href="#"><i class="top-link fas 
fa-fw fa-angle-double-up"></i></a></h2>
         <p>
-            Simple test defined in <code>NCModelValidationSpec</code> allows 
to check that all input test sentences are
+            Simple test defined in <code>LightSwitchModelSpec</code> allows to 
check that all input test sentences are
             processed expected way and fire intent <code>ls</code>.
+        </p>
+        <pre class="brush: scala, highlight: [9, 11]">
+            package demo
+
+            import org.apache.nlpcraft.*
+            import org.scalatest.funsuite.AnyFunSuite
+            import scala.util.Using
+
+            class LightSwitchModelSpec extends AnyFunSuite:
+                test("test") {
+                    Using.resource(new NCModelClient(new LightSwitchModel())) 
{ client =>
+                        def check(txt: String): Unit =
+                            require(client.debugAsk(txt, "userId", 
true).getIntentId == "ls")
+
+                        check("Turn the lights off in the entire house.")
+                        check("Turn off all lights now")
+                        check("Switch on the illumination in the master 
bedroom closet.")
+                        check("Get the lights on.")
+                        check("Off the lights on the 1st floor")
+                        check("Lights up in the kitchen.")
+                        check("Please, put the light out in the upstairs 
bedroom.")
+                        check("Set the lights on in the entire house.")
+                        check("Turn the lights off in the guest bedroom.")
+                        check("Could you please switch off all the lights?")
+                        check("Dial off illumination on the 2nd floor.")
+                        check("Turn down lights in 1st floor bedroom")
+                        check("Lights on at second floor kitchen")
+                        check("Please, no lights!")
+                        check("Kill off all the lights now!")
+                        check("Down the lights in the garage")
+                        check("Lights down in the kitchen!")
+                        check("Turn up the illumination in garage and master 
bedroom")
+                        check("Turn down all the light now!")
+                        check("No lights in the bedroom, please.")
+                        check("Light up the garage, please!")
+                        check("Kill the illumination now!")
+                    }
+                }
+        </pre>
+        <ul>
+            <li>
+                On <code>line 9</code> created client for model instance.
+            </li>
+            <li>
+                On <code>line 11</code> called special method 
<code>debugAsk</code>,
+                which was added to main client API for tests reasons.
+                It allows to check detected intent, and its callback 
parameters.
+            </li>
+            <li>
+                On <code>lines 13-24</code> presented model input samples.
+                All of these sentences should fire <code>ls</code> intent of 
given model.
+            </li>
+        </ul>
+        <p>
             You can run this test via SBT task <code>ExecuteTests</code> or 
using IDE.
         </p>
     </section>

Reply via email to