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

aradzinski 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 a5f8433  WIP
a5f8433 is described below

commit a5f84339ba267fd0e8bceff2d1c234ed92692046
Author: Aaron Radzinski <[email protected]>
AuthorDate: Mon Jan 17 13:30:21 2022 -0800

    WIP
---
 .../apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala    |  8 ++++----
 .../org/apache/nlpcraft/internal/ascii/NCAsciiTable.scala    |  8 ++++----
 .../org/apache/nlpcraft/internal/makro/NCMacroCompiler.scala | 12 ++++++------
 .../parser/semantic/impl/NCSemanticSynonymsProcessor.scala   | 10 ++++------
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
index 909d2f5..4142ddc 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
@@ -37,11 +37,11 @@ object NCCompilerUtils:
         val in0 = in.strip()
         val pos = Math.max(0, charPos0)
         val dash = "-" * in0.length
-        var ptrStr = dash.substring(0, pos) + r("^")
+        var ptrStr = s"${dash.substring(0, pos)}${r("^")}"
 
-        if pos < dash.length - 1 then ptrStr = ptrStr + y("~") + 
y(dash.substring(pos + 2))
-        else ptrStr = ptrStr + y(dash.substring(pos + 1))
+        if pos < dash.length - 1 then ptrStr = 
s"$ptrStr${y("~")}${y(dash.substring(pos + 2))}"
+        else ptrStr = s"$ptrStr${y(dash.substring(pos + 1))}"
 
-        val origStr = in0.substring(0, pos) + r(in0.charAt(pos)) + 
y(in0.substring(pos + 1))
+        val origStr = s"${in0.substring(0, 
pos)}${r(in0.charAt(pos))}${y(in0.substring(pos + 1))}"
 
         CompilerErrorHolder(ptrStr, origStr)
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ascii/NCAsciiTable.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ascii/NCAsciiTable.scala
index 1490b94..c1ac621 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ascii/NCAsciiTable.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ascii/NCAsciiTable.scala
@@ -289,7 +289,7 @@ class NCAsciiTable:
                 var curr = 0
                 val len = line.length
 
-                def addLine(s: String): Unit = buf += (if buf.isEmpty then s 
else space(leader) + s)
+                def addLine(s: String): Unit = buf += (if buf.isEmpty then s 
else s"${space(leader)}$s")
 
                 while (curr < len)
                     if curr - start > maxWidth then
@@ -393,9 +393,9 @@ class NCAsciiTable:
     private def aligned(txt: String, width: Int, sty: Style): String =
         val d = width - NCUtils.stripAnsi(txt).length
         sty.align match
-            case "center" => space(d / 2) + txt + space(d / 2 + d % 2)
-            case "left" => space(sty.leftPad) + txt + space(d - sty.leftPad)
-            case "right" => space(d - sty.rightPad) + txt + space(sty.rightPad)
+            case "center" => s"${space(d / 2)}$txt${space(d / 2 + d % 2)}"
+            case "left" => s"${space(sty.leftPad)}$txt${space(d - 
sty.leftPad)}"
+            case "right" => s"${space(d - 
sty.rightPad)}$txt${space(sty.rightPad)}"
             case _ => throw new AssertionError(s"Invalid align option: $sty")
 
     override def toString: String = mkString()
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/makro/NCMacroCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/makro/NCMacroCompiler.scala
index f6e7ef5..7fcca67 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/makro/NCMacroCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/makro/NCMacroCompiler.scala
@@ -66,7 +66,7 @@ object NCMacroCompiler extends LazyLogging:
           * @param s
           * @return
           */
-        private def concat(optS: String, s: String): String = if optS.isEmpty 
then s else optS + " " + s
+        private def concat(optS: String, s: String): String = if optS.isEmpty 
then s else s"$optS $s"
 
         /**
           *
@@ -84,7 +84,7 @@ object NCMacroCompiler extends LazyLogging:
           * @param ctx
           */
         private def checkMaxSyn(buf: mutable.Buffer[String])(implicit ctx: 
ParserRuleContext): Unit =
-            if buf.size > MAX_SYN then
+            if buf.sizeIs > MAX_SYN then
                 throw compilerError(s"Exceeded max number ($MAX_SYN) of macro 
expansions: ${buf.size}")
 
         override def enterExpr(ctx: NCMacroDslParser.ExprContext): Unit =
@@ -214,10 +214,10 @@ object NCMacroCompiler extends LazyLogging:
         val hldr = NCCompilerUtils.mkErrorHolder(in, charPos)
         val aMsg = NCUtils.decapitalize(msg) match
             case s: String if s.last == '.' => s
-            case s: String => s + '.'
-        s"Macro compiler error at line $line - $aMsg\n" +
-            s"  |-- ${c("Macro:")} ${hldr.origStr}\n" +
-            s"  +-- ${c("Error:")} ${hldr.ptrStr}"
+            case s: String => s"$s."
+        s"""Macro compiler error at line $line - $aMsg
+            |-- ${c("Macro:")} ${hldr.origStr}
+            +-- ${c("Error:")} ${hldr.ptrStr}"""
 
     /**
       *
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 23e7989..fcde40f 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
@@ -87,11 +87,9 @@ private[impl] object NCSemanticSynonymsProcessor extends 
LazyLogging:
 
             // Ignore suspicious chars if regex is used in macro...
             for ((name, value) <- macros if isSuspicious(name) || 
(isSuspicious(value) && !value.contains("//")))
-                logger.warn(
-                    s"Suspicious macro definition (use of 
${SUSP_SYNS_CHARS.map(s => s"'$s'").mkString(", ")} chars) [" +
-                        s"macro=$name" +
-                    s"]"
-                )
+                logger.warn(s"Suspicious macro definition (use of 
${SUSP_SYNS_CHARS.map(s => s"'$s'").mkString(", ")} chars) [" +
+                    s"macro=$name" +
+                s"]")
 
     /**
       *
@@ -139,7 +137,7 @@ private[impl] object NCSemanticSynonymsProcessor extends 
LazyLogging:
             if vals != null then
                 if hasNullOrEmpty(vals.keySet().asScala) then E(s"Some values 
names are null or empty [element=$elemId]")
                 for ((name, syns) <- vals.asScala)
-                    checkSynonyms(syns, elemId, Some(name))
+                    checkSynonyms(syns, elemId, Option(name))
 
     /**
       *

Reply via email to