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/11 05:34:23 UTC
[incubator-nlpcraft] branch NLPCRAFT-41 updated: WIP on adding
intent examples.
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 451b456 WIP on adding intent examples.
451b456 is described below
commit 451b4568d15a9951c4b3c07b6a131a1eaa81fd58
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Mon Aug 10 22:34:10 2020 -0700
WIP on adding intent examples.
---
.../examples/misc/darksky/DarkSkyException.java | 10 ++++++----
.../nlpcraft/examples/misc/darksky/DarkSkyService.java | 18 +++++++++---------
.../apache/nlpcraft/examples/weather/WeatherModel.java | 14 ++++++++------
3 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyException.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyException.java
index 69c6a2d..239bb1d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyException.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyException.java
@@ -22,17 +22,19 @@ package org.apache.nlpcraft.examples.misc.darksky;
*/
public class DarkSkyException extends RuntimeException {
/**
+ * Creates new exception.
*
- * @param msg
+ * @param msg Error message.
*/
public DarkSkyException(String msg) {
super(msg);
}
/**
- *
- * @param msg
- * @param cause
+ * Creates new exceptions.
+ *
+ * @param msg Error message.
+ * @param cause Optional cause.
*/
public DarkSkyException(String msg, Throwable cause) {
super(msg, cause);
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyService.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyService.java
index 1743029..c58bdb9 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyService.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/darksky/DarkSkyService.java
@@ -51,22 +51,22 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
* Dark Sky API weather provider. See https://darksky.net/dev/docs#overview for details.
*/
public class DarkSkyService {
- /** */
+ // GSON response type.
+ private static final Type TYPE_RESP = new TypeToken<HashMap<String, Object>>() {}.getType();
+
+ // Access key.
private final String key;
- /** */
+ // Maximum days in seconds.
private final int maxDaysSecs;
- /** */
+ // HTTP client instance.
private final CloseableHttpClient httpClient;
- /** */
- private static final Type TYPE_RESP = new TypeToken<HashMap<String, Object>>() {}.getType();
-
- /** */
+ // GSON instance.
private static final Gson GSON = new Gson();
- /** */
+ // Date formatter.
private static final DateTimeFormatter FMT =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss").withZone(ZoneId.systemDefault());
@@ -98,7 +98,7 @@ public class DarkSkyService {
/**
* Constructor.
*
- * @param key Service key.
+ * @param key Service key.
* @param maxDays Max days configuration value.
*/
public DarkSkyService(String key, int maxDays) {
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 b9526f6..d2faf3a 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
@@ -32,7 +32,7 @@ import static java.time.temporal.ChronoUnit.DAYS;
/**
* Weather example data model.
* <p>
- * This is relatively complete weather service with JSON output and a non-trivial
+ * This is a relatively complete weather service with JSON output and a non-trivial
* intent matching logic. It uses Apple's Dark Sky API weather provider REST service for the actual
* weather information (https://darksky.net/dev/docs#overview)
* <p>
@@ -215,9 +215,11 @@ public class WeatherModel extends NCModelFileAdapter {
* @param ctx Intent solver context.
* @return Query result.
*/
- @NCIntent("intent=fcast term={id == 'wt:fcast'} term(city)={id == 'nlpcraft:city'}? term(date)={id == 'nlpcraft:date'}?")
+ @NCIntent("intent=fcast conv=true term={id == 'wt:fcast'} term(city)={id == 'nlpcraft:city'}? term(date)={id == 'nlpcraft:date'}?")
@NCIntentSample({
- "What's the weather forecast in Moscow?"
+ "What's the weather forecast in Moscow?",
+ "Will it be hot next Sunday?",
+ "How about a rain next week in London"
})
public NCResult onForecastMatch(
NCIntentMatch ctx,
@@ -233,9 +235,9 @@ public class WeatherModel extends NCModelFileAdapter {
* @param ctx Intent solver context.
* @return Query result.
*/
- @NCIntent("intent=hist term={id == 'wt:hist'} term(city)={id == 'nlpcraft:city'}? term(date)={id == 'nlpcraft:date'}?")
+ @NCIntent("intent=hist conv=true term={id == 'wt:hist'} term(city)={id == 'nlpcraft:city'}? term(date)={id == 'nlpcraft:date'}?")
@NCIntentSample({
- "What the weather history in Mosco last week?"
+ "What the weather history in Moscow last week?"
})
public NCResult onHistoryMatch(
NCIntentMatch ctx,
@@ -251,7 +253,7 @@ public class WeatherModel extends NCModelFileAdapter {
* @param ctx Intent solver context.
* @return Query result.
*/
- @NCIntent("intent=curr term={id == 'wt:curr'} term(city)={id == 'nlpcraft:city'}? term(date)={id == 'nlpcraft:date'}?")
+ @NCIntent("intent=curr conv=true term={id == 'wt:curr'} term(city)={id == 'nlpcraft:city'}? term(date)={id == 'nlpcraft:date'}?")
@NCIntentSample({
"What's the current weather in Moscow"
})