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


The following commit(s) were added to refs/heads/NLPCRAFT-443 by this push:
     new 461e641  WIP.
461e641 is described below

commit 461e641b924b25b1a460e3a08a6818b409a9b0a9
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Sep 15 09:42:29 2021 +0300

    WIP.
---
 .../enrichers/stopword/NCStopWordEnricher.scala    |  4 +-
 .../model/stop/NCStopWordsAllowedSpec.scala        | 64 ++--------------------
 2 files changed, 7 insertions(+), 61 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
index 6d9b434..c0abd73 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
@@ -18,16 +18,14 @@
 package org.apache.nlpcraft.probe.mgrs.nlp.enrichers.stopword
 
 import io.opencensus.trace.Span
-import org.apache.nlpcraft.common.nlp.NCNlpSentenceToken.notes
 import org.apache.nlpcraft.common.nlp.core.NCNlpCoreManager
 import org.apache.nlpcraft.common.nlp.{NCNlpSentence, NCNlpSentenceToken}
 import org.apache.nlpcraft.common.{NCE, NCService, U}
+import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
-import org.apache.nlpcraft.probe.mgrs.{NCProbeModel, NCProbeSynonymsWrapper}
 
 import java.io.Serializable
 import scala.annotation.tailrec
-import scala.collection.mutable
 
 /**
   * Stop words enricher.
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsAllowedSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsAllowedSpec.scala
index 7ec0386..3f87f35 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsAllowedSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/stop/NCStopWordsAllowedSpec.scala
@@ -30,42 +30,18 @@ import scala.language.implicitConversions
   */
 class NCStopWordsAllowedModelAdapter extends NCModelAdapter("nlpcraft.test", 
"Test Model", "1.0") {
     override def getElements: util.Set[NCElement] = Set(NCTestElement("a", 
"the test"))
-}
 
+    override def onContext(ctx: NCContext): NCResult = {
+        ctx.getVariants.asScala.forall(t => t.asScala.exists(_.isStopWord) == 
isStopWordsAllowed)
+
+        NCResult.text("OK")
+    }
+}
 /**
   *
   */
 class NCStopWordsAllowedModel extends NCStopWordsAllowedModelAdapter {
     override def isStopWordsAllowed: Boolean = true
-
-    override def onContext(ctx: NCContext): NCResult = {
-        ctx.getRequest.getNormalizedText match {
-            case "the" =>
-                // One empty variant.
-                require(ctx.getVariants.size() == 1)
-                require(ctx.getVariants.asScala.head.size() == 0)
-            // Should be processed same way.
-            case "the test" | "the the test" =>
-                // One variant.
-                require(ctx.getVariants.size() == 1)
-
-                // One token (user token)
-                require(ctx.getVariants.asScala.head.size() == 1)
-                require(ctx.getVariants.asScala.head.asScala.head.getId == "a")
-
-            case "test the the test" =>
-                // One variant.
-                require(ctx.getVariants.size() == 1)
-
-                require(ctx.getVariants.asScala.head.size() == 2)
-                require(ctx.getVariants.asScala.head.asScala.head.getId == 
"nlpcraft:nlp")
-                require(ctx.getVariants.asScala.head.asScala.last.getId == "a")
-
-            case _ =>   throw new IllegalStateException(s"Unsupported test: 
${ctx.getRequest.getNormalizedText}")
-        }
-
-        NCResult.text("OK")
-    }
 }
 
 /**
@@ -73,34 +49,6 @@ class NCStopWordsAllowedModel extends 
NCStopWordsAllowedModelAdapter {
   */
 class NCStopWordsNotAllowedModel extends NCStopWordsAllowedModelAdapter {
     override def isStopWordsAllowed: Boolean = false
-
-    override def onContext(ctx: NCContext): NCResult = {
-        ctx.getRequest.getNormalizedText match {
-            case "the" =>
-                // One variant.
-                require(ctx.getVariants.size() == 1)
-
-                // One free token (nlp)
-                require(ctx.getVariants.asScala.head.size() == 1)
-                require(ctx.getVariants.asScala.head.asScala.head.getId == 
"nlpcraft:nlp")
-
-            case "the test" =>
-                // One variant.
-                require(ctx.getVariants.size() == 1)
-
-                // One token (user token)
-                require(ctx.getVariants.asScala.head.size() == 1)
-                require(ctx.getVariants.asScala.head.asScala.head.getId == "a")
-
-            case "the the test" | "test the the test" =>
-                // There are shouldn't be stop words.
-                ctx.getVariants.asScala.foreach(v => 
require(v.getStopWordTokens.asScala.isEmpty))
-
-            case _ =>   throw new IllegalStateException(s"Unsupported test: 
${ctx.getRequest.getNormalizedText}")
-        }
-
-        NCResult.text("OK")
-    }
 }
 
 /**

Reply via email to