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

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


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

commit ea3f929c91ab45f0499852ecc578231e0ff32476
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Mar 25 18:13:13 2021 +0300

    WIP.
---
 .../nlpcraft/common/config/NCConfigurableJava.java       |  4 ++--
 .../nlpcraft/common/extcfg/NCExternalConfigManager.scala |  4 ++--
 .../apache/nlpcraft/common/makro/NCMacroCompiler.scala   |  4 ++--
 .../nlpcraft/probe/mgrs/conn/NCConnectionManager.scala   | 16 +++++++---------
 .../nlpcraft/server/geo/tools/NCGeoNamesGenerator.scala  |  2 +-
 .../server/geo/tools/NCGeoStateNamesGenerator.scala      |  2 +-
 .../server/geo/tools/metro/NCGeoMetroGenerator.scala     |  2 +-
 .../server/geo/tools/unstats/NCUnsdStatsService.scala    |  2 +-
 .../scala/org/apache/nlpcraft/server/json/NCJson.scala   |  4 ++--
 9 files changed, 19 insertions(+), 21 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurableJava.java
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurableJava.java
index 320eb12..e7cfd45 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurableJava.java
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/config/NCConfigurableJava.java
@@ -62,7 +62,7 @@ public class NCConfigurableJava {
             abortWith(String.format("Invalid 'host:port' endpoint format: %s", 
ep));
 
         try {
-            return new Pair<String, Integer>(ep.substring(0, i), 
Integer.parseInt(ep.substring(i + 1)));
+            return new Pair<>(ep.substring(0, i), 
Integer.parseInt(ep.substring(i + 1)));
         }
         catch (NumberFormatException e) {
             abortWith(String.format("Invalid 'host:port' endpoint port: %s", 
ep));
@@ -80,7 +80,7 @@ public class NCConfigurableJava {
      * @return Pair of host and port from given configuration property or 
default values.
      */
     public Pair<String, Integer> getHostPortOrElse(String name, String 
dfltHost, int dfltPort) {
-        return cfg.hasPath(name) ? getHostPort(name) :  new Pair<String, 
Integer>(dfltHost, dfltPort);
+        return cfg.hasPath(name) ? getHostPort(name) : new Pair<>(dfltHost, 
dfltPort);
     }
 
     /**
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/extcfg/NCExternalConfigManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/extcfg/NCExternalConfigManager.scala
index c041f7c..d6e0b91 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/extcfg/NCExternalConfigManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/extcfg/NCExternalConfigManager.scala
@@ -231,7 +231,7 @@ object NCExternalConfigManager extends NCService {
     @throws[NCE]
     def getContent(typ: NCExternalConfigType, res: String, parent: Span = 
null): String =
         startScopedSpan("getContent", parent, "res" → res) { _ ⇒
-            mkString(U.readFile(mkFile(typ, res), "UTF-8"))
+            mkString(U.readFile(mkFile(typ, res)))
         }
 
     /**
@@ -269,7 +269,7 @@ object NCExternalConfigManager extends NCService {
                 d.listFiles(new FileFilter { override def accept(f: File): 
Boolean = f.isFile && resFilter(f.getName) })
 
             if (files != null)
-                files.toStream.map(f ⇒ NCExternalConfigHolder(typ, f.getName, 
mkString(U.readFile(f, "UTF-8"))))
+                files.toStream.map(f ⇒ NCExternalConfigHolder(typ, f.getName, 
mkString(U.readFile(f))))
             else
                 Stream.empty
         }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroCompiler.scala
index 16ff67f..561fe23 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/makro/NCMacroCompiler.scala
@@ -87,12 +87,12 @@ object NCMacroCompiler extends LazyLogging {
             // Add harmless empty string.
             buf += ""
 
-            stack.push(StackItem(buf, false))
+            stack.push(StackItem(buf, isGroup = false))
         }
 
         override def enterGroup(ctx: P.GroupContext): Unit = {
             // NOTE: group cannot be empty based on the BNF grammar.
-            stack.push(StackItem(mutable.Buffer.empty[String], true))
+            stack.push(StackItem(mutable.Buffer.empty[String], isGroup = true))
         }
 
         override def exitExpr(ctx: NCMacroDslParser.ExprContext): Unit = {
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
index 8121f88..e19a9d2 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conn/NCConnectionManager.scala
@@ -17,13 +17,6 @@
 
 package org.apache.nlpcraft.probe.mgrs.conn
 
-import java.io.{EOFException, IOException, InterruptedIOException}
-import java.net.{InetAddress, NetworkInterface}
-import java.util
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.atomic.AtomicInteger
-import java.util.{Properties, TimeZone}
-
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.common._
 import org.apache.nlpcraft.common.config.NCConfigurable
@@ -35,6 +28,11 @@ import org.apache.nlpcraft.probe.mgrs.NCProbeMessage
 import org.apache.nlpcraft.probe.mgrs.cmd.NCCommandManager
 import org.apache.nlpcraft.probe.mgrs.model.NCModelManager
 
+import java.io.{EOFException, IOException, InterruptedIOException}
+import java.net.{InetAddress, NetworkInterface}
+import java.util
+import java.util.concurrent.CountDownLatch
+import java.util.{Properties, TimeZone}
 import scala.collection.mutable
 
 /**
@@ -176,11 +174,11 @@ object NCConnectionManager extends NCService {
                 val ver = NCVersion.getCurrent
                 val tmz = TimeZone.getDefault
     
-                val srvNlpEng =
+                val srvNlpEng: String =
                     hashResp.getOrElse(
                         "NLP_ENGINE",
                         throw new HandshakeError("NLP engine parameter missed 
in response.")
-                    )
+                    ).asInstanceOf[String]
 
                 val probeNlpEng = NCNlpCoreManager.getEngine
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoNamesGenerator.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoNamesGenerator.scala
index 2b64a16..35ab1cc 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoNamesGenerator.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoNamesGenerator.scala
@@ -74,7 +74,7 @@ object NCGeoNamesGenerator extends App {
     // GEO name ID → internal representation mapping.
     private val ids = mutable.Map.empty[String, Location]
 
-    private def read(path: String): Seq[String] = U.readPath(path, 
"UTF-8").filter(!_.startsWith("#"))
+    private def read(path: String): Seq[String] = 
U.readPath(path).filter(!_.startsWith("#"))
 
     // Process country and continent information.
     private def processCountries(unsdContinents: Seq[NCUnsdStatsContinent]): 
Set[Country] = {
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoStateNamesGenerator.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoStateNamesGenerator.scala
index 8c570dc..e775cd9 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoStateNamesGenerator.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/NCGeoStateNamesGenerator.scala
@@ -31,7 +31,7 @@ import org.apache.nlpcraft.common.U
 object NCGeoStateNamesGenerator extends App {
     // Produce a map of regions (countryCode + regCode → region name)).
     private def getStates(txtFile: String): Map[String, String] =
-        U.readPath(txtFile, "UTF-8").filter(!_.startsWith("#")).flatMap(line ⇒ 
{
+        U.readPath(txtFile).filter(!_.startsWith("#")).flatMap(line ⇒ {
             val seq = line.split("\t").toSeq
 
             if (seq(7) == "ADM1" && seq(8) == "US") {
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/metro/NCGeoMetroGenerator.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/metro/NCGeoMetroGenerator.scala
index 28565ac..a76b823 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/metro/NCGeoMetroGenerator.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/metro/NCGeoMetroGenerator.scala
@@ -43,7 +43,7 @@ object NCGeoMetroGenerator extends App {
         U.normalize(s.replaceAll("\\(", " ").replaceAll("\\)", " "), " ")
 
     private def generate() {
-        val lines = U.readPath(in, "UTF-8").map(_.strip).filter(_.nonEmpty)
+        val lines = U.readPath(in).map(_.strip).filter(_.nonEmpty)
 
        // Skips header.
         val metro = lines.tail.filter(!_.contains("(not set)")).map(line ⇒ 
Holder(line.takeWhile(_ != ',')))
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/unstats/NCUnsdStatsService.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/unstats/NCUnsdStatsService.scala
index ac4ba82..c7030cf 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/unstats/NCUnsdStatsService.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/geo/tools/unstats/NCUnsdStatsService.scala
@@ -72,7 +72,7 @@ object NCUnsdStatsService {
     private val codesPath = s"$dir/codes.txt"
 
     private def read(path: String): Seq[String] =
-        U.readPath(path, 
"UTF-8").map(_.strip).filter(_.nonEmpty).filter(_.head != '#')
+        U.readPath(path).map(_.strip).filter(_.nonEmpty).filter(_.head != '#')
 
     def skip(iso: String): Boolean = SKIPPED_COUNTRIES_ISO3.contains(iso)
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/json/NCJson.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/json/NCJson.scala
index 9d1f452..a63b1c1 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/json/NCJson.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/json/NCJson.scala
@@ -239,14 +239,14 @@ object NCJson {
      *
      * @param f File to extract from.
      */
-    private def readFile(f: File): String = removeComments(U.readFile(f, 
"UTF-8").mkString)
+    private def readFile(f: File): String = 
removeComments(U.readFile(f).mkString)
 
     /**
       * Reads stream.
       *
       * @param in Stream to extract from.
       */
-    private def readStream(in: InputStream): String = 
removeComments(U.readStream(in, "UTF-8").mkString)
+    private def readStream(in: InputStream): String = 
removeComments(U.readStream(in).mkString)
 
     /**
      * Extracts type `T` from given JSON `file`.

Reply via email to