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 2021/09/10 18:08:09 UTC

[incubator-nlpcraft] branch NLPCRAFT-384 updated: WIP.

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

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


The following commit(s) were added to refs/heads/NLPCRAFT-384 by this push:
     new 8b3d530  WIP.
8b3d530 is described below

commit 8b3d530fe1f04b6b7f12cb6f94748ab2ef5e8e63
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Fri Sep 10 11:07:59 2021 -0700

    WIP.
---
 .../cargps/src/main/resources/cargps_intents.idl         | 10 +++++-----
 .../cargps/src/main/resources/cargps_model.yaml          | 16 +++++++++++++---
 .../nlpcraft/examples/cargps/NCCarGpsModelSpec.scala     |  2 +-
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl b/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl
index bf82b2c..a736cc9 100644
--- a/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl
+++ b/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl
@@ -20,15 +20,15 @@
   */
 
 // Reusable fragments.
-fragment=hey term={tok_id() == "x:hey" && tok_is_first()}
+fragment=hey term={# == "x:hey" && tok_is_first()}
 
 // Intents.
 intent=int:cancel
     // Ignore any other user or system tokens if we found 'cancel' token.
     options={'unused_usr_toks': true, 'unused_sys_toks': true}
     fragment(hey)
-    term={tok_id() == "x:cancel"}
+    term={# == "x:cancel"}
 
-intent=int:navigate fragment(hey) term={tok_id() == "x:navigate"} term={tok_id() == "x:addr"}
-intent=int:add:waypoint fragment(hey) term={tok_id() == "x:add-waypoint"}
-intent=int:remove:waypoint fragment(hey) term={tok_id() == "x:remove-waypoint"}
\ No newline at end of file
+intent=int:navigate fragment(hey) term={# == "x:navigate"} term={# == "x:addr"}
+intent=int:add:waypoint fragment(hey) term={# == "x:add-waypoint"}
+intent=int:remove:waypoint fragment(hey) term={# == "x:remove-waypoint"}
\ No newline at end of file
diff --git a/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml b/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
index 8f8bde7..e0616f1 100644
--- a/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
+++ b/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
@@ -29,7 +29,7 @@ macros:
   - name: "<HEY>"
     macro: "{hey|hi|howdy}"
   - name: "<NAVIGATE>"
-    macro: "{navigate|pilot|plot|drive|route|plan|find|head|ride|direct|steer|operate|sail} {out|_} {course|route|destination|drive|_}"
+    macro: "{navigate|pilot|plot|drive|route|plan|find|head|ride|direct|steer|operate|sail} {out|_} {course|route|destination|drive|_} {to|_}"
   - name: "<CANCEL>"
     macro: "{cancel|stop|abort|finish|cease|quit} {off|_}"
   - name: "<WAYPOINT>"
@@ -41,6 +41,10 @@ abstractTokens:
   - x:addr:st
 
 elements:
+  #
+  # Address definition.
+  # ===================
+  #
   - id: "x:addr:kind"
     # Short list from https://pe.usps.com/text/pub28/28apc_002.htm
     synonyms:
@@ -50,15 +54,21 @@ elements:
 
   - id: "x:addr:num"
     synonyms:
-      - "^^{tok_id() == 'nlpcraft:num' && meta_tok('nlpcraft:num:unit') == null && meta_tok('nlpcraft:num:isequalcondition')}^^"
+      - "^^{# == 'nlpcraft:num' && meta_tok('nlpcraft:num:unit') == null && meta_tok('nlpcraft:num:isequalcondition')}^^"
 
   - id: "x:addr:st"
+    greedy: false
     synonyms:
       - "{//[a-zA-Z0-9]+//}[1,3]"
 
   - id: "x:addr"
     synonyms:
-      - "^^[num]{tok_id() == 'x:addr:num'}^^ ^^[name]{tok_id() == 'x:addr:st'}^^ ^^[kind]{tok_id() == 'x:addr:kind'}^^"
+      - "^^[num]{# == 'x:addr:num'}^^ ^^[name]{# == 'x:addr:st'}^^ ^^[kind]{# == 'x:addr:kind'}^^"
+
+  #
+  # Address definition.
+  # -------------------
+  #
 
   - id: "x:hey"
     description: "NLI prompt"
diff --git a/nlpcraft-examples/cargps/src/test/java/org/apache/nlpcraft/examples/cargps/NCCarGpsModelSpec.scala b/nlpcraft-examples/cargps/src/test/java/org/apache/nlpcraft/examples/cargps/NCCarGpsModelSpec.scala
index 2e90850..f7f5ca1 100644
--- a/nlpcraft-examples/cargps/src/test/java/org/apache/nlpcraft/examples/cargps/NCCarGpsModelSpec.scala
+++ b/nlpcraft-examples/cargps/src/test/java/org/apache/nlpcraft/examples/cargps/NCCarGpsModelSpec.scala
@@ -24,6 +24,6 @@ import org.junit.jupiter.api.Test
 class NCCarGpsModelSpec extends NCTestContext {
     @Test
     def test(): Unit = {
-        checkIntent("21 x x drive", "int:navigate")
+        checkIntent("hey truck, drive to 21 x x drive", "int:navigate")
     }
 }