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

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


The following commit(s) were added to refs/heads/master_test by this push:
     new 7d7b65a  WIP.
7d7b65a is described below

commit 7d7b65a8d8d1167558201c166aa9110cbe1758b5
Author: Sergey Kamov <[email protected]>
AuthorDate: Mon Dec 13 17:18:20 2021 +0300

    WIP.
---
 .../scala/org/apache/nlpcraft/NCModelClient.java   | 36 ++++++++++++++++++++--
 .../parser/opennlp/NCOpenNlpEntityParser.java      | 25 ++++++++++++---
 pom.xml                                            |  6 ++--
 3 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
index ca0909c..8534528 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
@@ -18,6 +18,7 @@
 package org.apache.nlpcraft;
 
 import java.util.Map;
+import java.util.List;
 import java.util.concurrent.*;
 
 /**
@@ -34,14 +35,45 @@ public class NCModelClient implements NCLifecycle {
         this.mdl = mdl;
     }
 
+    /**
+     *
+     * @throws NCException
+     */
+    private static void verify() throws NCException {
+        // TODO:
+    }
+
+    private static void start(List<? extends NCLifecycle> list) {
+        if (list != null)
+            list.forEach(p -> p.start());
+    }
+
+    private static void stop(List<? extends NCLifecycle> list) {
+        if (list != null)
+            list.forEach(p -> p.stop());
+    }
+
     @Override
     public void start() {
-        // TODO
+        verify();
+
+        NCModelConfig cfg = mdl.getConfig();
+
+        cfg.getTokenParser().start();
+        start(cfg.getEntityParsers());
+        start(cfg.getEntityEnrichers());
+        start(cfg.getTokenEnrichers());
     }
 
     @Override
     public void stop() {
-        // TODO
+        NCModelConfig cfg = mdl.getConfig();
+
+        stop(cfg.getTokenEnrichers());
+        stop(cfg.getEntityEnrichers());
+        stop(cfg.getEntityParsers());
+        cfg.getTokenParser().stop();
+
     }
 
     /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
index 3993fe6..a83fa7a 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/nlp/entity/parser/opennlp/NCOpenNlpEntityParser.java
@@ -19,24 +19,41 @@ package 
org.apache.nlpcraft.internal.nlp.entity.parser.opennlp;
 
 import org.apache.nlpcraft.NCEntity;
 import org.apache.nlpcraft.NCEntityParser;
+import org.apache.nlpcraft.NCException;
 import org.apache.nlpcraft.NCModelConfig;
 import org.apache.nlpcraft.NCRequest;
 import org.apache.nlpcraft.NCToken;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  *
  */
 public class NCOpenNlpEntityParser implements NCEntityParser {
-    private final List<NCOpenNlpModel> models;
+    private final List<NCOpenNlpModel> mdls;
 
     /**
      *
-     * @param models
+     * @param mdls
      */
-    public NCOpenNlpEntityParser(List<NCOpenNlpModel> models) {
-        this.models = models;
+    public NCOpenNlpEntityParser(List<NCOpenNlpModel> mdls) {
+        this.mdls = mdls;
+    }
+
+    @Override
+    public void start() {
+        if (mdls == null || mdls.isEmpty()) {
+            // TODO:
+            throw new NCException("Model cannot be empty");
+        }
+
+        List<NCOpenNlpModel> invalid = mdls.stream().filter(p -> 
!p.getPath().isFile() || !p.getPath().exists()).collect(Collectors.toList());
+
+        if (!invalid.isEmpty()) {
+            // TODO: download etc
+            throw new NCException("Files are not valid: " + invalid);
+        }
     }
 
     @Override
diff --git a/pom.xml b/pom.xml
index bbcbaee..071772e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,14 +82,14 @@
         <timestamp>${maven.build.timestamp}</timestamp>
 
         <!-- Versions. -->
-        <scala.plugin.ver>4.5.3</scala.plugin.ver>
+        <scala.plugin.ver>4.5.4</scala.plugin.ver>
         <log4j.ver>2.15.0</log4j.ver>
         <scala.config.ver>1.3.4</scala.config.ver>
         <scala.logging.ver>3.9.4</scala.logging.ver>
         <scalatest.ver>3.2.9</scalatest.ver>
         <scala.par.colections>1.0.3</scala.par.colections>
         <maven.jar.plugin.ver>3.2.0</maven.jar.plugin.ver>
-        <maven.compiler.plugin.ver>3.8.0</maven.compiler.plugin.ver>
+        <maven.compiler.plugin.ver>3.8.1</maven.compiler.plugin.ver>
         <maven.enforcer.plugin.ver>1.4.1</maven.enforcer.plugin.ver>
         <maven.surefire.plugin.ver>2.22.1</maven.surefire.plugin.ver>
         <maven.shade.plugin.ver>3.2.1</maven.shade.plugin.ver>
@@ -102,7 +102,7 @@
         <commons.lang3.ver>3.12.0</commons.lang3.ver>
         <commons.codec.ver>1.15</commons.codec.ver>
         <scala3.ref.ver>1.0.0</scala3.ref.ver>
-        <junit.ver>5.8.1</junit.ver>
+        <junit.ver>5.8.2</junit.ver>
         <scalatest.ver>3.2.9</scalatest.ver>
         <gson.ver>2.8.5</gson.ver>
         <apache.opennlp.ver>1.9.4</apache.opennlp.ver>

Reply via email to