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 e5846b1  Minor performance improvements.
e5846b1 is described below

commit e5846b1971c60195146f673dcdc247df96ccda07
Author: Sergey Kamov <[email protected]>
AuthorDate: Sat Feb 20 19:09:47 2021 +0300

    Minor performance improvements.
---
 .../org/apache/nlpcraft/common/nlp/NCNlpSentence.scala     | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala
index 23eeff6..0583a3d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala
@@ -696,6 +696,8 @@ class NCNlpSentence(
                 filter(n ⇒ !links.contains(NoteLink(n.noteType, 
n.tokenIndexes))).
                 filter(getPartKeys(_).isEmpty).
                 flatMap(n ⇒ {
+                    val wIdxs = n.wordIndexes.toSet
+
                     val owners =
                         delCombs.
                             filter(_ != n).
@@ -712,7 +714,17 @@ class NCNlpSentence(
                                     None
                             )
 
-                    if (owners.exists(_.wordIndexes == n.wordIndexes)) Some(n) 
else None
+
+                    if (owners.exists(
+                        o ⇒ {
+                            val oWIdxs = o.wordIndexes.toSet
+
+                            wIdxs == oWIdxs || wIdxs.subsetOf(oWIdxs)
+                        })
+                    )
+                        Some(n)
+                    else
+                        None
                 })
 
         delCombs = delCombs.filter(p ⇒ !swallowed.contains(p))

Reply via email to