You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by if...@apache.org on 2021/03/25 03:26:38 UTC

[incubator-nlpcraft] 28/29: NPCRAFT-91: Add more examples and small changes in the model

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

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

commit 844a37a4640a4ee963c40aa2129d2a5d9896b921
Author: Ifropc <if...@apache.org>
AuthorDate: Thu Mar 18 19:35:44 2021 -0700

    NPCRAFT-91: Add more examples and small changes in the model
---
 .../java/org/apache/nplcraft/example/ExampleMod.java    |  8 +++-----
 .../org/apache/nlpcraft/example/MinecraftModel.kt       | 17 ++++++++++++++---
 .../minecraft-model/src/main/resources/minecraft.yaml   | 14 ++++++++++----
 3 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/nlpcraft-examples/minecraft-mod/src/main/java/org/apache/nplcraft/example/ExampleMod.java b/nlpcraft-examples/minecraft-mod/src/main/java/org/apache/nplcraft/example/ExampleMod.java
index f76ccd8..91bcbc6 100644
--- a/nlpcraft-examples/minecraft-mod/src/main/java/org/apache/nplcraft/example/ExampleMod.java
+++ b/nlpcraft-examples/minecraft-mod/src/main/java/org/apache/nplcraft/example/ExampleMod.java
@@ -118,11 +118,9 @@ public class ExampleMod {
     }
 
     private Optional<String> getToken() {
-        if (!token.isPresent()) {
-            loadSettings();
+        loadSettings();
 
-            token = post("signin", gson.toJson(creds), NCSignResponse.class).map(x -> x.acsTok);
-        }
+        token = post("signin", gson.toJson(creds), NCSignResponse.class).map(x -> x.acsTok);
 
         return token;
     }
@@ -135,7 +133,7 @@ public class ExampleMod {
             http.setRequestMethod("POST"); // PUT is another valid option
             http.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
             http.setConnectTimeout(1_000);
-            http.setReadTimeout(3_000);
+            http.setReadTimeout(5_000);
 
             http.setDoOutput(true);
             DataOutputStream wr = new DataOutputStream(http.getOutputStream());
diff --git a/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt b/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
index 68efd43..a5b8c88 100644
--- a/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
+++ b/nlpcraft-examples/minecraft-model/src/main/kotlin/org/apache/nlpcraft/example/MinecraftModel.kt
@@ -26,7 +26,12 @@ import java.util.*
 @Suppress("unused")
 class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
     @NCIntentRef("weatherIntent")
-    @NCIntentSample("make it rain")
+    @NCIntentSample(
+        "make it rain",
+        "cast the sun rays",
+        "it's rather rainy today",
+        "heavy storm is coming"
+    )
     fun onWeatherMatch(ctx: NCIntentMatch, @NCIntentTerm("arg") tok: NCToken): NCResult {
         if (ctx.isAmbiguous) {
             throw NCRejection("Ambiguous request")
@@ -36,7 +41,12 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
     }
 
     @NCIntentRef("timeIntent")
-    @NCIntentSample("set time to evening")
+    @NCIntentSample(
+        "set time to evening",
+        "now is evening",
+        "night",
+        "it's midnight"
+    )
     fun onTimeMatch(ctx: NCIntentMatch, @NCIntentTerm("arg") tok: NCToken): NCResult {
         if (ctx.isAmbiguous) {
             throw NCRejection("Ambiguous request")
@@ -59,7 +69,8 @@ class MinecraftModel : NCModelFileAdapter("minecraft.yaml") {
     @NCIntentSample(
         "give me iron sword",
         "give me 10 grass blocks",
-        "give PlayerName a jigsaw"
+        "give PlayerName a jigsaw",
+        "give PlayerName 1 kilogram of feathers"
     )
     fun onGiveMatch(
         ctx: NCIntentMatch,
diff --git a/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml b/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
index e8adef9..a49ba37 100644
--- a/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
+++ b/nlpcraft-examples/minecraft-model/src/main/resources/minecraft.yaml
@@ -44,6 +44,9 @@ elements:
     valueLoader: org.apache.nlpcraft.example.MinecraftObjectValueLoader
 
   # Weather intent
+  - id: weather:action
+    synonyms:
+      - "{make|start|cast}"
   - id: rain
     description: Set rain weather
     groups:
@@ -99,7 +102,8 @@ elements:
   - id: give:action
     synonyms:
       - "{give ^^[target](id == 'mc:player')^^}"
-    "permutateSynonyms": false
+    jiggleFactor: 0
+    permutateSynonyms: false
   - id: give:block-word
     synonyms:
       - "{block|blocks}"
@@ -129,21 +133,23 @@ elements:
       - fill:position
     synonyms:
       - "{{at|near} ^^[player](id == 'mc:player')^^ {position|_}|where ^^[player](id == 'mc:player')^^}"
-    "permutateSynonyms": false
+    jiggleFactor: 0
+    permutateSynonyms: false
 
   - id: position:front
     groups:
       - fill:position
     synonyms:
       - "{{^^[distance](id == 'nlpcraft:num')^^|_} {in|_} front {of|_} ^^[player](id == 'mc:player')^^}"
-    "permutateSynonyms": false
+    jiggleFactor: 0
+    permutateSynonyms: false
 
 
 
 
 # List of model intents.
 intents:
-  - intent=weatherIntent term(arg)={groups @@ 'weather'}
+  - intent=weatherIntent term={id == 'weather:action'}? term(arg)={groups @@ 'weather'}
   - intent=timeIntent term(arg)={groups @@ 'time'}
   - "intent=giveIntent term(action)={id == 'give:action'} term(quantity)={id == 'nlpcraft:num'}?
   term(item)={id == 'mc:item'} term={id == 'give:block-word'}?"