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/09/12 23:31:38 UTC

[incubator-nlpcraft] branch NLPCRAFT-41 updated: Update TimeModel.java

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 53b0da8  Update TimeModel.java
53b0da8 is described below

commit 53b0da8f0bb09ed2e6c98ff01b7c491232c06580
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sat Sep 12 16:31:25 2020 -0700

    Update TimeModel.java
---
 .../apache/nlpcraft/examples/time/TimeModel.java   | 54 +++++++++++-----------
 1 file changed, 27 insertions(+), 27 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.java
index 8835e4b..f09304c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.java
@@ -87,6 +87,33 @@ public class TimeModel extends NCModelFileAdapter {
     }
 
     /**
+     * Callback on remote time intent match.
+     *
+     * @param cityTok Token for 'geo' term.
+     * @return Query result.
+     */
+    @NCIntent("intent=intent2 conv=true term={id=='x:time'} term(city)={id=='nlpcraft:city'}")
+    @NCIntentSample({
+        "What time is it now in New York City?",
+        "What's the current time in Moscow?",
+        "Show me time of the day in London.",
+        "Can you please give me the San Francisco's current date and time."
+    })
+    private NCResult onRemoteMatch(@NCIntentTerm("city") NCToken cityTok) {
+        String city = cityTok.meta("nlpcraft:city:city");
+        String cntry = cityTok.meta("nlpcraft:city:country");
+
+        CityData data = citiesData.get(new City(city, cntry));
+
+        if (data != null)
+            return mkResult(city, cntry, data.getTimezone(), data.getLatitude(), data.getLongitude());
+
+        // We don't have timezone mapping for parsed GEO location.
+        // Instead of defaulting to a local time - we reject with a specific error message for cleaner UX.
+        throw new NCRejection(String.format("No timezone mapping for %s, %s.", city, cntry));
+    }
+    
+    /**
      * Callback on local time intent match.
      *
      * @param ctx Intent solver context.
@@ -119,31 +146,4 @@ public class TimeModel extends NCModelFileAdapter {
             geo.getCityName(), geo.getCountryName(), geo.getTimezoneName(), geo.getLatitude(), geo.getLongitude()
         );
     }
-
-    /**
-     * Callback on remote time intent match.
-     *
-     * @param cityTok Token for 'geo' term.
-     * @return Query result.
-     */
-    @NCIntent("intent=intent2 term={id=='x:time'} term(city)={id=='nlpcraft:city'}")
-    @NCIntentSample({
-        "What time is it now in New York City?",
-        "What's the current time in Moscow?",
-        "Show me time of the day in London.",
-        "Can you please give me the San Francisco's current date and time."
-    })
-    private NCResult onRemoteMatch(@NCIntentTerm("city") NCToken cityTok) {
-        String city = cityTok.meta("nlpcraft:city:city");
-        String cntry = cityTok.meta("nlpcraft:city:country");
-
-        CityData data = citiesData.get(new City(city, cntry));
-
-        if (data != null)
-            return mkResult(city, cntry, data.getTimezone(), data.getLatitude(), data.getLongitude());
-
-        // We don't have timezone mapping for parsed GEO location.
-        // Instead of defaulting to a local time - we reject with a specific error message for cleaner UX.
-        throw new NCRejection(String.format("No timezone mapping for %s, %s.", city, cntry));
-    }
 }