Minor improvements.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentenceNote.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentenceNote.scala
index ae50852..e51ab50 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentenceNote.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentenceNote.scala
@@ -173,8 +173,13 @@
override def toString: String =
values.toSeq.sortBy(t ⇒ { // Don't show internal ID.
val typeSort = t._1 match {
- case "noteType" ⇒ 1
- case _ ⇒ Math.abs(t._1.hashCode)
+ case "noteType" ⇒ 0
+ case "wordIndexes" ⇒ 1
+ case "direct" ⇒ 2
+ case "sparsity" ⇒ 3
+ case "parts" ⇒ 4
+
+ case _ ⇒ 100
}
(typeSort, t._1)
}).map(p ⇒ s"${p._1}=${p._2}").mkString("NLP note [", ", ", "]")
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 47fffea..ad66b8f 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
@@ -664,10 +664,15 @@
val delCombOthers =
delCombs.filter(_ != note).flatMap(n ⇒ if (getPartKeys(n).contains(key)) Some(n) else None)
- if (delCombOthers.exists(o ⇒ noteWordsIdxs == o.wordIndexes.toSet)) Some(note) else None
+ if (
+ delCombOthers.exists(o ⇒ noteWordsIdxs == o.wordIndexes.toSet) ||
+ delCombOthers.nonEmpty && !delCombOthers.exists(o ⇒ noteWordsIdxs.subsetOf(o.wordIndexes.toSet))
+ )
+ Some(note)
+ else
+ None
})
-
delCombs = delCombs.filter(p ⇒ !swallowed.contains(p))
addDeleted(sen, sen, swallowed)
swallowed.foreach(sen.removeNote)