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
The following commit(s) were added to refs/heads/NLPCRAFT-296 by this push:
new 1c9cbfd WIP.
1c9cbfd is described below
commit 1c9cbfdec7cd64a53580e9b19a2d8956b52c08ed
Author: unknown <[email protected]>
AuthorDate: Fri May 28 11:05:20 2021 -0700
WIP.
---
.../probe/mgrs/sentence/NCSentenceManager.scala | 18 ++++++++++--------
.../nlp/enrichers/stopword/NCStopWordEnricher.scala | 2 +-
.../server/sugsyn/NCSuggestSynonymManager.scala | 2 +-
3 files changed, 12 insertions(+), 10 deletions(-)
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 9120c84..4c49d1d 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
@@ -276,7 +276,7 @@ object NCSentenceManager extends NCService {
if (!buf.contains(idxs.head)) {
buf += idxs.head
- ns += mkCompound(ns, nsCopyToks, idxs, stop =
true, ns.size, None, history)
+ ns += mkCompound(ns, nsCopyToks.toSeq, idxs.toSeq,
stop = true, ns.size, None, history)
}
case None => simpleCopy(ns, history, nsCopyToks, i)
}
@@ -341,7 +341,7 @@ object NCSentenceManager extends NCService {
if (!buf.contains(n.tokenFrom)) {
buf += n.tokenFrom
- ns += mkCompound(ns, nsCopyToks, n.tokenIndexes,
stop = false, ns.size, Some(n), history)
+ ns += mkCompound(ns, nsCopyToks.toSeq,
n.tokenIndexes, stop = false, ns.size, Some(n), history)
}
case None => simpleCopy(ns, history, nsCopyToks, i)
}
@@ -529,11 +529,13 @@ object NCSentenceManager extends NCService {
notNlpTypes.foreach(typ => zipNotes(ns, typ, notNlpTypes, history))
unionStops(ns, notNlpTypes, history)
+ val histSeq = history.toSeq
+
val res =
- fixIndexesReferences("nlpcraft:relation", "indexes", "note", ns,
history) &&
- fixIndexesReferences("nlpcraft:limit", "indexes", "note", ns,
history) &&
- fixIndexesReferencesList("nlpcraft:sort", "subjindexes",
"subjnotes", ns, history) &&
- fixIndexesReferencesList("nlpcraft:sort", "byindexes", "bynotes",
ns, history)
+ fixIndexesReferences("nlpcraft:relation", "indexes", "note", ns,
histSeq) &&
+ fixIndexesReferences("nlpcraft:limit", "indexes", "note", ns,
histSeq) &&
+ fixIndexesReferencesList("nlpcraft:sort", "subjindexes",
"subjnotes", ns, histSeq) &&
+ fixIndexesReferencesList("nlpcraft:sort", "byindexes", "bynotes",
ns, histSeq)
if (res) {
// Validation (all indexes calculated well)
@@ -615,7 +617,7 @@ object NCSentenceManager extends NCService {
if (lastPhase)
dropAbstract(mdl, ns)
- if (collapseSentence(ns,
getNotNlpNotes(ns).map(_.noteType).distinct)) Some(ns) else None
+ if (collapseSentence(ns,
getNotNlpNotes(ns.toSeq).map(_.noteType).distinct)) Some(ns) else None
}
// Always deletes `similar` notes.
@@ -648,7 +650,7 @@ object NCSentenceManager extends NCService {
redundant.foreach(sen.removeNote)
var delCombs: Seq[NCNlpSentenceNote] =
- getNotNlpNotes(sen).
+ getNotNlpNotes(sen.toSeq).
flatMap(note => getNotNlpNotes(note.tokenIndexes.sorted.map(i
=> sen(i))).filter(_ != note)).
distinct
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/stopword/NCStopWordEnricher.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/stopword/NCStopWordEnricher.scala
index ac440d1..0762677 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/stopword/NCStopWordEnricher.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/nlp/enrichers/stopword/NCStopWordEnricher.scala
@@ -350,7 +350,7 @@ object NCStopWordEnricher extends NCServerEnricher {
val incl = toImmutable(m((isExc, form)).includes)
val excl = toImmutable(m((isExc, form)).excludes)
- mkInstance(any ++ excl.values.toSet.flatten, incl, excl)
+ mkInstance(any ++ excl.values.flatMap(x => x), incl, excl)
}
def mkHash(form: WordForm): HashHolder = mkHolder(mHash, form,
HashHolder)
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 02e51d2..cd3777b 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
@@ -323,7 +323,7 @@ object NCSuggestSynonymManager extends NCService {
allSgsts.
computeIfAbsent(elemId, (_:
String) => new CopyOnWriteArrayList[Suggestion]()).
- addAll(resps.flatten.asJava)
+ addAll(resps.flatMap(x =>
x).asJava)
if (i == allReqsCnt)
cdl.countDown()