You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2020/03/14 07:00:38 UTC
[incubator-nlpcraft] 06/13: WIP.
This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit aa60ed85acdf7b0f4da84eebf6d438d0158511d6
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Fri Mar 13 15:54:10 2020 +0300
WIP.
---
.../nlp/enrichers/post/NCPostEnrichProcessor.scala | 18 +++++++-----------
1 file changed, 7 insertions(+), 11 deletions(-)
diff --git a/src/main/scala/org/nlpcraft/probe/mgrs/nlp/enrichers/post/NCPostEnrichProcessor.scala b/src/main/scala/org/nlpcraft/probe/mgrs/nlp/enrichers/post/NCPostEnrichProcessor.scala
index 998607f..e9fc986 100644
--- a/src/main/scala/org/nlpcraft/probe/mgrs/nlp/enrichers/post/NCPostEnrichProcessor.scala
+++ b/src/main/scala/org/nlpcraft/probe/mgrs/nlp/enrichers/post/NCPostEnrichProcessor.scala
@@ -228,13 +228,10 @@ object NCPostEnrichProcessor extends NCService with LazyLogging {
unionStops(ns, notNlpTypes, history, idCache)
val res =
- Seq(
- "nlpcraft:aggregation",
- "nlpcraft:relation",
- "nlpcraft:limit"
- ).forall(t ⇒ fixIndexesReferences(t, ns, history) &&
+ Seq("nlpcraft:aggregation", "nlpcraft:relation", "nlpcraft:limit").
+ forall(t ⇒ fixIndexesReferences(t, ns, history)) &&
fixIndexesReferencesList("nlpcraft:sort", "subjIndexes", "subjNotes", ns, history) &&
- fixIndexesReferencesList("nlpcraft:sort", "byIndexes", "byNotes", ns, history))
+ fixIndexesReferencesList("nlpcraft:sort", "byIndexes", "byNotes", ns, history)
if (res)
// Validation (all indexes calculated well)
@@ -271,6 +268,7 @@ object NCPostEnrichProcessor extends NCService with LazyLogging {
}
}).distinct
+
/**
Example:
1. Sentence 'maximum x' (single element related function)
@@ -286,7 +284,7 @@ object NCPostEnrichProcessor extends NCService with LazyLogging {
*/
types.size match {
- case 0 ⇒ throw new AssertionError("Unexpected empty types")
+ case 0 ⇒ throw new AssertionError(s"Unexpected empty types [notesType=$notesType]")
case 1 ⇒ types.head == notesType
case _ ⇒
// Equal elements should be processed together with function element.
@@ -359,16 +357,14 @@ object NCPostEnrichProcessor extends NCService with LazyLogging {
val idxs: Seq[Seq[Int]] = n.data[java.util.List[java.util.List[Int]]](idxsField).asScala.map(_.asScala)
var fixed = idxs
- history.foreach { case (idxOld, idxNew) ⇒ fixed = fixed.map(_.map(i ⇒ if (i == idxOld) idxNew else i)) }
-
- fixed = fixed.distinct
+ history.foreach { case (idxOld, idxNew) ⇒ fixed = fixed.map(_.map(i ⇒ if (i == idxOld) idxNew else i).distinct) }
if (idxs != fixed) {
n += idxsField → fixed.map(_.asJava).asJava.asInstanceOf[java.io.Serializable]
def x(seq: Seq[Seq[Int]]): String = s"[${seq.map(p ⇒ s"[${p.mkString(",")}]").mkString(", ")}]"
- logger.trace(s"`$noteType` note `indexes` fixed [old=${x(idxs)}}, new=${x(fixed)}]")
+ logger.info(s"`$noteType` note `indexes` fixed [old=${x(idxs)}}, new=${x(fixed)}]")
}
case None ⇒ // No-op.
}