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

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


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

commit c7d8b6b8ea17bac5eeaf9120f2ee3de7c6b23460
Author: Sergey Kamov <skhdlem...@gmail.com>
AuthorDate: Tue Mar 29 23:21:55 2022 +0300

    WIP.
---
 .../internal/conversation/NCConversationSpec.scala       | 16 +++++++++-------
 .../nlpcraft/internal/impl/NCModelClientSpec2.scala      |  9 ++++++---
 .../scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala |  9 +++++++++
 3 files changed, 24 insertions(+), 10 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 f218168..4b7cc44 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
@@ -31,14 +31,16 @@ class NCConversationSpec:
 
     @Test
     def test(): Unit =
-        val mdl: NCModel = new NCModel:
-            import NCSemanticTestElement as TE
+        val mdl: NCModel =
+            new NCTestModelAdapter:
+                import NCSemanticTestElement as TE
+                override val getPipeline: NCPipeline =
+                    val pl = mkEnPipeline
+                    
pl.getEntityParsers.add(NCTestUtils.mkENSemanticParser(TE("e1"), TE("e2")))
+                    pl
 
-            override def getPipeline: NCPipeline = new 
NCPipelineBuilder().withSemantic("en", Seq(TE("e1"), TE("e2")).asJava).build()
-            override def getConfig: NCModelConfig = CFG
-
-            @NCIntent("intent=i1 term(t1)~{# == 'e1'} term(t2)~{# == 'e2'}?")
-            def onMatch(@NCIntentTerm("t1") t1: NCEntity, @NCIntentTerm("t2") 
t2: Option[NCEntity]): NCResult = new NCResult()
+                @NCIntent("intent=i1 term(t1)~{# == 'e1'} term(t2)~{# == 
'e2'}?")
+                def onMatch(@NCIntentTerm("t1") t1: NCEntity, 
@NCIntentTerm("t2") t2: Option[NCEntity]): NCResult = new NCResult()
 
         Using.resource(new NCModelClient(mdl)) { cli =>
             def execOk(txt: String): Unit = cli.ask(txt, null, usrId)
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 b7c2f62..4c37ddc 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
@@ -34,9 +34,12 @@ class NCModelClientSpec2:
     def test(): Unit =
         import NCSemanticTestElement as TE
 
-        val mdl = new NCModel:
-            override def getConfig: NCModelConfig = CFG
-            override def getPipeline: NCPipeline = new 
NCPipelineBuilder().withSemantic("en", Seq(TE("e1"), TE("e2")).asJava).build()
+        val mdl = new NCTestModelAdapter:
+            override val getPipeline: NCPipeline =
+                val pl = mkEnPipeline
+                
pl.getEntityParsers.add(NCTestUtils.mkENSemanticParser(TE("e1"), TE("e2")))
+                pl.getTokenEnrichers.add(EN_TOK_LEMMA_POS_ENRICHER)
+                pl
 
             @NCIntent("intent=i1 term(t1)={# == 'e1'} term(t2List)={# == 
'e2'}*")
             def onMatch(@NCIntentTerm("t1") act: NCEntity, 
@NCIntentTerm("t2List") locs: List[NCEntity]): NCResult =
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala
index eb727d0..da731fc 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala
@@ -143,6 +143,15 @@ object NCTestUtils:
 
     /**
       *
+      * @param elms
+      * @param macros
+      * @return
+      */
+    def mkENSemanticParser(elms: NCSemanticElement*): NCSemanticEntityParser =
+        new NCSemanticEntityParser(mkSemanticStemmer, EN_TOK_PARSER, null, 
elms.asJava)
+
+    /**
+      *
       * @param src
       * @return
       */

Reply via email to