You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2021/09/18 09:05:17 UTC

[incubator-nlpcraft] 06/08: WIP.

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

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

commit c0d3b7cf8bf2c6974a2631d4c1a02a5db44583d9
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Fri Sep 17 12:11:29 2021 +0300

    WIP.
---
 .../nlpcraft/model/stop/NCStopWordsBaseSpec.scala  | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsBaseSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsBaseSpec.scala
new file mode 100644
index 0000000..07ca216
--- /dev/null
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsBaseSpec.scala
@@ -0,0 +1,73 @@
+/*
+ * 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.stop
+
+import org.apache.nlpcraft.model.{NCElement, NCIntent, NCModelAdapter, NCResult}
+import org.apache.nlpcraft.{NCTestContext, NCTestElement, NCTestEnvironment}
+import org.junit.jupiter.api.Test
+
+import java.util
+import scala.language.implicitConversions
+
+/**
+  *
+  */
+class NCStopWordsBaseModel extends NCModelAdapter("nlpcraft.test", "Test Model", "1.0") {
+    override def getElements: util.Set[NCElement] = Set(
+        NCTestElement("a"),
+        NCTestElement("b"),
+        NCTestElement("xy", "x y"),
+    )
+
+    @NCIntent(
+        "intent=twoWords " +
+        "    term(a)~{# == 'a'}" +
+        "    term(b)~{# == 'b'}"
+    )
+    def onTwoWords(): NCResult = NCResult.text("OK")
+
+    @NCIntent(
+        "intent=oneWord " +
+        "    term(xt)~{# == 'xy'}"
+    )
+    def onOneWord(): NCResult = NCResult.text("OK")
+}
+
+/**
+  *
+  */
+@NCTestEnvironment(model = classOf[NCStopWordsBaseModel], startClient = true)
+class NCStopWordsBaseSpec extends NCTestContext {
+    @Test
+    def testTwoWords(): Unit = {
+        checkIntent("a b", "twoWords")
+        checkIntent("a the b", "twoWords")
+        checkIntent("a the the b", "twoWords")
+        checkIntent("the a the b", "twoWords")
+        checkIntent("the a the b the the", "twoWords")
+    }
+
+    @Test
+    def testOneWord(): Unit = {
+        checkIntent("x y", "oneWord")
+        checkIntent("x the y", "oneWord")
+        checkIntent("x the the y", "oneWord")
+        checkIntent("the x the y", "oneWord")
+        checkIntent("the x the y the the", "oneWord")
+    }
+}
\ No newline at end of file