You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/09/10 19:04:56 UTC

[incubator-nlpcraft] branch NLPCRAFT-41 updated (867a3e0 -> 123e19a)

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

aradzinski pushed a change to branch NLPCRAFT-41
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git.


    from 867a3e0  WIP.
     add 1b5e967  WIP.
     new 123e19a  Merge branch 'NLPCRAFT-41-2' into NLPCRAFT-41

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nlpcraft/src/main/resources/log4j2.xml             | 22 ++++++---
 .../org/apache/nlpcraft/probe/NCProbeBoot.scala    | 23 ++++++++--
 .../probe/mgrs/deploy/NCDeployManager.scala        | 52 +++++++++++++---------
 nlpcraft/src/test/resources/log4j2.xml             | 24 +++++++---
 4 files changed, 83 insertions(+), 38 deletions(-)


[incubator-nlpcraft] 01/01: Merge branch 'NLPCRAFT-41-2' into NLPCRAFT-41

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 123e19aa65753c832534ee084c6e53c5cbc766fc
Merge: 867a3e0 1b5e967
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Thu Sep 10 12:04:33 2020 -0700

    Merge branch 'NLPCRAFT-41-2' into NLPCRAFT-41

 nlpcraft/src/main/resources/log4j2.xml             | 22 ++++++---
 .../org/apache/nlpcraft/probe/NCProbeBoot.scala    | 23 ++++++++--
 .../probe/mgrs/deploy/NCDeployManager.scala        | 52 +++++++++++++---------
 nlpcraft/src/test/resources/log4j2.xml             | 24 +++++++---
 4 files changed, 83 insertions(+), 38 deletions(-)

diff --cc nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index f6941ad,a7e494b..20837a0
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@@ -27,17 -23,10 +27,17 @@@ import java.util.regex.{Pattern, Patter
  import io.opencensus.trace.Span
  import org.apache.nlpcraft.common._
  import org.apache.nlpcraft.common.config.NCConfigurable
 +import org.apache.nlpcraft.common.makro.NCMacroParser
 +import org.apache.nlpcraft.common.nlp.core.{NCNlpCoreManager, NCNlpPorterStemmer}
 +import org.apache.nlpcraft.common.util.NCUtils.{DSL_FIX, REGEX_FIX}
  import org.apache.nlpcraft.model._
  import org.apache.nlpcraft.model.factories.basic.NCBasicModelFactory
 -import org.apache.nlpcraft.model.impl.NCModelWrapper
 -import org.apache.nlpcraft.model.intent.impl.{NCIntentScanner, NCIntentSolver}
 +import org.apache.nlpcraft.model.intent.impl.{NCIntentDslCompiler, NCIntentSolver}
 +import org.apache.nlpcraft.model.intent.utils.NCDslIntent
 +import org.apache.nlpcraft.probe.mgrs.NCSynonymChunkKind.{DSL, REGEX, TEXT}
- import org.apache.nlpcraft.probe.mgrs.{NCSynonym, NCSynonymChunk, deploy}
++import org.apache.nlpcraft.probe.mgrs.{NCSynonym, NCSynonymChunk}
 +import org.apache.nlpcraft.probe.mgrs.model.NCModelSynonymDslCompiler
 +import org.apache.nlpcraft.probe.mgrs.nlp.NCModelData
  import resource.managed
  
  import scala.collection.JavaConverters._
@@@ -90,11 -50,9 +90,12 @@@ object NCDeployManager extends NCServic
          // It should reload config.
          def modelFactoryType: Option[String] = getStringOpt(s"$pre.modelFactory.type")
          def modelFactoryProps: Option[Map[String, String]] = getMapOpt(s"$pre.modelFactory.properties")
+         def model: Option[String] = getStringOpt(s"$pre.model")
          def models: Seq[String] = getStringList(s"$pre.models")
          def jarsFolder: Option[String] = getStringOpt(s"$pre.jarsFolder")
 +
 +        // TODO: property name.
 +        def synonymsWarnValue: Int = getInt(s"$pre.synonymsWarnValue")
      }
  
      /**
@@@ -631,47 -215,82 +632,54 @@@
              )
          )
      }
 -    
 +
      @throws[NCE]
      override def start(parent: Span = null): NCService = startScopedSpan("start", parent) { _ ⇒
-         modelFactory = new NCBasicModelFactory
 -        models = ArrayBuffer.empty[NCModelWrapper]
 +        data = ArrayBuffer.empty[NCModelData]
  
-         // Initialize model factory (if configured).
-         Config.modelFactoryType match {
-             case Some(mft) ⇒
-                 modelFactory = makeModelFactory(mft)
+         Config.model match {
+             case Some(mdlClsName) ⇒
 -                models += makeModel(mdlClsName)
++                data += makeModelWrapper(mdlClsName)
  
-                 modelFactory.initialize(Config.modelFactoryProps.getOrElse(Map.empty[String, String]).asJava)
+             case None ⇒
+                 modelFactory = new NCBasicModelFactory
  
-             case None ⇒ // No-op.
-         }
+                 // Initialize model factory (if configured).
+                 Config.modelFactoryType match {
+                     case Some(mft) ⇒
+                         modelFactory = makeModelFactory(mft)
+ 
+                         modelFactory.initialize(Config.modelFactoryProps.getOrElse(Map.empty[String, String]).asJava)
  
-         data ++= Config.models.map(makeModelWrapper)
+                     case None ⇒ // No-op.
+                 }
  
-         Config.jarsFolder match {
-             case Some(jarsFolder) ⇒
-                 val jarsFile = new File(jarsFolder)
 -                models ++= Config.models.map(makeModel)
++                data ++= Config.models.map(makeModelWrapper)
  
-                 if (!jarsFile.exists())
-                     throw new NCE(s"JAR folder path '$jarsFolder' does not exist.")
-                 if (!jarsFile.isDirectory)
-                     throw new NCE(s"JAR folder path '$jarsFolder' is not a directory.")
+                 Config.jarsFolder match {
+                     case Some(jarsFolder) ⇒
+                         val jarsFile = new File(jarsFolder)
  
-                 val src = this.getClass.getProtectionDomain.getCodeSource
-                 val locJar = if (src == null) null else new File(src.getLocation.getPath)
+                         if (!jarsFile.exists())
+                             throw new NCE(s"JAR folder path '$jarsFolder' does not exist.")
+                         if (!jarsFile.isDirectory)
+                             throw new NCE(s"JAR folder path '$jarsFolder' is not a directory.")
  
-                 for (jar ← scanJars(jarsFile) if jar != locJar)
-                     data ++= extractModels(jar)
+                         val src = this.getClass.getProtectionDomain.getCodeSource
+                         val locJar = if (src == null) null else new File(src.getLocation.getPath)
  
-             case None ⇒ // No-op.
+                         for (jar ← scanJars(jarsFile) if jar != locJar)
 -                            models ++= extractModels(jar)
++                            data ++= extractModels(jar)
+ 
+                     case None ⇒ // No-op.
+                 }
          }
  
 -        // Verify models' identities.
 -        models.foreach(mdl ⇒ {
 -            val mdlName = mdl.getName
 -            val mdlId = mdl.getId
 -            val mdlVer = mdl.getVersion
 -
 -            if (mdlId == null)
 -                throw new NCE(s"Model ID is not provided: $mdlName")
 -            if (mdlName == null)
 -                throw new NCE(s"Model name is not provided: $mdlId")
 -            if (mdlVer == null)
 -                throw new NCE(s"Model version is not provided: $mdlId")
 -            if (mdlName != null && mdlName.isEmpty)
 -                throw new NCE(s"Model name cannot be empty string: $mdlId")
 -            if (mdlId != null && mdlId.isEmpty)
 -                throw new NCE( s"Model ID cannot be empty string: $mdlId")
 -            if (mdlVer != null && mdlVer.length > 16)
 -                throw new NCE(s"Model version cannot be empty string: $mdlId")
 -            if (mdlName != null && mdlName.length > 64)
 -                throw new NCE(s"Model name is too long (64 max): $mdlId")
 -            if (mdlId != null && mdlId.length > 32)
 -                throw new NCE(s"Model ID is too long (32 max): $mdlId")
 -            if (mdlVer != null && mdlVer.length > 16)
 -                throw new NCE(s"Model version is too long (16 max): $mdlId")
 -            
 -            for (elm ← mdl.getElements.asScala)
 -                if (!elm.getId.matches(ID_REGEX))
 -                    throw new NCE(s"Model element ID '${elm.getId}' does not match '$ID_REGEX' regex in: $mdlId")
 -        })
 +        val ids = data.map(_.model.getId).toList
 +
 +        if (U.containsDups(ids))
 +            throw new NCE(s"Duplicate model IDs detected: ${ids.mkString(", ")}")
  
 -        if (U.containsDups(models.map(_.getId).toList))
 -            throw new NCE("Duplicate model IDs detected.")
 -        
          super.start()
      }