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

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


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

commit 6d18cb467e958801c6a33961c4ada1d0dd40bfa9
Author: Sergey Kamov <[email protected]>
AuthorDate: Fri Feb 18 23:23:12 2022 +0300

    WIP.
---
 .../opennlp/impl/NCOpenNLPTokenParserImpl.scala    | 12 +++----
 .../nlpcraft/internal/impl/NCModelClientSpec.scala | 42 ++++++++++++----------
 2 files changed, 29 insertions(+), 25 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/parser/opennlp/impl/NCOpenNLPTokenParserImpl.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/parser/opennlp/impl/NCOpenNLPTokenParserImpl.scala
index e85fd74..c1074fb 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/parser/opennlp/impl/NCOpenNLPTokenParserImpl.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/token/parser/opennlp/impl/NCOpenNLPTokenParserImpl.scala
@@ -51,18 +51,18 @@ class NCOpenNLPTokenParserImpl(tokMdl: String,  posMdlSrc: 
String, lemmaDicSrc:
 
     private def init(): Unit =
         NCUtils.execPar(
-            () =>
+            () => {
                 tagger = new POSTaggerME(new 
POSModel(NCUtils.getStream(posMdlSrc)))
                 logger.trace(s"Loaded resource: $posMdlSrc")
-            ,
-            () =>
+            },
+            () => {
                 lemmatizer = new 
DictionaryLemmatizer(NCUtils.getStream(lemmaDicSrc))
                 logger.trace(s"Loaded resource: $lemmaDicSrc")
-            ,
-            () =>
+            },
+            () => {
                 tokenizer = new TokenizerME(new 
TokenizerModel(NCUtils.getStream(tokMdl)))
                 logger.trace(s"Loaded resource: $tokMdl")
-
+            }
         )(ExecutionContext.Implicits.global)
 
     override def tokenize(text: String): JList[NCToken] =
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
index 9563947..95a0222 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
@@ -28,24 +28,7 @@ import scala.jdk.CollectionConverters.*
 import scala.util.Using
 
 class NCModelClientSpec:
-    /**
-      *
-      */
-    @Test
-    def test(): Unit =
-        val mdl: NCTestModelAdapter =
-            new NCTestModelAdapter():
-                // TODO: doesn't work.
-                //@NCIntent("intent=ls term(act)={has(ent_groups, 'act')} 
term(loc)={# == 'ls:loc'}*") @NCIntent("intent=locInt term(single)~{# == 'id1'} 
term(list)~{# == 'id2'}[0,10] term(opt)~{# == 'id3'}?")
-                @NCIntentSample(Array("Lights on at second floor kitchen", 
"Invalid sample"))
-                @NCIntent("intent=ls term(act)={# == 'ls:on'} term(loc)={# == 
'ls:loc'}*")
-                def onMatch(@NCIntentTerm("act") act: NCEntity, 
@NCIntentTerm("loc") locs: List[NCEntity]): NCResult =
-                    val ncRes = new NCResult()
-                    ncRes.setType(NCResultType.ASK_RESULT)
-                    ncRes.setBody(if locs.isEmpty then "entire house" else 
locs.map(_.mkText()).mkString(","))
-
-                    ncRes
-
+    private def test0(mdl: NCTestModelAdapter): Unit =
         mdl.getPipeline.getEntityParsers.add(
             new NCSemanticEntityParser(
                 new NCEnSemanticPorterStemmer,
@@ -61,4 +44,25 @@ class NCModelClientSpec:
             println(s"Body: ${res.getBody}")
 
             client.validateSamples()
-        }
\ No newline at end of file
+        }
+    /**
+      *
+      */
+    @Test
+    def test(): Unit =
+        test0(
+            new NCTestModelAdapter():
+                @NCIntentSample(Array("Lights on at second floor kitchen", 
"Invalid sample"))
+                @NCIntent("intent=ls term(act)={# == 'ls:on'} term(loc)={# == 
'ls:loc'}*")
+                def onMatch(@NCIntentTerm("act") act: NCEntity, 
@NCIntentTerm("loc") locs: List[NCEntity]): NCResult = new NCResult()
+        )
+
+    @Test
+    def test2(): Unit =
+        test0(
+            new NCTestModelAdapter():
+                @NCIntent("intent=ls term(act)={has(ent_groups, 'act')} 
term(loc)={# == 'ls:loc'}*")
+                @NCIntentSample(Array("Lights on at second floor kitchen", 
"Invalid sample"))
+                def onMatch(@NCIntentTerm("act") act: NCEntity, 
@NCIntentTerm("loc") locs: List[NCEntity]): NCResult = new NCResult()
+        )
+

Reply via email to