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 2eb81ad  WIP.
2eb81ad is described below

commit 2eb81adcb947726f885ec39f40677581fde9eb01
Author: Aaron Radzinski <[email protected]>
AuthorDate: Wed Sep 29 23:22:53 2021 -0700

    WIP.
---
 .../nlpcraft/examples/cargps/CarGpsModel.scala     | 38 +++++++++++++++-------
 .../cargps/src/main/resources/cargps_intents.idl   | 18 +++++-----
 .../cargps/src/main/resources/cargps_model.yaml    |  7 ++--
 .../samples/cargps_add_waypoint_samples.txt        |  1 +
 .../resources/samples/cargps_navigate_samples.txt  |  3 ++
 .../samples/cargps_remove_waypoint_samples.txt     |  4 +++
 .../nlpcraft/examples/weather/WeatherModel.java    |  2 +-
 nlpcraft/src/main/python/ctxword/WINDOWS_SETUP.md  |  9 ++---
 .../src/main/python/ctxword/bin/py_requirements    |  2 +-
 9 files changed, 54 insertions(+), 30 deletions(-)

diff --git 
a/nlpcraft-examples/cargps/src/main/java/org/apache/nlpcraft/examples/cargps/CarGpsModel.scala
 
b/nlpcraft-examples/cargps/src/main/java/org/apache/nlpcraft/examples/cargps/CarGpsModel.scala
index 2e79a2b..4d614d9 100644
--- 
a/nlpcraft-examples/cargps/src/main/java/org/apache/nlpcraft/examples/cargps/CarGpsModel.scala
+++ 
b/nlpcraft-examples/cargps/src/main/java/org/apache/nlpcraft/examples/cargps/CarGpsModel.scala
@@ -24,13 +24,17 @@ import org.apache.nlpcraft.model._
  */
 class CarGpsModel extends NCModelFileAdapter("cargps_model.yaml") {
     /**
-     *
-     * @return
-     */
+      *
+      * @param addrTok Address token from the 'navigate' intent.
+      * @return
+      */
     @NCIntentRef("navigate")
     @NCIntentSampleRef("samples/cargps_navigate_samples.txt")
-    def onNavigation(): NCResult = {
-        NCResult.text(s"")
+    def onNavigation(@NCIntentTerm("addr") addrTok: NCToken): NCResult = {
+        // Simulate actual GPS routing...
+        val msg = s"Started navigation to '${addrTok.getNormalizedText}'."
+        println(s"GPS: $msg")
+        NCResult.text(msg)
     }
 
     /**
@@ -40,17 +44,24 @@ class CarGpsModel extends 
NCModelFileAdapter("cargps_model.yaml") {
     @NCIntentRef("cancel")
     @NCIntentSampleRef("samples/cargps_cancel_samples.txt")
     def onCancel(): NCResult = {
-        NCResult.text(s"")
+        // Simulate actual GPS routing...
+        val msg = "Routing cancelled."
+        println(s"GPS: $msg")
+        NCResult.text(msg)
     }
 
     /**
-     *
-     * @return
-     */
+      *
+      * @param addrTok Address token from the 'add:waypoint' intent.
+      * @return
+      */
     @NCIntentRef("add:waypoint")
     @NCIntentSampleRef("samples/cargps_add_waypoint_samples.txt")
-    def onAddWaypoint(): NCResult = {
-        NCResult.text(s"")
+    def onAddWaypoint(@NCIntentTerm("addr") addrTok: NCToken): NCResult = {
+        // Simulate actual GPS routing...
+        val msg = s"Added waypoint for '${addrTok.getNormalizedText}'."
+        println(s"GPS: $msg")
+        NCResult.text(msg)
     }
 
     /**
@@ -60,6 +71,9 @@ class CarGpsModel extends 
NCModelFileAdapter("cargps_model.yaml") {
     @NCIntentRef("remove:waypoint")
     @NCIntentSampleRef("samples/cargps_remove_waypoint_samples.txt")
     def onRemoveWaypoint(): NCResult = {
-        NCResult.text(s"")
+        // Simulate actual GPS routing...
+        val msg = "Removing waypoint."
+        println(s"GPS: $msg")
+        NCResult.text(msg)
     }
 }
diff --git a/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl 
b/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl
index 3eae285..8aa62ad 100644
--- a/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl
+++ b/nlpcraft-examples/cargps/src/main/resources/cargps_intents.idl
@@ -20,28 +20,28 @@
   */
 
 // Reusable fragments.
-fragment=hey term={# == "x:hey" && tok_is_first()}
+fragment=hi term={# == "x:hey" && tok_is_first()}
 
 // Cancel intent.
 intent=cancel
-    fragment(hey) // Always, salutation 1st.
+    fragment(hi) // Always, salutation 1st.
     term={# == "x:cancel"}
 
 // Navigate intent.
 intent=navigate
     options={'ordered': true} // Order of terms is important.
-    fragment(hey) // Always, salutation 1st.
+    fragment(hi) // Always, salutation 1st.
     term={# == "x:navigate"} // Then word 'navigate'.
-    term={# == "x:addr"} // Then where to navigate.
+    term(addr)={# == "x:addr"} // Then where to navigate.
 
 // Add a waypoint intent.
 intent=add:waypoint
-    fragment(hey) // Always, salutation 1st.
+    options={'ordered': true} // Order of terms is important.
+    fragment(hi) // Always, salutation 1st.
     term={# == "x:add-waypoint"}
-    term={# == "x:addr"}
+    term(addr)={# == "x:addr"} // Then where to navigate.
 
-// Remove a waypoint intent.
-// Assumes last waypoint.
+// Remove a waypoint intent (assumes last waypoint).
 intent=remove:waypoint
-    fragment(hey) // Always, salutation 1st.
+    fragment(hi) // Always, salutation 1st.
     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 722103b..ccbec6b 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|journey|plot|drive|route|plan|find|head|ride|direct|steer|operate|sail}
 {out|_} {course|route|destination|drive|_} {to|_}"
+    macro: 
"{go|move|navigate|pilot|journey|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>"
@@ -71,7 +71,7 @@ elements:
 
   - id: "x:addr"
     synonyms:
-      - "^^[num]{# == 'x:addr:num'}^^ ^^[name]{# == 'x:addr:st'}^^ ^^[kind]{# 
== 'x:addr:kind'}^^"
+      - "^^{# == 'x:addr:num'}^^ ^^{# == 'x:addr:st'}^^ ^^{# == 
'x:addr:kind'}^^"
 
   - id: "x:hey"
     description: "NLI prompt, salutation."
@@ -87,12 +87,13 @@ elements:
     description: "Start 'navigate' action."
     synonyms:
       - "<NAVIGATE>"
+      - "{find|give|get|calculate} {me|_} 
{shortest|fastest|quickest|ideal|best|_} 
{navigation|route|path|drive|course|ride}"
 
   - id: "x:add-waypoint"
     description: "Add 'waypoint' action."
     synonyms:
       - "{add|make} <WAYPOINT>"
-      - "stop by"
+      - "stop {by|at}"
 
   - id: "x:remove-waypoint"
     description: "Remove last 'waypoint' action."
diff --git 
a/nlpcraft-examples/cargps/src/main/resources/samples/cargps_add_waypoint_samples.txt
 
b/nlpcraft-examples/cargps/src/main/resources/samples/cargps_add_waypoint_samples.txt
index 4b0c809..adaae9c 100644
--- 
a/nlpcraft-examples/cargps/src/main/resources/samples/cargps_add_waypoint_samples.txt
+++ 
b/nlpcraft-examples/cargps/src/main/resources/samples/cargps_add_waypoint_samples.txt
@@ -20,4 +20,5 @@
 #
 
 hey car, add a stopover at 21 table rock drive
+hey car, let's stop at 11 sunrise meadow plaza
 howdy, truck - add a waypoint for 2121 5th avenue please
diff --git 
a/nlpcraft-examples/cargps/src/main/resources/samples/cargps_navigate_samples.txt
 
b/nlpcraft-examples/cargps/src/main/resources/samples/cargps_navigate_samples.txt
index 0e6f244..f0827bc 100644
--- 
a/nlpcraft-examples/cargps/src/main/resources/samples/cargps_navigate_samples.txt
+++ 
b/nlpcraft-examples/cargps/src/main/resources/samples/cargps_navigate_samples.txt
@@ -20,5 +20,8 @@
 #
 
 hey car, navigate to 21 table rock drive
+hey car, find the best path to 21 table rock drive
+hey car, calculate the shortest navigation to 21 table rock drive
 howdy, truck - drive to 2121 5th avenue please
+howdy, truck - let's go to 11 dark sunrise plaza please
 hi lorry, how about a drive to 21 x x drive
diff --git 
a/nlpcraft-examples/cargps/src/main/resources/samples/cargps_remove_waypoint_samples.txt
 
b/nlpcraft-examples/cargps/src/main/resources/samples/cargps_remove_waypoint_samples.txt
index ac13b37..4878766 100644
--- 
a/nlpcraft-examples/cargps/src/main/resources/samples/cargps_remove_waypoint_samples.txt
+++ 
b/nlpcraft-examples/cargps/src/main/resources/samples/cargps_remove_waypoint_samples.txt
@@ -22,4 +22,8 @@
 hey truck, cancel the last waypoint
 hey truck, cancel the stopover location
 Hi truck - drive without stopping at the last checkpoint
+hi truck - skip the waypoint
+hi truck - skip the latest way station
+hi truck - cancel the checkpoint
+hi car - continue routing without stopping at the last stop over
 
diff --git 
a/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
 
b/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
index 325d428..db2f84b 100644
--- 
a/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
+++ 
b/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
@@ -82,7 +82,7 @@ public class WeatherModel extends NCModelFileAdapter {
      *
      * @param ctx Intent solver context.
      * @param geoTokOpt Optional geo token.
-     * @return Geo location.
+     * @return Geo-location.
      */
     private Pair<Double, Double> prepGeo(NCIntentMatch ctx, Optional<NCToken> 
geoTokOpt) throws NCRejection {
         if (geoTokOpt.isPresent()) {
diff --git a/nlpcraft/src/main/python/ctxword/WINDOWS_SETUP.md 
b/nlpcraft/src/main/python/ctxword/WINDOWS_SETUP.md
index 8eea91b..533f4e3 100644
--- a/nlpcraft/src/main/python/ctxword/WINDOWS_SETUP.md
+++ b/nlpcraft/src/main/python/ctxword/WINDOWS_SETUP.md
@@ -29,14 +29,15 @@ To set up `ctxword` module under Windows, you would need to 
repeat steps from `s
     - `python3`
     - `pip3` (included with the latest versions of python3)
     - `git`
+    - `rust` (install from 
[https://www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install))
  2. Download pre-trained 
[FastText](https://dl.fbaipublicfiles.com/fasttext/vectors-crawl/cc.en.300.bin.gz)
 model.
  3. Extract GZIP model into `data` folder (i.e. 
`/nlpcraft/src/main/python/ctxword/data`).
  4. Git clone [FastText](https://github.com/facebookresearch/fastText.git) 
into some temporary folder.
  5. Ensure that you have [Microsoft Windows 10 
SDK](https://developer.microsoft.com/en-US/windows/downloads/windows-10-sdk/) 
installed. Step 6. will fail unless this SDK is installed.
- 6. Run `pip3 install fastText` (where `fastText` is root of the cloned git 
repository from the previous step).
- 7. Install PyTorch depending on whether you have NVIDIA CUDA support:
-    - Without CUDA support: `pip3 install torch==1.6.0+cpu -f 
https://download.pytorch.org/whl/torch_stable.html`
-    - With CUDA support: `pip3 install torch==1.6.0 -f 
https://download.pytorch.org/whl/torch_stable.html`
+ 6. Run as administrator `pip3 install fastText` (where `fastText` is root of 
the cloned git repository from the previous step).
+ 7. Install PyTorch depending on whether you have NVIDIA CUDA support (check 
the latest 'PyTorch' version):
+    - Without CUDA support: `pip3 install torch==1.9.1+cpu -f 
https://download.pytorch.org/whl/torch_stable.html`
+    - With CUDA support: `pip3 install torch==1.9.1 -f 
https://download.pytorch.org/whl/torch_stable.html`
  8. Install the rest of required python packages from `bin/py_requirements` by 
running `pip3 install -r bin/py_requirements`
  9. You can remove the local clone of FastText git repository after its setup 
is finished.
  
diff --git a/nlpcraft/src/main/python/ctxword/bin/py_requirements 
b/nlpcraft/src/main/python/ctxword/bin/py_requirements
index 1e39f0f..38d4c15 100644
--- a/nlpcraft/src/main/python/ctxword/bin/py_requirements
+++ b/nlpcraft/src/main/python/ctxword/bin/py_requirements
@@ -59,7 +59,7 @@ spacy-legacy==3.0.8
 srsly==2.4.1
 thinc==8.0.8
 tokenizers==0.5.2
-torch==1.6.0
+torch==1.9.1
 tqdm==4.62.0
 transformers==2.7.0
 typer==0.3.2

Reply via email to