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

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


The following commit(s) were added to refs/heads/NLPCRAFT-500 by this push:
     new d1566d69 Tests minor improvements.
d1566d69 is described below

commit d1566d69ef92918fa67d75c9194dfab6903e73f6
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Aug 25 16:28:00 2022 +0300

    Tests minor improvements.
---
 .../nlpcraft/internal/conversation/NCConversationSpec.scala    | 10 ++--------
 .../internal/conversation/NCConversationTimeoutSpec.scala      |  5 +----
 .../org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala |  3 +--
 .../org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala |  5 +----
 .../intent/compiler/NCIDLFragmentsOverridingSpec.scala         |  5 +----
 .../intent/compiler/NCIDLFragmentsOverridingSpec2.scala        |  5 +----
 .../test/scala/org/apache/nlpcraft/nlp/util/NCTestConfig.scala | 10 +++++++---
 7 files changed, 14 insertions(+), 29 deletions(-)

diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
index 9ca15df3..6366a9c1 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
@@ -42,10 +42,7 @@ class NCConversationSpec:
     def test(): Unit =
         val mdl: NCModel =
             new NCTestModelAdapter:
-                override val getPipeline: NCPipeline =
-                    val pl = mkEnPipeline
-                    pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("e1"), 
TE("e2"))
-                    pl
+                override val getPipeline: NCPipeline = mkEnPipeline(TE("e1"), 
TE("e2"))
 
                 @NCIntent("intent=i1 term(t1)~{# == 'e1'} term(t2)~{# == 
'e2'}?")
                 def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("t1") t1: NCEntity, @NCIntentTerm("t2") t2: Option[NCEntity]): 
NCResult = NCTestResult()
@@ -82,10 +79,7 @@ class NCConversationSpec:
     def testClearEmptyData(): Unit =
         val mdl: NCModel =
             new NCTestModelAdapter:
-                override val getPipeline: NCPipeline =
-                    val pl = mkEnPipeline
-                    pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("e1"))
-                    pl
+                override val getPipeline: NCPipeline = mkEnPipeline(TE("e1"))
 
                 @NCIntent("intent=i1 term(t1)~{# == 'e1'}")
                 def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult =
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
index 726f966c..51918b05 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
@@ -47,10 +47,7 @@ class NCConversationTimeoutSpec:
                 override val getConfig: NCModelConfig =
                     NCModelConfig(CFG.getId, CFG.getName, CFG.getVersion, 
"Test desc", "Test origin", TIMEOUT, CFG.getConversationDepth)
 
-                override val getPipeline: NCPipeline =
-                    val pl = mkEnPipeline
-                    pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("test"))
-                    pl
+                override val getPipeline: NCPipeline = mkEnPipeline(TE("test"))
 
                 @NCIntent("intent=i term(e)~{# == 'test'}")
                 def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("e") e: NCEntity): NCResult =
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
index ec63bb1f..88b61ea4 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
@@ -37,8 +37,7 @@ class NCModelClientSpec2:
         val mdl = new NCTestModelAdapter:
             import NCSemanticTestElement as TE
             override val getPipeline =
-                val pl = mkEnPipeline
-                pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("e1"), 
TE("e2"))
+                val pl = mkEnPipeline(TE("e1"), TE("e2"))
                 pl.tokEnrichers += EN_TOK_LEMMA_POS_ENRICHER
                 pl
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
index a18a2885..4b6d610c 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
@@ -37,10 +37,7 @@ class NCModelClientSpec3:
         import NCSemanticTestElement as TE
 
         val mdl: NCTestModelAdapter = new NCTestModelAdapter:
-            override val getPipeline: NCPipeline =
-                val pl = mkEnPipeline
-                pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("e1"))
-                pl
+            override val getPipeline: NCPipeline = mkEnPipeline(TE("e1"))
 
             @NCIntent("intent=i1 term(t1)={# == 'e1'}")
             def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("t1") 
t1: NCEntity): NCResult = TEST_RESULT
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
index dfe77b57..f03a7a6e 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
@@ -37,10 +37,7 @@ class NCIDLFragmentsOverridingSpec:
         @NCIntent("fragment=f term(y)~{# == 'x2'} intent=i1 fragment(f)")
         private def onY(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult(2)
 
-        override val getPipeline: NCPipeline =
-            val pl = mkEnPipeline
-            pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("x1"), TE("x2"))
-            pl
+        override val getPipeline: NCPipeline = mkEnPipeline(TE("x1"), TE("x2"))
 
     @Test
     def test(): Unit =
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
index 8583b3de..4021f3ea 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
@@ -41,10 +41,7 @@ class NCIDLFragmentsOverridingSpec2:
         @NCIntent("fragment=f term(z)~{# == 'x3'} intent=i3 fragment(f)")
         private def on3(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult(3)
 
-        override val getPipeline: NCPipeline =
-            val pl = mkEnPipeline
-            pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("x1"), 
TE("x2"), TE("x3"))
-            pl
+        override val getPipeline: NCPipeline = mkEnPipeline(TE("x1"), 
TE("x2"), TE("x3"))
 
     @Test
     def test(): Unit =
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestConfig.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestConfig.scala
index 368290d3..e15c74f9 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestConfig.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestConfig.scala
@@ -19,8 +19,8 @@ package org.apache.nlpcraft.nlp.util
 
 import org.apache.nlpcraft.NCModelConfig
 import org.apache.nlpcraft.internal.util.NCResourceReader as R
-import org.apache.nlpcraft.nlp.enrichers.{NCEnStopWordsTokenEnricher, 
NCOpenNLPLemmaPosTokenEnricher}
-import org.apache.nlpcraft.nlp.parsers.NCOpenNLPTokenParser
+import org.apache.nlpcraft.nlp.enrichers.*
+import org.apache.nlpcraft.nlp.parsers.*
 import org.apache.nlpcraft.nlp.enrichers.*
 import org.apache.nlpcraft.nlp.util.*
 
@@ -29,4 +29,8 @@ final val EN_TOK_PARSER = new 
NCOpenNLPTokenParser(R.getPath("opennlp/en-token.b
 final val EN_TOK_STOP_ENRICHER = new NCEnStopWordsTokenEnricher
 final val EN_TOK_LEMMA_POS_ENRICHER =
     new NCOpenNLPLemmaPosTokenEnricher(R.getPath("opennlp/en-pos-maxent.bin"), 
R.getPath("opennlp/en-lemmatizer.dict"))
-final def mkEnPipeline = NCTestPipeline(EN_TOK_PARSER)
+final def mkEnPipeline: NCTestPipeline = NCTestPipeline(EN_TOK_PARSER)
+final def mkEnPipeline(es: NCSemanticTestElement*): NCTestPipeline =
+    val pl = mkEnPipeline
+    pl.entParsers += NCTestUtils.mkEnSemanticParser(es*)
+    pl

Reply via email to