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

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


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

commit f140ed5a076a0f9a6f209982c17a5ff810c24747
Author: Sergey Kamov <[email protected]>
AuthorDate: Fri Mar 11 10:44:02 2022 +0300

    WIP.
---
 .../parser/impl/NCSemanticEntityParserImpl.scala   | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/mult/entity/parser/impl/NCSemanticEntityParserImpl.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/mult/entity/parser/impl/NCSemanticEntityParserImpl.scala
index 6f01131..d49ffd5 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/mult/entity/parser/impl/NCSemanticEntityParserImpl.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/mult/entity/parser/impl/NCSemanticEntityParserImpl.scala
@@ -246,19 +246,20 @@ class NCSemanticEntityParserImpl(
                                         elems.foreach(elem => 
add(elem.elementId, elem.value))
                                     case None => // No-op.
                         // With regex.
-                        for ((elemId, syns) <- 
synsHolder.mixedSynonyms.getOrElse(variant.size, Seq.empty))
-                            for (s <- syns if !found)
-                                found = s.chunks.zip(variant).
-                                    sortBy { (chunk, _) => if chunk.isText 
then 0 else 1 }.
-                                    forall { (chunk, tok) =>
-                                        if chunk.isText then
-                                            chunk.stem == stems(tok) || 
(stems4Lemms.nonEmpty && chunk.stem == stems4Lemms(tok))
-                                        else
-                                            def match0(txt: String) = 
chunk.regex.matcher(txt).matches()
-                                            match0(tok.getText) || 
match0(tok.getText.toLowerCase)
-                                    }
-
-                                if found then add(elemId, Option.when(s.value 
!= null)(s.value))
+                        if !found then
+                            for ((elemId, syns) <- 
synsHolder.mixedSynonyms.getOrElse(variant.size, Seq.empty))
+                                for (s <- syns if !found)
+                                    found = s.chunks.zip(variant).
+                                        sortBy { (chunk, _) => if chunk.isText 
then 0 else 1 }.
+                                        forall { (chunk, tok) =>
+                                            if chunk.isText then
+                                                chunk.stem == stems(tok) || 
(stems4Lemms.nonEmpty && chunk.stem == stems4Lemms(tok))
+                                            else
+                                                def match0(txt: String) = 
chunk.regex.matcher(txt).matches()
+                                                match0(tok.getText) || 
match0(tok.getText.toLowerCase)
+                                        }
+
+                                    if found then add(elemId, 
Option.when(s.value != null)(s.value))
 
         hs.toSeq.map(h => {
             val e = elemsMap(h.elemId)

Reply via email to