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 016e9fe WIP.
016e9fe is described below
commit 016e9fe249559ed8a67403c90d03c43aee3514f7
Author: Aaron Radzinski <[email protected]>
AuthorDate: Thu Sep 30 13:59:44 2021 -0700
WIP.
---
.../cargps/src/main/resources/cargps_model.yaml | 7 +++-
.../resources/samples/cargps_navigate_samples.txt | 3 ++
.../examples/cargps/NCCarGpsModelSpec.scala | 45 ----------------------
.../test/impl/NCTestAutoModelValidatorImpl.scala | 2 +-
.../nlp/enrichers/NCServerEnrichmentManager.scala | 12 ++++--
5 files changed, 19 insertions(+), 50 deletions(-)
diff --git a/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
b/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
index ccbec6b..c6a0b74 100644
--- a/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
+++ b/nlpcraft-examples/cargps/src/main/resources/cargps_model.yaml
@@ -45,6 +45,7 @@ abstractTokens:
- x:addr:kind
- x:addr:num
- x:addr:st
+ - x:street:addr
elements:
#
@@ -69,10 +70,14 @@ elements:
# Alphanumeric and must be after street number and before street kind.
- "{^^{is_alphanum(tok_txt) && tok_is_between_ids('x:addr:num',
'x:addr:kind') == true}^^}[1,3]"
- - id: "x:addr"
+ - id: "x:street:addr"
synonyms:
- "^^{# == 'x:addr:num'}^^ ^^{# == 'x:addr:st'}^^ ^^{# ==
'x:addr:kind'}^^"
+ - id: "x:addr"
+ synonyms:
+ - "^^{# == 'x:street:addr'}^^ {^^{# == 'nlpcraft:city'}^^}[0,1]"
+
- id: "x:hey"
description: "NLI prompt, salutation."
synonyms:
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 f0827bc..28513e3 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,6 +20,9 @@
#
hey car, navigate to 21 table rock drive
+hey car, navigate to 21 table rock drive, San Francisco
+hey car, navigate to 21 table rock drive, Moscow Russia
+hey car, navigate to 21 table rock drive, San Jose, Uruguay
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
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
deleted file mode 100644
index a3092ae..0000000
---
a/nlpcraft-examples/cargps/src/test/java/org/apache/nlpcraft/examples/cargps/NCCarGpsModelSpec.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.nlpcraft.examples.cargps
-
-import org.apache.nlpcraft.{NCTestContext, NCTestEnvironment}
-import org.junit.jupiter.api.Test
-
-/**
- *
- */
-@NCTestEnvironment(model = classOf[CarGpsModel], startClient = true)
-class NCCarGpsModelSpec extends NCTestContext {
- @Test
- def testNavigate(): Unit = {
- checkIntent("hey truck, drive to 21 x x drive", "navigate")
- checkIntent("hey car, navigate to 21 table rock drive", "navigate")
- checkIntent("howdy, truck - drive to 2121 5th avenue please",
"navigate")
- }
-
- @Test
- def testCancel(): Unit = {
- checkIntent("Hey truck - stop the navigation!", "cancel")
- checkIntent("Howdy, car, please cancel the routing now.", "cancel")
- checkIntent("Hi car - stop the route.", "cancel")
- checkIntent("Hi car - stop the navigation...", "cancel")
- checkIntent("Howdy truck - quit navigating.", "cancel")
- checkIntent("Hi car - finish off the driving.", "cancel")
- checkIntent("Hi car - cancel the journey.", "cancel")
- }
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
index 8cec3ee..11a0837 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/impl/NCTestAutoModelValidatorImpl.scala
@@ -114,7 +114,7 @@ private [test] object NCTestAutoModelValidatorImpl extends
LazyLogging {
val tbl = NCAsciiTable()
- tbl #= ("Model ID", "Intent ID", "+/-", "Text", "Error", "ms.")
+ tbl #= ("Model ID", "Intent ID", "+/-", "Text", "Error", "Msec.")
for (res <- results)
tbl += (
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
index df745a0..1c5e59d 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/NCServerEnrichmentManager.scala
@@ -58,7 +58,7 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
private val HEADERS: Map[String, (Int, Seq[String])] =
Seq(
- "nlpcraft:nlp" -> Seq("origText", "index", "pos", "lemma", "stem",
"bracketed", "quoted", "stopWord"),
+ "nlpcraft:nlp" -> Seq("origText", "index", "pos", "lemma", "stem",
"bracketed", "quoted", "stopWord", "unid"),
"nlpcraft:continent" -> Seq("continent"),
"nlpcraft:subcontinent" -> Seq("continent", "subcontinent"),
"nlpcraft:country" -> Seq("country"),
@@ -154,7 +154,7 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
cache(normTxt) match {
case Some(h) =>
if (h.enabledBuiltInTokens == normEnabledBuiltInToks) {
- prepareAsciiTable(h.sentence).info(logger,
Some(s"Sentence enriched (from cache): '$normTxt'"))
+ prepareAsciiTable(h.sentence).info(logger,
Some(s"Sever-side enrichment (built-in tokens only, from cache): '$normTxt'"))
h.sentence.copy(Some(srvReqId))
}
@@ -181,7 +181,7 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
val typ = n.noteType
val prefix = typ.substring(typ.indexOf(':') + 1) // Remove
'nlpcraft:' prefix.
- n.keySet
+ val hdrs = n.keySet
.filter(name => HEADERS.find(h => isType(typ, h._1)) match {
case Some((_, (_, names))) => names.contains(name)
case None => false
@@ -196,6 +196,12 @@ object NCServerEnrichmentManager extends NCService with
NCIgniteInstance {
name
)
)
+
+ hdrs + Header(
+ "nlp:unid",
+ "nlpcraft:nlp",
+ "unid"
+ )
}
val headers = s.flatten.flatMap(mkNoteHeaders).distinct.sortBy(hdr => {