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


The following commit(s) were added to refs/heads/master by this push:
     new 0bd7b03  Minor improvements.
0bd7b03 is described below

commit 0bd7b0304cb6b2f3c141bdddd6ac67023dabad76
Author: Sergey Kamov <[email protected]>
AuthorDate: Mon Mar 22 17:56:38 2021 +0300

    Minor improvements.
---
 .../scala/org/apache/nlpcraft/common/nlp/NCNlpSentenceNote.scala | 9 +++++++--
 .../apache/nlpcraft/probe/mgrs/sentence/NCSentenceManager.scala  | 9 +++++++--
 2 files changed, 14 insertions(+), 4 deletions(-)

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 @@ class NCNlpSentenceNote(private val values: Map[String, 
java.io.Serializable]) e
     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 @@ object NCSentenceManager extends NCService {
                     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)

Reply via email to