You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2022/09/03 18:16:34 UTC

[incubator-nlpcraft] branch master updated: Quick fixes.,

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 61548fb3 Quick fixes.,
61548fb3 is described below

commit 61548fb38920500fdb54a5f6075c690944120848
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sat Sep 3 11:16:29 2022 -0700

    Quick fixes.,
---
 ...ilerUtils.scala => NCCompilerErrorHolder.scala} | 29 +++-------------------
 .../nlpcraft/internal/antlr4/NCCompilerUtils.scala | 18 ++++----------
 .../internal/intent/compiler/NCIDLCompiler.scala   |  2 +-
 3 files changed, 10 insertions(+), 39 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/NCCompilerErrorHolder.scala
similarity index 50%
copy from nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
copy to nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerErrorHolder.scala
index bb13bd08..2f6c42c5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerErrorHolder.scala
@@ -17,31 +17,10 @@
 
 package org.apache.nlpcraft.internal.antlr4
 
-import org.apache.nlpcraft.internal.*
-
-case class CompilerErrorHolder(
+/**
+  *
+  */
+case class NCCompilerErrorHolder(
     ptrStr: String,
     origStr: String
 )
-
-object NCCompilerUtils:
-    /**
-      *
-      * @param in
-      * @param charPos
-      * @return
-      */
-    def mkErrorHolder(in: String, charPos: Int): CompilerErrorHolder =
-        val in0 = in.strip()
-        if in0.isEmpty || charPos < 0 then CompilerErrorHolder("<empty>", "<empty>")
-        else
-            val charPos0 = charPos - (in.length - in.stripLeading().length)
-            val pos = Math.max(0, charPos0)
-            val dash = "-" * in0.length
-
-            var ptrStr = s"${dash.substring(0, pos)}^"
-            if pos < dash.length - 1 then ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
-            else ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
-
-            val origStr = s"${in0.substring(0, pos)}${in0.charAt(pos)}${in0.substring(pos + 1)}"
-            CompilerErrorHolder(ptrStr, origStr)
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 bb13bd08..1940b254 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
@@ -19,11 +19,6 @@ package org.apache.nlpcraft.internal.antlr4
 
 import org.apache.nlpcraft.internal.*
 
-case class CompilerErrorHolder(
-    ptrStr: String,
-    origStr: String
-)
-
 object NCCompilerUtils:
     /**
       *
@@ -31,17 +26,14 @@ object NCCompilerUtils:
       * @param charPos
       * @return
       */
-    def mkErrorHolder(in: String, charPos: Int): CompilerErrorHolder =
+    def mkErrorHolder(in: String, charPos: Int): NCCompilerErrorHolder =
         val in0 = in.strip()
-        if in0.isEmpty || charPos < 0 then CompilerErrorHolder("<empty>", "<empty>")
+        if in0.isEmpty || charPos < 0 then NCCompilerErrorHolder("<empty>", "<empty>")
         else
             val charPos0 = charPos - (in.length - in.stripLeading().length)
             val pos = Math.max(0, charPos0)
             val dash = "-" * in0.length
-
-            var ptrStr = s"${dash.substring(0, pos)}^"
-            if pos < dash.length - 1 then ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
-            else ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
-
+            val ptrStr = s"${dash.substring(0, pos)}^${dash.substring(pos + 1)}"
             val origStr = s"${in0.substring(0, pos)}${in0.charAt(pos)}${in0.substring(pos + 1)}"
-            CompilerErrorHolder(ptrStr, origStr)
+
+            NCCompilerErrorHolder(ptrStr, origStr)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
index fbf0cf53..d8f4cba6 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
@@ -498,7 +498,7 @@ class NCIDLCompiler(cfg: NCModelConfig) extends LazyLogging with mutable.Cloneab
         intents.getOrElseUpdate(x, {
             val (fsm, parser) = antlr4Armature(x, origin, isMethodLevel)
 
-            // Parse the input IDL and walk built AST.
+            // Parse the input IDL and walk the built AST.
             (new ParseTreeWalker).walk(fsm, parser.idl())
 
             // Return the compiled intents.