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

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

commit 4a17942cb49076a344ae841737943c0fb0e8ab18
Author: Aaron Radzinski <aradzin...@datalingvo.com>
AuthorDate: Fri Jan 7 20:50:44 2022 -0800

    WIP
---
 .../stanford/impl/NCStanfordEntityParserImpl.scala |  1 +
 .../parser/stanford/impl/NCStanfordNlpImpl.scala   | 10 +--
 .../main/scala/org/apache/nlpcraft/NCContext.java  |  2 +-
 .../main/scala/org/apache/nlpcraft/NCModel.java    |  2 +-
 .../scala/org/apache/nlpcraft/NCModelConfig.java   |  4 ++
 .../org/apache/nlpcraft/internal/ansi/NCAnsi.scala | 80 +++++++++++-----------
 .../nlpcraft/internal/ansi/NCAnsiProgressBar.scala | 15 ++--
 .../nlpcraft/internal/ansi/NCAnsiSpinner.scala     |  4 +-
 .../nlpcraft/internal/ascii/NCAsciiTable.scala     |  8 +--
 .../nlpcraft/internal/makro/NCMacroCompiler.scala  |  2 +-
 10 files changed, 63 insertions(+), 65 deletions(-)

diff --git 
a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/entity/parser/stanford/impl/NCStanfordEntityParserImpl.scala
 
b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/entity/parser/stanford/impl/NCStanfordEntityParserImpl.scala
index 069e41b..1085007 100644
--- 
a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/entity/parser/stanford/impl/NCStanfordEntityParserImpl.scala
+++ 
b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/entity/parser/stanford/impl/NCStanfordEntityParserImpl.scala
@@ -70,6 +70,7 @@ class NCStanfordEntityParserImpl(stanford: StanfordCoreNLP, 
supported: JSet[Stri
                             new NCPropertyMapAdapter with NCEntity:
                                 props.foreach { (k, v) => 
put(s"stanford:$typ:$k", v) }
 
+                                // TODO: why not vals?
                                 override def getTokens: JList[NCToken] = 
entToks.asJava
                                 override def getRequestId: String = 
req.getRequestId
                                 override def getId: String = s"stanford:$typ"
diff --git 
a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNlpImpl.scala
 
b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNlpImpl.scala
index 7c1f5d0..516cf77 100644
--- 
a/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNlpImpl.scala
+++ 
b/nlpcraft-stanford/src/main/java/org/apache/nlpcraft/nlp/token/parser/stanford/impl/NCStanfordNlpImpl.scala
@@ -45,18 +45,14 @@ class NCStanfordNlpImpl(stanford: StanfordCoreNLP) extends 
NCTokenParser:
     override def tokenize(text: String): JList[NCToken] =
         val doc = new CoreDocument(text)
         stanford.annotate(doc)
-        val ann: JList[CoreMap] = 
doc.annotation().get(classOf[SentencesAnnotation])
+        val ann = doc.annotation().get(classOf[SentencesAnnotation])
 
         if ann == null then
             throw new NCException("Sentence annotation not found.") // TODO: 
error text.
 
-        val toks: Seq[NCToken] =
-            ann.asScala.flatMap(p => {
-                val labels: JList[CoreLabel] = 
p.asInstanceOf[ArrayCoreMap].get(classOf[TokensAnnotation])
-
-                labels.asScala
-            }).
+        val toks = 
ann.asScala.flatMap(_.asInstanceOf[ArrayCoreMap].get(classOf[TokensAnnotation]).asScala).
             zipWithIndex.map { (t, idx) =>
+                // TODO: why not vals?
                 new NCPropertyMapAdapter with NCToken :
                     override def getText: String = t.originalText()
                     override def getLemma: String = t.lemma()
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCContext.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCContext.java
index 6887690..36a4a51 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCContext.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCContext.java
@@ -56,5 +56,5 @@ public interface NCContext {
      *
      * @return
      */
-    Collection<List<NCEntity>> getVariants();
+    Collection<NCVariant> getVariants();
 }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.java
index 4feec48..881a11b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.java
@@ -34,7 +34,7 @@ public interface NCModel {
      * @param vrn
      * @return
      */
-    default boolean onVariant(List<NCEntity> vrn) {
+    default boolean onVariant(NCVariant vrn) {
         return true;
     }
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
index ebf0a95..9113f9b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
@@ -29,6 +29,10 @@ public interface NCModelConfig extends NCPropertyMap {
      */
     NCTokenParser getTokenParser();
 
+    /**
+     *
+     * @return
+     */
     NCStemmer getStemmer();
 
     /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsi.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsi.scala
index 895bb94..16f8725 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsi.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsi.scala
@@ -51,8 +51,8 @@ sealed trait NCAnsi extends LazyLogging:
     private final val CYAN_B = s"${CSI}46m"
     private final val WHITE_B = s"${CSI}47m"
 
-    def ansi256Fg(color: Int): String = if (isEnabled) s"[38;5;${color}m" 
else ""
-    def ansi256Bg(color: Int): String = if (isEnabled) s"[48;5;${color}m" 
else ""
+    def ansi256Fg(color: Int): String = if isEnabled then s"[38;5;${color}m" 
else ""
+    def ansi256Bg(color: Int): String = if isEnabled then s"[48;5;${color}m" 
else ""
     def ansi256Fg(fgColor: Int, s: Any): String = 
s"${ansi256Fg(fgColor)}${s.toString}$ansiReset"
     def ansi256(fgColor: Int, bgColor: Int, s: Any): String = 
s"${ansi256Fg(fgColor)}${ansi256Bg(bgColor)}${s.toString}$ansiReset"
 
@@ -149,30 +149,30 @@ sealed trait NCAnsi extends LazyLogging:
     def bold(s: Any): String = s"$ansiBold${s.toString}$RST"
 
     // Color functions.
-    def ansiBlackFg: String = if (isEnabled) BLACK else ""
-    def ansiBlackBg: String = if (isEnabled) BLACK_B else ""
-    def ansiRedFg: String = if (isEnabled) RED else ""
-    def ansiRedBg: String = if (isEnabled) RED_B else ""
-    def ansiGreenFg: String = if (isEnabled) GREEN else ""
-    def ansiGreenBg: String = if (isEnabled) GREEN_B else ""
-    def ansiYellowFg: String = if (isEnabled) YELLOW else ""
-    def ansiYellowBg: String = if (isEnabled) YELLOW_B else ""
-    def ansiBlueFg: String = if (isEnabled) BLUE else ""
-    def ansiBlueBg: String = if (isEnabled) BLUE_B else ""
-    def ansiMagentaFg: String = if (isEnabled) MAGENTA else ""
-    def ansiMagentaBg: String = if (isEnabled) MAGENTA_B else ""
-    def ansiCyanFg: String = if (isEnabled) CYAN else ""
-    def ansiCyanBg: String = if (isEnabled) CYAN_B else ""
-    def ansiWhiteFg: String = if (isEnabled) WHITE else ""
-    def ansiWhiteBg: String = if (isEnabled) WHITE_B else ""
+    def ansiBlackFg: String = if isEnabled then BLACK else ""
+    def ansiBlackBg: String = if isEnabled then BLACK_B else ""
+    def ansiRedFg: String = if isEnabled then RED else ""
+    def ansiRedBg: String = if isEnabled then RED_B else ""
+    def ansiGreenFg: String = if isEnabled then GREEN else ""
+    def ansiGreenBg: String = if isEnabled then GREEN_B else ""
+    def ansiYellowFg: String = if isEnabled then YELLOW else ""
+    def ansiYellowBg: String = if isEnabled then YELLOW_B else ""
+    def ansiBlueFg: String = if isEnabled then BLUE else ""
+    def ansiBlueBg: String = if isEnabled then BLUE_B else ""
+    def ansiMagentaFg: String = if isEnabled then MAGENTA else ""
+    def ansiMagentaBg: String = if isEnabled then MAGENTA_B else ""
+    def ansiCyanFg: String = if isEnabled then CYAN else ""
+    def ansiCyanBg: String = if isEnabled then CYAN_B else ""
+    def ansiWhiteFg: String = if isEnabled then WHITE else ""
+    def ansiWhiteBg: String = if isEnabled then WHITE_B else ""
 
     // Effect functions.
-    def ansiBold: String = if (isEnabled) BOLD else ""
-    def ansiUnderlined: String = if (isEnabled) UNDERLINED else ""
-    def ansiReset: String = if (isEnabled) RESET else ""
-    def ansiReversed: String = if (isEnabled) REVERSED else ""
-    def ansiBlink: String = if (isEnabled) BLINK else ""
-    def ansiInvisible: String = if (isEnabled) INVISIBLE else ""
+    def ansiBold: String = if isEnabled then BOLD else ""
+    def ansiUnderlined: String = if isEnabled then UNDERLINED else ""
+    def ansiReset: String = if isEnabled then RESET else ""
+    def ansiReversed: String = if isEnabled then REVERSED else ""
+    def ansiBlink: String = if isEnabled then BLINK else ""
+    def ansiInvisible: String = if isEnabled then INVISIBLE else ""
 
     def ansiGreen(s: Any): String = s"$ansiGreenFg${s.toString}$ansiReset"
     def ansiRed(s: Any): String = s"$ansiRedFg${s.toString}$ansiReset"
@@ -185,24 +185,24 @@ sealed trait NCAnsi extends LazyLogging:
     def ansiBold(s: Any): String = s"$ansiBold${s.toString}$ansiReset"
 
     // Erase functions.
-    def ansiClearScreen: String = if (isEnabled) CLEAR_SCREEN else ""
-    def ansiClearScreenAfter: String = if (isEnabled) CLEAR_SCREEN_AFTER else 
""
-    def ansiClearScreenBefore: String = if (isEnabled) CLEAR_SCREEN_BEFORE 
else ""
-    def ansiClearLine: String = if (isEnabled) CLEAR_LINE else ""
-    def ansiClearLineAfter: String = if (isEnabled) CLEAR_LINE_AFTER else ""
-    def ansiClearLineBefore: String = if (isEnabled) CLEAR_LINE_BEFORE else ""
+    def ansiClearScreen: String = if isEnabled then CLEAR_SCREEN else ""
+    def ansiClearScreenAfter: String = if isEnabled then CLEAR_SCREEN_AFTER 
else ""
+    def ansiClearScreenBefore: String = if isEnabled then CLEAR_SCREEN_BEFORE 
else ""
+    def ansiClearLine: String = if isEnabled then CLEAR_LINE else ""
+    def ansiClearLineAfter: String = if isEnabled then CLEAR_LINE_AFTER else ""
+    def ansiClearLineBefore: String = if isEnabled then CLEAR_LINE_BEFORE else 
""
 
     // Cursor movement functions.
-    def ansiCursorUp: String = if (isEnabled) CURSOR_UP else ""
-    def ansiCursorDown: String = if (isEnabled) CURSOR_DOWN else ""
-    def ansiCursorLeft: String = if (isEnabled) CURSOR_LEFT else ""
-    def ansiCursorRight: String = if (isEnabled) CURSOR_RIGHT else ""
-    def ansiCursorLineHome: String = if (isEnabled) CURSOR_LINE_HOME else ""
-    def ansiCursorScreenHome: String = if (isEnabled) CURSOR_SCREEN_HOME else 
""
-    def ansiCursorPosSave: String = if (isEnabled) CURSOR_POS_SAVE else ""
-    def ansiCursorPosRestore: String = if (isEnabled) CURSOR_POS_RESTORE else 
""
-    def ansiCursorShow: String = if (isEnabled) CURSOR_SHOW else ""
-    def ansiCursorHide: String = if (isEnabled) CURSOR_HIDE else ""
+    def ansiCursorUp: String = if isEnabled then CURSOR_UP else ""
+    def ansiCursorDown: String = if isEnabled then CURSOR_DOWN else ""
+    def ansiCursorLeft: String = if isEnabled then CURSOR_LEFT else ""
+    def ansiCursorRight: String = if isEnabled then CURSOR_RIGHT else ""
+    def ansiCursorLineHome: String = if isEnabled then CURSOR_LINE_HOME else ""
+    def ansiCursorScreenHome: String = if isEnabled then CURSOR_SCREEN_HOME 
else ""
+    def ansiCursorPosSave: String = if isEnabled then CURSOR_POS_SAVE else ""
+    def ansiCursorPosRestore: String = if isEnabled then CURSOR_POS_RESTORE 
else ""
+    def ansiCursorShow: String = if isEnabled then CURSOR_SHOW else ""
+    def ansiCursorHide: String = if isEnabled then CURSOR_HIDE else ""
 
 /**
   *
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiProgressBar.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiProgressBar.scala
index 3135881..794b8ab 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiProgressBar.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiProgressBar.scala
@@ -84,17 +84,14 @@ class NCAnsiProgressBar(
             if useAnsi then
                 clean()
                 val ratio = tick.toFloat / totalTicks.toFloat
-                val bar = if (tick == 1) 1 else Math.round(ratio * dispSize)
+                val bar = if tick == 1 then 1 else Math.round(ratio * dispSize)
                 val pct = Math.round(ratio * 100)
                 out.print(PB_LEFT)
-                for (i <- 0 until dispSize) {
-                    if (i < bar)
-                        out.print(PB_FULL)
-                    else if (i == bar)
-                        out.print(PB_LEAD)
-                    else
-                        out.print(PB_EMPTY)
-                }
+                for (i <- 0 until dispSize)
+                    if i < bar then out.print(PB_FULL)
+                    else if i == bar then out.print(PB_LEAD)
+                    else out.print(PB_EMPTY)
+
                 out.print(PB_RIGHT)
                 out.print(" ")
                 out.print(W + StringUtils.rightPad(s"$pct%",4) + RST)
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiSpinner.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiSpinner.scala
index 08048a4..9b0878e 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiSpinner.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/ansi/NCAnsiSpinner.scala
@@ -43,14 +43,14 @@ class NCAnsiSpinner(out: PrintWriter, useAnsi: Boolean = 
true):
       * @param p
       */
     def setSuffix(p: String): Unit =
-        this.suffix = if (p == null) "" else p
+        this.suffix = if p == null then "" else p
 
     /**
       *
       * @param p
       */
     def setPrefix(p: String): Unit =
-        this.prefix = if (p == null) "" else p
+        this.prefix = if p == null then "" else p
 
     /**
       *
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 6bb3b4d..4a28a42 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
@@ -85,7 +85,7 @@ class NCAsciiTable:
       */
     private sealed case class Cell(style: Style, lines: Seq[String]):
         // Cell's calculated width including padding.
-        lazy val width: Int = style.padding + (if (height > 0) 
lines.map(NCUtils.stripAnsi(_).length).max else 0)
+        lazy val width: Int = style.padding + (if height > 0 then 
lines.map(NCUtils.stripAnsi(_).length).max else 0)
         // Gets height of the cell.
         lazy val height: Int = lines.length
 
@@ -285,11 +285,11 @@ class NCAsciiTable:
                 var curr = 0
                 val len = line.length
 
-                def addLine(s: String): Unit = buf += (if (buf.isEmpty) s else 
space(leader) + s)
+                def addLine(s: String): Unit = buf += (if buf.isEmpty then s 
else space(leader) + s)
 
                 while (curr < len)
                     if curr - start > maxWidth then
-                        val end = if (lastSpace == -1) curr else lastSpace + 1 
/* Keep space at the end of the line. */
+                        val end = if lastSpace == -1 then curr else lastSpace 
+ 1 /* Keep space at the end of the line. */
                         addLine(line.substring(start, end))
                         start = end
                     if line.charAt(curr) == ' ' then
@@ -506,7 +506,7 @@ class NCAsciiTable:
                     // Right margin.
                     tbl ++= s"${space(margin.right)}\n"
 
-                if (i < rows.size - 1 && ((rowH > 1 && multiLineAutoBorder) || 
insideBorder))
+                if i < rows.size - 1 && ((rowH > 1 && multiLineAutoBorder) || 
insideBorder) then
                     addHorLine(i)
 
             tbl ++= tblWidthLine
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 9e5ecca..c9ae012 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
@@ -65,7 +65,7 @@ object NCMacroCompiler extends LazyLogging:
           * @param s
           * @return
           */
-        private def concat(optS: String, s: String): String = if 
(optS.isEmpty) s else optS + " " + s
+        private def concat(optS: String, s: String): String = if optS.isEmpty 
then s else optS + " " + s
 
         /**
           *

Reply via email to