This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-30
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-30 by this push:
     new 8dcf60a  WIP.
8dcf60a is described below

commit 8dcf60ad18b906b47d5bd04cae0bd5218044d00a
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Apr 30 17:19:42 2020 +0300

    WIP.
---
 .../mgrs/nlp/enrichers/limit/NCLimitEnricher.scala | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
index 3e554cc..bf798df 100644
--- 
a/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
+++ 
b/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCLimitEnricher.scala
@@ -272,17 +272,16 @@ object NCLimitEnricher extends NCProbeEnricher {
         val i2 = toks.last.index
 
         val refCands = toks.filter(_.exists(n ⇒ n.isUser && 
n.tokenIndexes.head >= i1 && n.tokenIndexes.last <= i2))
-        val commonRefNotes = getCommonNotes(refCands)
 
-        if (commonRefNotes.nonEmpty) {
-            val matchCands = toks.diff(refCands)
-            val idxs = refCands.map(_.index)
+        // Reference should be last.
+        if (refCands.nonEmpty && refCands.last.index == toks.last.index) {
+            val commonRefNotes = getCommonNotes(refCands)
 
-            val minRefIdx = idxs.min
+            if (commonRefNotes.nonEmpty) {
+                val matchCands = toks.diff(refCands)
+                val idxs = refCands.map(_.index)
 
-            def try0(group: Seq[NCNlpSentenceToken]): Option[Match] =
-                // All references must be after token for limits.
-                if (group.forall(_.index < minRefIdx))
+                def try0(group: Seq[NCNlpSentenceToken]): Option[Match] =
                     groupsMap.get(group) match {
                         case Some(h) ⇒
                             if (LIMITS.contains(h.value) || h.isFuzzyNum)
@@ -294,13 +293,14 @@ object NCLimitEnricher extends NCProbeEnricher {
                                 }
                         case None ⇒ None
                     }
-                else
-                    None
 
-            try0(matchCands) match {
-                case Some(m) ⇒ Some(m)
-                case None ⇒ try0(matchCands.filter(!_.isStopWord))
+                try0(matchCands) match {
+                    case Some(m) ⇒ Some(m)
+                    case None ⇒ try0(matchCands.filter(!_.isStopWord))
+                }
             }
+            else
+                None
         }
         else
             None

Reply via email to