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

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


The following commit(s) were added to refs/heads/scala-2.13 by this push:
     new a74bd00  WIP.
a74bd00 is described below

commit a74bd0083c4c931a508ed7c0387718d583f67818
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Wed May 19 21:14:00 2021 -0700

    WIP.
---
 .../scala/org/apache/nlpcraft/common/debug/NCLogHolder.scala |  2 +-
 .../org/apache/nlpcraft/common/makro/NCMacroParser.scala     |  9 ++++-----
 .../scala/org/apache/nlpcraft/model/impl/NCTokenImpl.scala   |  2 +-
 .../scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala   |  1 +
 .../nlpcraft/model/intent/compiler/NCIdlCompiler.scala       |  2 ++
 .../apache/nlpcraft/model/intent/solver/NCIntentSolver.scala |  2 ++
 .../nlpcraft/model/intent/solver/NCIntentSolverEngine.scala  | 12 +++++++-----
 .../nlpcraft/model/intent/solver/NCIntentSolverVariant.scala |  3 ++-
 .../model/tools/sqlgen/impl/NCSqlExtractorImpl.scala         | 11 ++++++-----
 .../apache/nlpcraft/probe/mgrs/model/NCModelManager.scala    | 11 +++++------
 10 files changed, 31 insertions(+), 24 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/debug/NCLogHolder.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/debug/NCLogHolder.scala
index 4aaf02e..6fb5f55 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/debug/NCLogHolder.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/debug/NCLogHolder.scala
@@ -23,7 +23,7 @@ import java.util
 import com.google.gson.Gson
 import org.apache.nlpcraft.model._
 
-import scala.jdk.CollectionConverters.{CollectionHasAsScala, SeqHasAsJava}
+import scala.jdk.CollectionConverters.{CollectionHasAsScala, 
IterableHasAsJava, MapHasAsJava, SeqHasAsJava}
 
 //
 // NOTE: these classes are specifically designed for JSON marshalling.
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala
index 2948d10..97deac0 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroParser.scala
@@ -20,14 +20,13 @@ package org.apache.nlpcraft.common.makro
 import org.apache.nlpcraft.common._
 
 import scala.collection._
-import scala.jdk.CollectionConverters.ConcurrentMapHasAsScala
+import scala.jdk.CollectionConverters.{ConcurrentMapHasAsScala, SetHasAsJava}
 
 object NCMacroParser {
-    private final val CHARS = "[A-Za-z0-9-_]+"
     private final val ESC_CHARS = """{}\<>_[]|,"""
-    private final val MACRO_REGEX = s"<$CHARS>".r
-    private final val BROKEN_MACRO_REGEX1 = s"<$CHARS".r
-    private final val BROKEN_MACRO_REGEX2 = s"$CHARS>".r
+    private final val MACRO_REGEX = s"<[A-Za-z0-9-_]+>".r
+    private final val BROKEN_MACRO_REGEX1 = s"<[A-Za-z0-9-_]+".r
+    private final val BROKEN_MACRO_REGEX2 = s"[A-Za-z0-9-_]+>".r
     
     /**
       * Constructor.
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenImpl.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenImpl.scala
index d0f4f2e..7d96996 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenImpl.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenImpl.scala
@@ -25,7 +25,7 @@ import org.apache.nlpcraft.model._
 import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 
 import scala.collection.{Seq, mutable}
-import scala.jdk.CollectionConverters.{MapHasAsJava, SeqHasAsJava}
+import scala.jdk.CollectionConverters._
 
 /**
   *
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala
index f82dd08..5d8a215 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala
@@ -19,6 +19,7 @@ package org.apache.nlpcraft.model.impl
 
 import org.apache.nlpcraft.model.NCToken
 import scala.language.implicitConversions
+import scala.jdk.CollectionConverters._
 
 /**
   *
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
index 4f37a40..709c944 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
@@ -31,8 +31,10 @@ import java.io._
 import java.net._
 import java.util.Optional
 import java.util.regex.{Pattern, PatternSyntaxException}
+
 import scala.collection.mutable
 import scala.collection.mutable.ArrayBuffer
+import scala.jdk.CollectionConverters._
 
 object NCIdlCompiler extends LazyLogging {
     // Compiler caches.
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolver.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolver.scala
index a63b3d4..50b08ab 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolver.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolver.scala
@@ -28,6 +28,8 @@ import org.apache.nlpcraft.model.intent.NCIdlIntent
 import org.apache.nlpcraft.model.{NCContext, NCIntentMatch, NCIntentSkip, 
NCModel, NCRejection, NCResult, NCToken, NCVariant}
 import org.apache.nlpcraft.probe.mgrs.dialogflow.NCDialogFlowManager
 
+import scala.jdk.CollectionConverters._
+
 /**
  * Front-end for intent solver.
  */
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
index 5403086..d227475 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
@@ -29,7 +29,9 @@ import org.apache.nlpcraft.model.{NCContext, 
NCDialogFlowItem, NCIntentMatch, NC
 import org.apache.nlpcraft.probe.mgrs.dialogflow.NCDialogFlowManager
 
 import java.util.function.Function
+
 import scala.collection.mutable
+import scala.jdk.CollectionConverters._
 
 /**
  * Intent solver that finds the best matching intent given user sentence.
@@ -121,7 +123,7 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
          *
          * @return
          */
-        def toSeq: Seq[Int] = buf
+        def toSeq: Seq[Int] = buf.toSeq
 
         def toAnsiString: String = buf.mkString(y(bo("[")), ", ", y(bo("]")))
     }
@@ -205,8 +207,8 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
             val matches = mutable.ArrayBuffer.empty[MatchHolder]
 
             // Find all matches across all intents and sentence variants.
-            for ((vrn, vrnIdx) <- ctx.getVariants.zipWithIndex) {
-                val availToks = vrn.filter(t => !t.isStopWord)
+            for ((vrn, vrnIdx) <- ctx.getVariants.asScala.zipWithIndex) {
+                val availToks = vrn.asScala.filter(t => !t.isStopWord)
 
                 matches.appendAll(
                     intents.flatMap(pair => {
@@ -223,9 +225,9 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
                                 Seq.empty[UsedToken] ++
                                     // We shouldn't mix tokens with same group 
from conversation
                                     // history and processed sentence.
-                                    ctx.getConversation.getTokens.
+                                    ctx.getConversation.getTokens.asScala.
                                         filter(t => {
-                                            val convTokGroups = 
t.getGroups.sorted
+                                            val convTokGroups = 
t.getGroups.asScala.sorted
 
                                             
!senTokGroups.exists(convTokGroups.containsSlice)
                                         }).
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
index c9685d6..f8b1a21 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
@@ -19,7 +19,8 @@ package org.apache.nlpcraft.model.intent.solver
 
 import org.apache.nlpcraft.common._
 import org.apache.nlpcraft.model.NCToken
-import org.apache.nlpcraft.model.impl.NCTokenPimp._
+
+import scala.jdk.CollectionConverters._
 
 import java.util
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlExtractorImpl.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlExtractorImpl.scala
index b7437e5..d146f80 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlExtractorImpl.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/sqlgen/impl/NCSqlExtractorImpl.scala
@@ -24,8 +24,8 @@ import org.apache.nlpcraft.common.NCException
 import org.apache.nlpcraft.model._
 import org.apache.nlpcraft.model.tools.sqlgen._
 
-import scala.collection.JavaConverters._
 import scala.compat.java8.OptionConverters._
+import scala.jdk.CollectionConverters._
 
 /**
   *
@@ -167,7 +167,8 @@ class NCSqlExtractorImpl(schema: NCSqlSchema, variant: 
NCVariant) extends NCSqlE
                     }
                     else
                         throw new NCException(s"Token not found with index: 
$idx")
-                })
+                }).toSeq
+
             case None => Seq.empty
         }
     }
@@ -197,7 +198,7 @@ class NCSqlExtractorImpl(schema: NCSqlSchema, variant: 
NCVariant) extends NCSqlE
             else
                 throw new NCException(s"Token not found with index: $idx")
         )
-    }
+    }.toSeq
 
     /**
      *
@@ -260,10 +261,10 @@ class NCSqlExtractorImpl(schema: NCSqlSchema, variant: 
NCVariant) extends NCSqlE
                 var colTabs = cols.filter(_.getTable == t.getTable)
 
                 if (colTabs.isEmpty)
-                    colTabs = t.getColumns.asScala.filter(_.isPk)
+                    colTabs = t.getColumns.asScala.filter(_.isPk).toSeq
 
                 if (colTabs.isEmpty)
-                    colTabs = t.getColumns.asScala.take(1)
+                    colTabs = t.getColumns.asScala.take(1).toSeq
 
                 require(colTabs.nonEmpty)
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
index deab94f..a33670a 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/model/NCModelManager.scala
@@ -24,13 +24,12 @@ import org.apache.nlpcraft.model._
 import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 import org.apache.nlpcraft.probe.mgrs.deploy._
 
-import scala.collection.convert.DecorateAsScala
 import scala.util.control.Exception._
 
 /**
   * Model manager.
   */
-object NCModelManager extends NCService with DecorateAsScala {
+object NCModelManager extends NCService {
     // Deployed models keyed by their IDs.
     @volatile private var data: Map[String, NCProbeModel] = _
 
@@ -73,10 +72,10 @@ object NCModelManager extends NCService with 
DecorateAsScala {
                     s"${B}Origin:$RST                ${mdl.getOrigin}",
                     s"${B}Elements:$RST              
${withWarn(w.elements.keySet.size)}",
                     s"${B}Synonyms:$RST",
-                    s"${B}   Simple continuous:$RST  $contCnt",
-                    s"${B}   Simple sparse:$RST      $sparseCnt",
-                    s"${B}   IDL continuous:$RST     $contIdlCnt",
-                    s"${B}   IDL sparse:$RST         $sparseIdlCnt",
+                    s"$B   Simple continuous:$RST  $contCnt",
+                    s"$B   Simple sparse:$RST      $sparseCnt",
+                    s"$B   IDL continuous:$RST     $contIdlCnt",
+                    s"$B   IDL sparse:$RST         $sparseIdlCnt",
                     s"${B}Intents:$RST               
${withWarn(w.intents.size)}"
                 )
             })

Reply via email to