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/21 04:33:40 UTC

[incubator-nlpcraft] branch NLPCRAFT-41 updated: Improved weather example.

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

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


The following commit(s) were added to refs/heads/NLPCRAFT-41 by this push:
     new 2e0d677  Improved weather example.
2e0d677 is described below

commit 2e0d67791d0df07a3f8c1d0b46bcb9a80da02dd6
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Thu Aug 20 21:33:31 2020 -0700

    Improved weather example.
---
 .../nlpcraft/examples/weather/WeatherModel.java    | 24 ++++++++--------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherModel.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherModel.java
index 98dc82b..123b1f9 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherModel.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherModel.java
@@ -114,21 +114,13 @@ public class WeatherModel extends NCModelFileAdapter {
     }
 
     /**
-     * Strict check for an exact match (i.e. no dangling unused system or user defined tokens) and
-     * maximum number of free words left unmatched. In both cases user input will be rejected.
+     * A callback for the intent match.
      *
-     * @param ctx Solver context.
-     */
-    private void checkMatch(NCIntentMatch ctx) {
-        // Reject if intent match is not exact (at least one "dangling" token remain).
-        if (ctx.isAmbiguous())
-            throw new NCRejection("Please clarify your request.");
-    }
-
-    /**
-     *
-     * @param ctx
-     * @return
+     * @param ctx Intent match context.
+     * @param indToksOpt List of optional indicator elements.
+     * @param cityTokOpt Optional GEO token for city.
+     * @param dateTokOpt Optional date token.
+     * @return Callback result.
      */
     @NCIntent(
         "intent=req " +
@@ -162,7 +154,9 @@ public class WeatherModel extends NCModelFileAdapter {
         @NCIntentTerm("city") Optional<NCToken> cityTokOpt,
         @NCIntentTerm("date") Optional<NCToken> dateTokOpt
     ) {
-        checkMatch(ctx);
+        // Reject if intent match is not exact (at least one "dangling" token remain).
+        if (ctx.isAmbiguous())
+            throw new NCRejection("Please clarify your request.");
 
         try {
             Instant now = Instant.now();