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 bae6420 WIP.
bae6420 is described below
commit bae64204d6ac0a75d89825c9fe4d142a3f908658
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Thu May 20 13:52:12 2021 -0700
WIP.
---
.../probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala | 12 ++++++------
.../probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala | 4 ++--
.../nlpcraft/probe/mgrs/sentence/NCSentenceManager.scala | 4 ++--
.../server/nlp/enrichers/numeric/NCNumericEnricher.scala | 3 ++-
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
index 70ba7a2..341141e 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
@@ -27,8 +27,8 @@ import org.apache.nlpcraft.probe.mgrs.NCProbeModel
import org.apache.nlpcraft.probe.mgrs.nlp.NCProbeEnricher
import java.io.Serializable
-import scala.collection.JavaConverters._
-import scala.collection.{Map, Seq, mutable}
+import scala.collection.mutable
+import scala.jdk.CollectionConverters._
/**
* Limit enricher.
@@ -260,14 +260,14 @@ object NCLimitEnricher extends NCProbeEnricher {
// Tries to grab tokens reverse way.
// Example: A, B, C => ABC, BC, AB .. (BC will be processed first)
- for (toks <- ns.tokenMixWithStopWords().sortBy(p => (-p.size,
-p.head.index)) if validImportant(ns, toks)) {
+ for (toks <- ns.tokenMixWithStopWords().sortBy(p => (-p.size,
-p.head.index)) if validImportant(ns, toks.toSeq)) {
if (numsMap == null) {
numsMap = NCNumericManager.find(ns).map(p => p.tokens ->
p).toMap
groupsMap = groupNums(ns, numsMap.values)
tech = (numsMap.keys.flatten ++
groupsMap.keys.flatten).toSet
}
- tryToMatch(numsMap, groupsMap, tech, toks) match {
+ tryToMatch(numsMap, groupsMap, tech, toks.toSeq) match {
case Some(m) =>
for (refNote <- m.refNotes if
!restricted.contains(refNote)) {
val ps = mutable.ArrayBuffer.empty[(String, Any)]
@@ -279,7 +279,7 @@ object NCLimitEnricher extends NCProbeEnricher {
if (m.asc.isDefined)
ps += "asc" -> m.asc.get
- val note =
NCNlpSentenceNote(m.matched.map(_.index), TOK_ID, ps: _*)
+ val note =
NCNlpSentenceNote(m.matched.map(_.index), TOK_ID, ps.toSeq: _*)
if (!notes.exists(n => ns.notesEqualOrSimilar(n,
note))) {
notes += note
@@ -371,7 +371,7 @@ object NCLimitEnricher extends NCProbeEnricher {
val numsMap = nums.map(n => n.tokens -> n).toMap
// All groups combinations.
- val tks2Nums: Seq[(NCNlpSentenceToken, Option[Int])] =
ns.filter(!_.isStopWord).map(t => t -> fuzzyNums.get(t.stem))
+ val tks2Nums: Seq[(NCNlpSentenceToken, Option[Int])] =
ns.filter(!_.isStopWord).map(t => t -> fuzzyNums.get(t.stem)).toSeq
// Tokens: A; B; 20; C; twenty; two, D
// NERs : -; -; 20; -; 22; 22; -
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
index 3f5c171..47bca00 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/model/NCModelEnricher.scala
@@ -203,7 +203,7 @@ object NCModelEnricher extends NCProbeEnricher {
val idxs = toks.map(_.index).sorted
- val note = NlpNote(idxs, elem.getId, params: _*)
+ val note = NlpNote(idxs, elem.getId, params.toSeq: _*)
toks.foreach(_.add(note))
@@ -367,7 +367,7 @@ object NCModelEnricher extends NCProbeEnricher {
val complexesWords = ns.map(Complex(_))
val complexes =
- NCProbeVariants.convert(ns.srvReqId, mdl,
NCSentenceManager.collapse(mdl.model, ns.clone())).
+ NCProbeVariants.convert(ns.srvReqId, mdl,
NCSentenceManager.collapse(mdl.model, ns.clone()).toSeq).
map(_.asScala).
par.
flatMap(sen =>
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 36cb77e..29ab443 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
@@ -27,8 +27,8 @@ import org.apache.nlpcraft.model.NCModel
import java.io.{Serializable => JSerializable}
import java.util
import java.util.{List => JList}
-import scala.collection.JavaConverters.{asScalaBufferConverter, _}
-import scala.collection.{Map, Seq, mutable}
+import scala.collection.mutable
+import scala.jdk.CollectionConverters._
import scala.language.implicitConversions
/**
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/numeric/NCNumericEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/numeric/NCNumericEnricher.scala
index a83d253..32da10e 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/numeric/NCNumericEnricher.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/numeric/NCNumericEnricher.scala
@@ -24,6 +24,7 @@ import org.apache.nlpcraft.common.nlp.numeric._
import org.apache.nlpcraft.server.nlp.enrichers.NCServerEnricher
import scala.collection._
+import scala.language.implicitConversions
/**
* Numeric enricher.
@@ -228,7 +229,7 @@ object NCNumericEnricher extends NCServerEnricher {
params += "unitType" -> unit.unitType
case None => // No-op.
}
-
+
NCNlpSentenceNote(toks.map(_.index), "nlpcraft:num", params:_*)
}