Intents IDL `options` tests added.
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCFreeWordsSpec.scala
similarity index 70%
copy from nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
copy to nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCFreeWordsSpec.scala
index ad71333..0fd8c4c 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCFreeWordsSpec.scala
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model.intent.idl
+package org.apache.nlpcraft.model.intent.idl.options
import org.apache.nlpcraft.model.`abstract`.NCAbstractTokensModel
import org.apache.nlpcraft.model.meta.NCMetaSpecAdapter
@@ -25,26 +25,25 @@
import java.util
-class NCIdlIntentOptionsModel extends NCAbstractTokensModel {
+class NCFreeWordsModel extends NCAbstractTokensModel {
override def getElements: util.Set[NCElement] = Set(
- NCTestElement("i1_a"),
- NCTestElement("i1_b"),
-
- NCTestElement("i2_a"),
- NCTestElement("i2_b")
+ NCTestElement("a"),
+ NCTestElement("b"),
+ NCTestElement("c"),
+ NCTestElement("d")
)
@NCIntent(
"intent=i1 " +
" options={" +
- " 'ordered': true, " +
- " 'unused_free_words': false, " +
+ " 'ordered': false, " +
+ " 'unused_free_words': true, " +
" 'unused_sys_toks': false, " +
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i1_a'}" +
- " term(b)={tok_id() == 'i1_b'}"
+ " term(a)={tok_id() == 'a'}" +
+ " term(b)={tok_id() == 'b'}"
)
def i1(): NCResult = NCResult.text("i1")
@@ -57,20 +56,20 @@
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i2_a'}" +
- " term(b)={tok_id() == 'i2_b'}"
+ " term(a)={tok_id() == 'c'}" +
+ " term(b)={tok_id() == 'd'}"
)
def i2(): NCResult = NCResult.text("i2")
}
-@NCTestEnvironment(model = classOf[NCIdlIntentOptionsModel], startClient = true)
-class NCIdlIntentOptionsSpec extends NCMetaSpecAdapter {
+@NCTestEnvironment(model = classOf[NCFreeWordsModel], startClient = true)
+class NCFreeWordsSpec extends NCMetaSpecAdapter {
@Test
def test(): Unit = {
- checkResult("i1_a i1_b", "i1")
- checkFail("i1_b i1_a")
+ checkResult("a b", "i1")
+ checkResult("a test b", "i1")
- checkResult("i2_a i2_b", "i2")
- checkResult("i2_b i2_a", "i2")
+ checkResult("c d", "i2")
+ checkFail("c test d")
}
}
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCOrderedSpec.scala
similarity index 73%
rename from nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
rename to nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCOrderedSpec.scala
index ad71333..0076a99 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCOrderedSpec.scala
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model.intent.idl
+package org.apache.nlpcraft.model.intent.idl.options
import org.apache.nlpcraft.model.`abstract`.NCAbstractTokensModel
import org.apache.nlpcraft.model.meta.NCMetaSpecAdapter
@@ -25,13 +25,12 @@
import java.util
-class NCIdlIntentOptionsModel extends NCAbstractTokensModel {
+class NCOrderedModel extends NCAbstractTokensModel {
override def getElements: util.Set[NCElement] = Set(
- NCTestElement("i1_a"),
- NCTestElement("i1_b"),
-
- NCTestElement("i2_a"),
- NCTestElement("i2_b")
+ NCTestElement("a"),
+ NCTestElement("b"),
+ NCTestElement("c"),
+ NCTestElement("d")
)
@NCIntent(
@@ -43,8 +42,8 @@
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i1_a'}" +
- " term(b)={tok_id() == 'i1_b'}"
+ " term(a)={tok_id() == 'a'}" +
+ " term(b)={tok_id() == 'b'}"
)
def i1(): NCResult = NCResult.text("i1")
@@ -57,20 +56,20 @@
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i2_a'}" +
- " term(b)={tok_id() == 'i2_b'}"
+ " term(a)={tok_id() == 'c'}" +
+ " term(b)={tok_id() == 'd'}"
)
def i2(): NCResult = NCResult.text("i2")
}
-@NCTestEnvironment(model = classOf[NCIdlIntentOptionsModel], startClient = true)
-class NCIdlIntentOptionsSpec extends NCMetaSpecAdapter {
+@NCTestEnvironment(model = classOf[NCOrderedModel], startClient = true)
+class NCOrderedSpec extends NCMetaSpecAdapter {
@Test
def test(): Unit = {
- checkResult("i1_a i1_b", "i1")
- checkFail("i1_b i1_a")
+ checkResult("a b", "i1")
+ checkFail("b a")
- checkResult("i2_a i2_b", "i2")
- checkResult("i2_b i2_a", "i2")
+ checkResult("c d", "i2")
+ checkResult("d c", "i2")
}
}
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStemOnlySpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStemOnlySpec.scala
new file mode 100644
index 0000000..604d4ca
--- /dev/null
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStemOnlySpec.scala
@@ -0,0 +1,115 @@
+/*
+ * 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
+ *
+ * https://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.model.intent.idl.options
+
+import org.apache.nlpcraft.model.`abstract`.NCAbstractTokensModel
+import org.apache.nlpcraft.model.meta.NCMetaSpecAdapter
+import org.apache.nlpcraft.model.{NCElement, NCIntent, NCResult}
+import org.apache.nlpcraft.{NCTestElement, NCTestEnvironment}
+import org.junit.jupiter.api.Test
+
+import java.util
+
+class NCStmOnlyModel extends NCAbstractTokensModel {
+ override def getElements: util.Set[NCElement] = Set(
+ NCTestElement("a"),
+ NCTestElement("b"),
+ NCTestElement("c"),
+ NCTestElement("d")
+ )
+
+ @NCIntent(
+ "intent=before " +
+ " options={" +
+ " 'ordered': false, " +
+ " 'unused_free_words': false, " +
+ " 'unused_sys_toks': false, " +
+ " 'unused_usr_toks': false, " +
+ " 'allow_stm_only': false" +
+ " }" +
+ " term(a)={tok_id() == 'a'}" +
+ " term(b)={tok_id() == 'b'} " +
+ " term(c)={tok_id() == 'c'} " +
+ " term(d)={tok_id() == 'd'}"
+ )
+ def before(): NCResult = NCResult.text("before")
+
+ @NCIntent(
+ "intent=i1 " +
+ " options={" +
+ " 'ordered': false, " +
+ " 'unused_free_words': false, " +
+ " 'unused_sys_toks': false, " +
+ " 'unused_usr_toks': false, " +
+ " 'allow_stm_only': true" +
+ " }" +
+ " term(a)={tok_id() == 'a'}" +
+ " term(b)={tok_id() == 'b'}"
+ )
+ def i1(): NCResult = NCResult.text("i1")
+
+ @NCIntent(
+ "intent=i2 " +
+ " options={" +
+ " 'ordered': false, " +
+ " 'unused_free_words': false, " +
+ " 'unused_sys_toks': false, " +
+ " 'unused_usr_toks': false, " +
+ " 'allow_stm_only': false" +
+ " }" +
+ " term(a)={tok_id() == 'c'}" +
+ " term(b)={tok_id() == 'd'}"
+ )
+ def i2(): NCResult = NCResult.text("i2")
+}
+
+@NCTestEnvironment(model = classOf[NCStmOnlyModel], startClient = true)
+class NCStmOnlySpec extends NCMetaSpecAdapter {
+ private def clear(): Unit = {
+ val client = getClient
+
+ client.clearConversation()
+ client.clearDialog()
+ }
+
+ @Test
+ def test1(): Unit = {
+ clear()
+
+ checkResult("a b c d", "before")
+
+ checkResult("a b", "i1")
+
+ clear()
+
+ checkFail("a b", "i1")
+ }
+
+ @Test
+ def test2(): Unit = {
+ clear()
+
+ checkResult("a b c d", "before")
+
+ checkResult("c d", "i2")
+
+ clear()
+
+ checkResult("c d", "i2")
+ }
+}
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCSysTokensSpec.scala
similarity index 70%
copy from nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
copy to nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCSysTokensSpec.scala
index ad71333..8c7e9ec 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCSysTokensSpec.scala
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model.intent.idl
+package org.apache.nlpcraft.model.intent.idl.options
import org.apache.nlpcraft.model.`abstract`.NCAbstractTokensModel
import org.apache.nlpcraft.model.meta.NCMetaSpecAdapter
@@ -25,26 +25,25 @@
import java.util
-class NCIdlIntentOptionsModel extends NCAbstractTokensModel {
+class NCSysTokensModel extends NCAbstractTokensModel {
override def getElements: util.Set[NCElement] = Set(
- NCTestElement("i1_a"),
- NCTestElement("i1_b"),
-
- NCTestElement("i2_a"),
- NCTestElement("i2_b")
+ NCTestElement("a"),
+ NCTestElement("b"),
+ NCTestElement("c"),
+ NCTestElement("d")
)
@NCIntent(
"intent=i1 " +
" options={" +
- " 'ordered': true, " +
+ " 'ordered': false, " +
" 'unused_free_words': false, " +
- " 'unused_sys_toks': false, " +
+ " 'unused_sys_toks': true, " +
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i1_a'}" +
- " term(b)={tok_id() == 'i1_b'}"
+ " term(a)={tok_id() == 'a'}" +
+ " term(b)={tok_id() == 'b'}"
)
def i1(): NCResult = NCResult.text("i1")
@@ -57,20 +56,20 @@
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i2_a'}" +
- " term(b)={tok_id() == 'i2_b'}"
+ " term(a)={tok_id() == 'c'}" +
+ " term(b)={tok_id() == 'd'}"
)
def i2(): NCResult = NCResult.text("i2")
}
-@NCTestEnvironment(model = classOf[NCIdlIntentOptionsModel], startClient = true)
-class NCIdlIntentOptionsSpec extends NCMetaSpecAdapter {
+@NCTestEnvironment(model = classOf[NCSysTokensModel], startClient = true)
+class NCSysTokensSpec extends NCMetaSpecAdapter {
@Test
def test(): Unit = {
- checkResult("i1_a i1_b", "i1")
- checkFail("i1_b i1_a")
+ checkResult("a b", "i1")
+ checkResult("a today b", "i1")
- checkResult("i2_a i2_b", "i2")
- checkResult("i2_b i2_a", "i2")
+ checkResult("c d", "i2")
+ checkFail("c today d")
}
}
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCUserTokensSpec.scala
similarity index 70%
copy from nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
copy to nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCUserTokensSpec.scala
index ad71333..29b034e 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/NCIdlIntentOptionsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCUserTokensSpec.scala
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model.intent.idl
+package org.apache.nlpcraft.model.intent.idl.options
import org.apache.nlpcraft.model.`abstract`.NCAbstractTokensModel
import org.apache.nlpcraft.model.meta.NCMetaSpecAdapter
@@ -25,26 +25,25 @@
import java.util
-class NCIdlIntentOptionsModel extends NCAbstractTokensModel {
+class NCUserTokensModel extends NCAbstractTokensModel {
override def getElements: util.Set[NCElement] = Set(
- NCTestElement("i1_a"),
- NCTestElement("i1_b"),
-
- NCTestElement("i2_a"),
- NCTestElement("i2_b")
+ NCTestElement("a"),
+ NCTestElement("b"),
+ NCTestElement("c"),
+ NCTestElement("d")
)
@NCIntent(
"intent=i1 " +
" options={" +
- " 'ordered': true, " +
+ " 'ordered': false, " +
" 'unused_free_words': false, " +
" 'unused_sys_toks': false, " +
- " 'unused_usr_toks': false, " +
+ " 'unused_usr_toks': true, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i1_a'}" +
- " term(b)={tok_id() == 'i1_b'}"
+ " term(a)={tok_id() == 'a'}" +
+ " term(b)={tok_id() == 'b'}"
)
def i1(): NCResult = NCResult.text("i1")
@@ -57,20 +56,20 @@
" 'unused_usr_toks': false, " +
" 'allow_stm_only': false" +
" }" +
- " term(a)={tok_id() == 'i2_a'}" +
- " term(b)={tok_id() == 'i2_b'}"
+ " term(a)={tok_id() == 'c'}" +
+ " term(b)={tok_id() == 'd'}"
)
def i2(): NCResult = NCResult.text("i2")
}
-@NCTestEnvironment(model = classOf[NCIdlIntentOptionsModel], startClient = true)
-class NCIdlIntentOptionsSpec extends NCMetaSpecAdapter {
+@NCTestEnvironment(model = classOf[NCUserTokensModel], startClient = true)
+class NCUserTokensSpec extends NCMetaSpecAdapter {
@Test
def test(): Unit = {
- checkResult("i1_a i1_b", "i1")
- checkFail("i1_b i1_a")
+ checkResult("a b", "i1")
+ checkResult("a d b", "i1")
- checkResult("i2_a i2_b", "i2")
- checkResult("i2_b i2_a", "i2")
+ checkResult("c d", "i2")
+ checkFail("c a d")
}
}