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 2020/08/20 04:39:31 UTC
[incubator-nlpcraft] branch NLPCRAFT-41 updated: Fix for
NLPCRAFT-104.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-41
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-41 by this push:
new 1ab9aed Fix for NLPCRAFT-104.
1ab9aed is described below
commit 1ab9aed67ff8d328c16805245edfd08f97400edb
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Wed Aug 19 21:39:19 2020 -0700
Fix for NLPCRAFT-104.
---
.../apache/nlpcraft/model/impl/NCTokenLogger.scala | 30 ++++++++--------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenLogger.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenLogger.scala
index 340f7f2..4908bfc 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenLogger.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenLogger.scala
@@ -33,6 +33,9 @@ import scala.collection._
/**
* Utility service that provides supporting functionality for ASCII rendering.
*/
+// TODO: we need to refactor this class eventually to remove
+// TODO: duplicate code usage.
+//noinspection DuplicatedCode
object NCTokenLogger extends LazyLogging {
case class NoteMetadata(noteType: String, filtered: Seq[String], isFull: Boolean)
@@ -85,6 +88,8 @@ object NCTokenLogger extends LazyLogging {
).map(p ⇒ p._1 → p._2.zipWithIndex.map(p ⇒ p._1 → p._2).toMap)
private def format(l: Long): String = new SimpleDateFormat("yyyy/MM/dd").format(new java.util.Date(l))
+ private def mkMore(incl: Boolean): String = if (incl) ">=" else ">"
+ private def mkLess(incl: Boolean): String = if (incl) "<=" else "<"
/**
* Filters and sorts keys pairs to visually group notes logically.
@@ -152,8 +157,6 @@ object NCTokenLogger extends LazyLogging {
found.get._2
}
- def mkMore(incl: Boolean): String = if (incl) ">=" else ">"
- def mkLess(incl: Boolean): String = if (incl) "<=" else "<"
def mkValue(name: String, fractionalField: String): String = {
val d = getValue(name).asInstanceOf[Double]
@@ -182,15 +185,8 @@ object NCTokenLogger extends LazyLogging {
}
def mkDouble3(name: String): Double = (getValue(name).asInstanceOf[Double] * 1000).intValue / 1000.0
-
def indexes2String(v: java.io.Serializable): String = v.asInstanceOf[util.List[Int]].asScala.mkString(",")
def mkIndexes(name: String): String = indexes2String(getValue(name))
- def mkIndexesOpt(name: String): Option[String] =
- getValueOpt(name) match {
- case Some(indexes) ⇒ Some(indexes2String(indexes))
- case None ⇒ None
- }
-
def getSeq(names: String*): String = names.flatMap(name ⇒ mkStringOpt(name)).mkString("|")
note.noteType match {
@@ -232,10 +228,8 @@ object NCTokenLogger extends LazyLogging {
val ascOpt = mkBoolOpt("asc")
- ascOpt match {
- case Some(asc) ⇒ s = s"$s, asc=$asc"
- case None ⇒ // No-op.
- }
+ if (ascOpt.isDefined)
+ s = s"$s, asc=${ascOpt.get}"
s
@@ -246,10 +240,8 @@ object NCTokenLogger extends LazyLogging {
var s = s"limit=$limit, indexes=[${mkIndexes("indexes")}], note=$note"
- ascOpt match {
- case Some(asc) ⇒ s = s"$s, asc=$asc"
- case None ⇒ // No-op.
- }
+ if (ascOpt.isDefined)
+ s = s"$s, asc=${ascOpt.get}"
s
@@ -333,6 +325,7 @@ object NCTokenLogger extends LazyLogging {
s = s"$s, meta=$v"
}
+
case None ⇒ // No-op.
}
@@ -518,9 +511,6 @@ object NCTokenLogger extends LazyLogging {
if (fr) d.toString else d.toInt.toString
}
- def mkMore(incl: Boolean): String = if (incl) ">=" else ">"
- def mkLess(incl: Boolean): String = if (incl) "<=" else "<"
-
val from = mkValue("from", "isfractional")
val to = mkValue("to", "isfractional")
val fromIncl: Boolean = get("fromincl")