You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/08/19 05:09:00 UTC

[incubator-nlpcraft-website] branch master updated: WIP on docs...

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 8bc8425  WIP on docs...
8bc8425 is described below

commit 8bc8425b4069020045d339c519f05e3b75c3a0f1
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Tue Aug 18 22:08:46 2020 -0700

    WIP on docs...
---
 intent-matching.html | 62 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 36 insertions(+), 26 deletions(-)

diff --git a/intent-matching.html b/intent-matching.html
index 319860c..fd6b25e 100644
--- a/intent-matching.html
+++ b/intent-matching.html
@@ -41,7 +41,7 @@ id: intent_matching
             most specific one as its best match.
         </p>
         <p>
-            In NLPCraft intents are specified using three Java annotations:
+            In NLPCraft intents are specified using the following Java annotations:
         </p>
         <table class="gradient-table">
             <thead>
@@ -52,26 +52,35 @@ id: intent_matching
             </thead>
             <tbody>
                 <tr>
-                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/intent/NCIntent.html">@NCIntent</a></td>
+                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntent.html">@NCIntent</a></td>
                     <td>
                         This annotation defines an intent in-place on the method serving as its callback. It takes a string value
                         that specifies an intent using intent <a href="#syntax">DSL syntax</a>.
                     </td>
                 </tr>
                 <tr>
-                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/intent/NCIntentRed.html">@NCIntentRef</a></td>
+                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntentRed.html">@NCIntentRef</a></td>
                     <td>
                         This annotation allows to reference an intent defined in external JSON or YAML model definition.
-                        Similarly to <a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/intent/NCIntent.html">@NCIntent</a>
+                        Similarly to <a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntent.html">@NCIntent</a>
                         annotation the intent should be defined using <a href="#syntax">DSL syntax</a>.
                     </td>
                 </tr>
                 <tr>
-                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/intent/NCIntentTerm.html">@NCIntentTerm</a></td>
+                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntentTerm.html">@NCIntentTerm</a></td>
                     <td>
                         This annotation annotation marks a formal callback method parameter to receive term's tokens.
                     </td>
                 </tr>
+                <tr>
+                    <td><a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a></td>
+                    <td>
+                        Optional annotation that provides one or more sample of the input that associated intent should match on.
+                        Although this annotation is optional it's highly recommended to provide at least 5 samples per intent.
+                        These samples serve not only documentation purpose but also used in built-in model <a href="/tools/test_framework.html">auto-validation</a>
+                        and model lint tool.
+                    </td>
+                </tr>
             </tbody>
         </table>
         <p>
@@ -79,10 +88,23 @@ id: intent_matching
         </p>
         <p>
              An intent from
-            <a target="github" href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/lightswitch">Light Switch</a> Scala example:
+            <a href="examples/light_switch.html">Light Switch</a> Scala example:
         </p>
         <pre class="brush: java">
             &#64;NCIntent("intent=act conv=false term(act)={groups @@ 'act'} term(loc)={trim(id) == 'ls:loc'}*")
+            &#64;NCIntentSample(Array(
+                "Turn the lights off in the entire house.",
+                "Switch on the illumination in the master bedroom closet.",
+                "Get the lights on.",
+                "Please, put the light out in the upstairs bedroom.",
+                "Set the lights on in the entire house.",
+                "Turn the lights off in the guest bedroom.",
+                "Could you please switch off all the lights?",
+                "Dial off illumination on the 2nd floor.",
+                "Please, no lights!",
+                "Kill off all the lights now!",
+                "No lights in the bedroom, please."
+            ))
             def onMatch(
                 &#64;NCIntentTerm("act") actTok: NCToken,
                 &#64;NCIntentTerm("loc") locToks: List[NCToken]
@@ -123,27 +145,10 @@ id: intent_matching
                 method parameters to automatically assign terms' tokens to the formal method parameters using <code>@NCIntentTerm</code>
                 annotations.
             </li>
-            <li>
-                Given the <a target="github" href="https://github.com/apache/incubator-nlpcraft/blob/master/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml">data model</a>
-                from this <a target="github" href="https://github.com/apache/incubator-nlpcraft/blob/master/src/main/scala/org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml">example</a> the following sentences will be matched by this intent:
-                <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>
-            </li>
         </ul>
         <br/>
         <p>
-            In the following <a target="github" href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm">Alarm Clock</a> Java example
+            In the following <a href="examples/alarm_clock.html">Alarm Clock</a> Java example
             the intent is defined in JSON model definition and referenced in Java code using <code>@NCIntentTerm</code>
             annotation:
         </p>
@@ -172,6 +177,11 @@ id: intent_matching
         </pre>
         <pre class="brush: java, highlight: [1]">
             &#64;NCIntentRef("alarm")
+            &#64;NCIntentSample({
+                "Ping me in 3 minutes",
+                "Buzz me in an hour and 15mins",
+                "Set my alarm for 30s"
+            })
             private NCResult onMatch(
                NCIntentMatch ctx,
                &#64;NCIntentTerm("nums") List&lt;NCToken&gt; numToks
@@ -206,7 +216,7 @@ id: intent_matching
             </li>
             <li>
                 Second term is defined as a zero or up to seven numeric built-in <code>nlpcraft:num</code> tokens that
-                have unit type of <code>datetime</code> and are single numbers. Note that <a target="github" href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm">Alarm Clock</a>
+                have unit type of <code>datetime</code> and are single numbers. Note that <a href="examples/alarm_clock.html">Alarm Clock</a>
                 model allows zero tokens in this term which would mean the current time.
             </li>
             <li>
@@ -500,7 +510,7 @@ id: intent_matching
                 Intent has ID <code>id1</code>.
             </li>
             <li>
-                Intent has uses default conversational support (<code>true</code>) and default order (<code>false</code>).
+                Intent uses default conversational support (<code>true</code>) and default order (<code>false</code>).
             </li>
             <li>
                 Intent has two terms that have to be found for the intent to match. Note that second term is optional as it