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

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


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

commit 212ab9a5ed08c50ebaa25fb6b040d1f79f24b81d
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Dec 30 19:39:46 2021 +0300

    WIP.
---
 .../semantic/impl/NCSemanticSynonymsProcessor.scala | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
index b92a9f8..a75f870 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
@@ -82,25 +82,20 @@ private[impl] object NCSemanticSynonymsProcessor extends 
LazyLogging:
       * @param valueName
       */
     private def checkSynonyms(syns: JList[String], elemId: String, valueName: 
Option[String] = None): Unit =
+        def mkDesc: String =
+            val valuePart = if valueName.isDefined then s", 
value=${valueName.get}" else ""
+
+            s"[id=$elemId$valuePart]"
+
         if syns != null then
-            if syns.contains(null) then throw new NCException(
-                "Some synonyms are null[" +
-                s"id=$elemId, " +
-                (if valueName.isDefined then s"value=${valueName.get}, " else 
"") +
-                "]"
-            )
+            if syns.contains(null) then throw new NCException(s"Some synonyms 
are null $mkDesc")
 
             val susp = syns.asScala.filter(syn => !syn.contains("//") && 
SUSP_SYNS_CHARS.exists(susp => syn.contains(susp)))
 
             if susp.nonEmpty then
                 logger.warn(
-                    s"Suspicious synonyms detected (use of 
${SUSP_SYNS_CHARS.map(s => s"'$s'").mkString(", ")} chars) [" +
-                    s"id=$elemId, " +
-                    (if valueName.isDefined then s"value=${valueName.get}, " 
else "") +
-                    s"synonyms=[${susp.mkString(", ")}]" +
-                    s"]"
+                    s"Suspicious synonyms detected (use of 
${SUSP_SYNS_CHARS.map(s => s"'$s'").mkString(", ")} chars) $mkDesc"
                 )
-
     /**
       *
       * @param elements
@@ -129,6 +124,8 @@ private[impl] object NCSemanticSynonymsProcessor extends 
LazyLogging:
             checkSynonyms(e.getSynonyms, elemId)
 
             if e.getValues != null then
+                if e.getValues.contains(null) then throw new 
NCException(s"Some values are null [element=$elemId]")
+
                 for (v <- e.getValues.asScala)
                     val name = v.getName
 

Reply via email to