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 2021/05/28 03:46:11 UTC

[incubator-nlpcraft] branch NLPCRAFT-296 updated (511241a -> c10417b)

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

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


    from 511241a  WIP.
     new 3ccd213  WIP.
     new c10417b  WIP.

The 2 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:
 .../model/intent/solver/NCIntentSolverEngine.scala      |  2 +-
 .../org/apache/nlpcraft/probe/mgrs/NCProbeSynonym.scala |  2 +-
 .../nlpcraft/probe/mgrs/nlp/NCProbeEnricher.scala       |  1 -
 .../nlp/enrichers/dictionary/NCDictionaryEnricher.scala |  1 -
 .../nlp/enrichers/relation/NCRelationEnricher.scala     |  2 +-
 .../nlp/enrichers/stopword/NCStopWordEnricher.scala     |  1 -
 .../suspicious/NCSuspiciousNounsEnricher.scala          |  2 --
 .../probe/mgrs/sentence/NCSentenceManager.scala         | 17 +++++++++--------
 .../apache/nlpcraft/server/nlp/core/NCNlpParser.scala   |  2 --
 .../nlpcraft/server/nlp/core/NCNlpServerManager.scala   |  1 -
 .../server/nlp/core/opennlp/NCOpenNlpNerEnricher.scala  |  1 +
 .../server/nlp/enrichers/date/NCDateEnricher.scala      | 10 +++++-----
 .../server/sugsyn/NCSuggestSynonymManager.scala         |  2 +-
 13 files changed, 19 insertions(+), 25 deletions(-)

[incubator-nlpcraft] 01/02: WIP.

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

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

commit 3ccd21380d392395b24a59b9c0b032ad892da22b
Author: unknown <ar...@datalingvo.com>
AuthorDate: Thu May 27 13:14:57 2021 -0700

    WIP.
---
 .../scala/org/apache/nlpcraft/probe/mgrs/NCProbeSynonym.scala  |  2 +-
 .../org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnricher.scala   |  1 -
 .../probe/mgrs/nlp/enrichers/relation/NCRelationEnricher.scala |  2 +-
 .../server/nlp/core/opennlp/NCOpenNlpNerEnricher.scala         |  1 +
 .../nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala    | 10 +++++-----
 .../nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala       |  2 +-
 6 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeSynonym.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeSynonym.scala
index e30d301..e8e02f0 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeSynonym.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeSynonym.scala
@@ -207,7 +207,7 @@ class NCProbeSynonym(
         require(toks != null)
         require(sparse && !hasIdl)
 
-        sparseMatch0(toks, isMatch, (t: NCNlpSentenceToken) => t.startCharIndex, shouldBeNeighbors = false)
+        sparseMatch0(toks.toSeq, isMatch, (t: NCNlpSentenceToken) => t.startCharIndex, shouldBeNeighbors = false)
     }
 
     /**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnricher.scala
index c893251..7a22d18 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnricher.scala
@@ -24,7 +24,6 @@ import org.apache.nlpcraft.common.nlp._
 import org.apache.nlpcraft.common.{NCService, _}
 import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 
-import scala.collection.Map
 import scala.language.implicitConversions
 
 /**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCRelationEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCRelationEnricher.scala
index 1c3e9ea..19aad79 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCRelationEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCRelationEnricher.scala
@@ -27,7 +27,7 @@ import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
 
 import scala.collection.mutable
-import scala.jdk.CollectionConverters.SeqHasAsJava
+import scala.jdk.CollectionConverters.{MapHasAsScala, SeqHasAsJava, SetHasAsScala}
 
 /**
   * Relation enricher.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/opennlp/NCOpenNlpNerEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/opennlp/NCOpenNlpNerEnricher.scala
index f86f0a8..44f7d85 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/opennlp/NCOpenNlpNerEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/opennlp/NCOpenNlpNerEnricher.scala
@@ -129,6 +129,7 @@ object NCOpenNlpNerEnricher extends NCService with NCNlpNerEnricher with NCIgnit
                     synchronized {
                         val res = nerFinders.
                             filter { case (_, tokName) => ebiTokens.contains(tokName)}.
+                            toSeq.
                             flatMap {
                                 case (finder, name) =>
                                     finder.find(words).map(p => Holder(p.getStart, p.getEnd - 1, name, p.getProb))
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
index d507dcf..e4c7908 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/date/NCDateEnricher.scala
@@ -174,7 +174,7 @@ object NCDateEnricher extends NCServerEnricher {
      * @throws NCE
      */
     @throws[NCE]
-    override def enrich(ns: Sentence, parent: Span = null) {
+    override def enrich(ns: Sentence, parent: Span = null): Unit = {
         require(isStarted)
 
         // This stage must not be 1st enrichment stage.
@@ -383,7 +383,7 @@ object NCDateEnricher extends NCServerEnricher {
         fromIncl: Boolean,
         toIncl: Boolean,
         tokens: Seq[Token],
-        base: Long) {
+        base: Long): Unit = {
         val note = mkNote(
             NCDateParser.calculate(body, base, fromIncl, toIncl).mkInclusiveDateRange,
             tokens.head.index,
@@ -396,7 +396,7 @@ object NCDateEnricher extends NCServerEnricher {
 
     private def mark(processed: F*): Unit = processed.foreach(_.isProcessed = true)
 
-    private def collapse(ns: Sentence) {
+    private def collapse(ns: Sentence): Unit = {
         removeDuplicates(ns)
         collapsePeriods(ns)
         removeDuplicates(ns)
@@ -404,7 +404,7 @@ object NCDateEnricher extends NCServerEnricher {
 
     private def isValidRange(n: Note): Boolean = n("from").asInstanceOf[Long] < n("to").asInstanceOf[Long]
 
-    private def collapsePeriods(ns: Sentence) {
+    private def collapsePeriods(ns: Sentence): Unit = {
         // a) Months and years.
         // 1. "m", "m"... "y, m" -> fix year for firsts; try to union all.
         // Example: January, February of 2009.
@@ -563,7 +563,7 @@ object NCDateEnricher extends NCServerEnricher {
         ns: Sentence,
         seq: Seq[Note],
         before: Option[Note] = None,
-        after: Option[Note] = None) {
+        after: Option[Note] = None): Unit = {
         if (!compressNotes(ns, seq, before, after)) {
             def remove(nOpt: Option[Note]): Unit =
                 nOpt match {
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala
index e6a9c66..4753a17 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala
@@ -38,7 +38,7 @@ import java.util.concurrent._
 import java.util.concurrent.atomic.{AtomicInteger, AtomicReference}
 import scala.collection.mutable
 import scala.concurrent.{ExecutionContext, Future, Promise}
-import scala.jdk.CollectionConverters.{ListHasAsScala, MapHasAsScala}
+import scala.jdk.CollectionConverters.{ListHasAsScala, MapHasAsScala, SeqHasAsJava}
 import scala.util.{Failure, Success}
 
 /**

[incubator-nlpcraft] 02/02: WIP.

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

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

commit c10417b6dd83e0966cb8432bd6c05b2356681b11
Author: unknown <ar...@datalingvo.com>
AuthorDate: Thu May 27 13:22:13 2021 -0700

    WIP.
---
 .../model/intent/solver/NCIntentSolverEngine.scala      |  2 +-
 .../nlp/enrichers/dictionary/NCDictionaryEnricher.scala |  1 -
 .../nlp/enrichers/stopword/NCStopWordEnricher.scala     |  1 -
 .../suspicious/NCSuspiciousNounsEnricher.scala          |  2 --
 .../probe/mgrs/sentence/NCSentenceManager.scala         | 17 +++++++++--------
 .../apache/nlpcraft/server/nlp/core/NCNlpParser.scala   |  2 --
 .../nlpcraft/server/nlp/core/NCNlpServerManager.scala   |  1 -
 7 files changed, 10 insertions(+), 16 deletions(-)

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 2451f65..9946afd 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
@@ -24,7 +24,7 @@ import org.apache.nlpcraft.common.debug.{NCLogGroupToken, NCLogHolder}
 import org.apache.nlpcraft.common.opencensus.NCOpenCensusTrace
 import org.apache.nlpcraft.model.impl.NCTokenLogger
 import org.apache.nlpcraft.model.impl.NCTokenPimp._
-import org.apache.nlpcraft.model.intent.{NCIdlContext, NCIdlFunction, NCIdlIntent, NCIdlTerm, NCIdlStackItem ⇒ Z}
+import org.apache.nlpcraft.model.intent.{NCIdlContext, NCIdlFunction, NCIdlIntent, NCIdlTerm, NCIdlStackItem => Z}
 import org.apache.nlpcraft.model.{NCContext, NCDialogFlowItem, NCIntentMatch, NCResult, NCToken}
 import org.apache.nlpcraft.probe.mgrs.dialogflow.NCDialogFlowManager
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/dictionary/NCDictionaryEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/dictionary/NCDictionaryEnricher.scala
index 8c58a83..5c28d9e 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/dictionary/NCDictionaryEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/dictionary/NCDictionaryEnricher.scala
@@ -28,7 +28,6 @@ import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
 
 import java.io.Serializable
-import scala.collection.Map
 
 /**
   * Dictionary enricher.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
index b70dd49..fc904d2 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/stopword/NCStopWordEnricher.scala
@@ -27,7 +27,6 @@ import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
 
 import scala.annotation.tailrec
-import scala.collection.{Map, Seq}
 
 /**
   * Stop words enricher.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/suspicious/NCSuspiciousNounsEnricher.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/suspicious/NCSuspiciousNounsEnricher.scala
index 2d08c10..384f1e3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/suspicious/NCSuspiciousNounsEnricher.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/suspicious/NCSuspiciousNounsEnricher.scala
@@ -25,8 +25,6 @@ import org.apache.nlpcraft.common.nlp._
 import org.apache.nlpcraft.probe.mgrs.NCProbeModel
 import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
 
-import scala.collection.Map
-
 /**
   * Suspicious words enricher.
   */
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/sentence/NCSentenceManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/sentence/NCSentenceManager.scala
index 1ff8df0..f922eaa 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/sentence/NCSentenceManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/sentence/NCSentenceManager.scala
@@ -24,11 +24,11 @@ import org.apache.nlpcraft.common.nlp.{NCNlpSentence, NCNlpSentenceNote, NCNlpSe
 import org.apache.nlpcraft.common.{NCE, NCService, U}
 import org.apache.nlpcraft.model.NCModel
 
-import java.io.{Serializable => JSerializable}
+import java.io.{Serializable ⇒ JSerializable}
 import java.util
-import java.util.{List => JList}
+import java.util.{List ⇒ JList}
 import scala.collection.mutable
-import scala.jdk.CollectionConverters.CollectionHasAsScala
+import scala.jdk.CollectionConverters.{ListHasAsScala, SeqHasAsJava}
 import scala.language.implicitConversions
 
 /**
@@ -77,9 +77,10 @@ object NCSentenceManager extends NCService {
                 require(names.size() == idxsSeq.size())
 
                 noteLinks ++=
-                    (for ((name, idxs) <- names.asScala.zip(idxsSeq.asScala.map(_.asScala)))
-                        yield NoteLink(name, idxs.sorted)
-                        )
+                    (
+                        for ((name, idxs) <- names.asScala.zip(idxsSeq.asScala.map(_.asScala)))
+                            yield NoteLink(name, idxs.sorted.toSeq)
+                    )
             }
 
             if (n.contains("subjnotes")) add("subjnotes", "subjindexes")
@@ -164,7 +165,7 @@ object NCSentenceManager extends NCService {
         ns.filter(_.isTypeOf(noteType)).foreach(tok =>
             tok.getNoteOpt(noteType, idxsField) match {
                 case Some(n) =>
-                    val idxs: Seq[Int] = n.data[JList[Int]](idxsField).asScala
+                    val idxs: Seq[Int] = n.data[JList[Int]](idxsField).asScala.toSeq
                     var fixed = idxs
 
                     history.foreach { case (idxOld, idxNew) => fixed = fixed.map(i => if (i == idxOld) idxNew else i) }
@@ -178,7 +179,7 @@ object NCSentenceManager extends NCService {
         )
 
         ns.flatMap(_.getNotes(noteType)).forall(
-            n => checkRelation(ns, n.data[JList[Int]]("indexes").asScala, n.data[String](noteField), n)
+            n => checkRelation(ns, n.data[JList[Int]]("indexes").asScala.toSeq, n.data[String](noteField), n)
         )
     }
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpParser.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpParser.scala
index 4ec9b3e..21d059c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpParser.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpParser.scala
@@ -20,8 +20,6 @@ package org.apache.nlpcraft.server.nlp.core
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common.NCService
 
-import scala.collection.Seq
-
 /**
   * NLP parser.
   */
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala
index ba71930..a3e5a25 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/core/NCNlpServerManager.scala
@@ -23,7 +23,6 @@ import org.apache.nlpcraft.common.nlp.core.NCNlpCoreManager
 import org.apache.nlpcraft.common.pool.NCThreadPoolManager
 import org.apache.nlpcraft.common.{NCService, _}
 
-import scala.collection.Seq
 import scala.concurrent.ExecutionContext
 
 /**