This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-369
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-369 by this push:
new 7551efb WIP on NLPCRAFT-369.
7551efb is described below
commit 7551efbd78848602d033d7d301a9220f00eab096
Author: Aaron Radzinski <[email protected]>
AuthorDate: Tue Jul 27 00:05:35 2021 -0700
WIP on NLPCRAFT-369.
---
.../nlpcraft/common/config/NCConfigurable.scala | 2 +-
.../scala/org/apache/nlpcraft/NCTestContext.scala | 7 ++-
.../model/intent/idl/options/NCStmOnlySpec.scala | 21 ++++++--
.../model/properties/NCTokensPropertiesSpec.scala | 60 ++++++++++------------
4 files changed, 48 insertions(+), 42 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurable.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurable.scala
index 537148e..f7c6ef7 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurable.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurable.scala
@@ -330,7 +330,7 @@ object NCConfigurable extends LazyLogging {
val lines =
U.splitTrimFilter(cfg.origin().description(),",").drop(1).distinct
- logger.info(s"NLPCraft configuration successfully loaded as a
merge of: ${lines.mkString("\n +-- ", "\n +-- ", "")}")
+ logger.info(s"NLPCraft configuration successfully loaded as a
merge of: ${lines.mkString(s"\n ${c("+--")} ", s"\n ${c("+--")} ", "")}")
}
// Set parsed configuration into Java shim.
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
index ceae8a7..74e0345 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/NCTestContext.scala
@@ -133,11 +133,10 @@ abstract class NCTestContext {
/**
*
- * @param txts
+ * @param txt
*/
- protected def checkFail(txts: String*): Unit =
- for (txt <- txts)
- require(getClient.ask(txt).isFailed)
+ protected def checkFail(txt: String): Unit =
+ require(getClient.ask(txt).isFailed)
/**
* @param req
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
index e41f938..33c670b 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
@@ -43,8 +43,8 @@ class NCStmOnlyModel extends NCAbstractTokensModel {
" 'allow_stm_only': false" +
" }" +
" term(a)={tok_id() == 'a'}" +
- " term(b)={tok_id() == 'b'} " +
- " term(c)={tok_id() == 'c'} " +
+ " term(b)={tok_id() == 'b'}" +
+ " term(c)={tok_id() == 'c'}" +
" term(d)={tok_id() == 'd'}"
)
def before(): NCResult = NCResult.text("before")
@@ -97,7 +97,8 @@ class NCStmOnlySpec extends NCMetaSpecAdapter {
// This should match as 'i1' intent allows:
// - unmatched free words, and
- // - all of its matched tokens to come from STM
+ // - all of its matched tokens to come from STM, and
+ // - its terms are conversational (~).
checkResult("x y", "i1")
}
@@ -112,4 +113,18 @@ class NCStmOnlySpec extends NCMetaSpecAdapter {
checkResult("c d", "i2")
}
+
+ @Test
+ def test3(): Unit = {
+ clear()
+
+ checkResult("a b c d", "before")
+ checkResult("b a d c", "before")
+ checkResult("a b", "i1")
+
+ clear()
+
+ // This should NOT match because STM is cleared.
+ checkFail("x y")
+ }
}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/properties/NCTokensPropertiesSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/properties/NCTokensPropertiesSpec.scala
index 5ab3635..cd7055f 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/properties/NCTokensPropertiesSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/properties/NCTokensPropertiesSpec.scala
@@ -86,19 +86,17 @@ class NCTokenPropertiesModel2Spec extends NCTestContext {
def test(): Unit = {
checkIntent("a b", "onAB")
checkIntent("a test test b", "onAB")
- checkFail(
- "b a",
- "b test test a"
- )
+
+ checkFail("b a")
+ checkFail("b test test a")
checkIntent("x y", "onXY")
checkIntent("x test test y", "onXY")
- checkFail(
- "b a",
- "b test test a",
- "y x",
- "y test test x"
- )
+
+ checkFail("b a")
+ checkFail("b test test a")
+ checkFail("y x")
+ checkFail("y test test x")
}
}
@@ -117,17 +115,14 @@ class NCTokenPropertiesModel3Spec extends NCTestContext {
checkIntent("y x", "onXY")
checkIntent("x y", "onXY")
- checkFail(
- "a test b",
- "b test a",
- "x test y",
- "y test x",
- "a test test b",
- "b test test a",
- "x test test y",
- "y test test x"
-
- )
+ checkFail("a test b")
+ checkFail("b test a")
+ checkFail("x test y")
+ checkFail("y test x")
+ checkFail("a test test b")
+ checkFail("b test test a")
+ checkFail("x test test y")
+ checkFail("y test test x")
}
}
@@ -142,11 +137,10 @@ class NCTokenPropertiesModel4Spec extends NCTestContext {
@Test
def test(): Unit = {
checkIntent("a b", "onAB")
- checkFail(
- "b a",
- "a test b",
- "b test a"
- )
+
+ checkFail("b a")
+ checkFail("a test b")
+ checkFail("b test a")
}
}
@@ -205,17 +199,15 @@ class NCTokenPropertiesModel6Spec extends NCTestContext {
checkIntent("y x", "onXY")
checkIntent("x y", "onXY")
- checkFail(
- "a test b",
- "b test a"
- )
+ checkFail("a test b")
+ checkFail("b test a")
+
checkIntent("y test x", "onXY")
checkIntent("x test y", "onXY")
- checkFail(
- "a test test b",
- "b test test a"
- )
+ checkFail("a test test b")
+ checkFail("b test test a")
+
checkIntent("y test test x", "onXY")
checkIntent("x test test y", "onXY")
}