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

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


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

commit 705db6314918fd3bda4cbc10198ea0264a9caccb
Author: Aaron Radzinski <[email protected]>
AuthorDate: Wed Mar 17 17:39:28 2021 -0700

    WIP.
---
 .../model/intent/solver/NCIntentSolverEngine.scala | 39 +++++++---------------
 .../intent/solver/NCIntentSolverVariant.scala      | 11 ++----
 2 files changed, 14 insertions(+), 36 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
index a22c10a..086d57a 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
@@ -125,7 +125,7 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
          */
         def toSeq: Seq[Int] = buf
 
-        override def toString: String = s"Weight (${buf.mkString(", ")})"
+        override def toString: String = buf.mkString(y("<"), " ,", y(">"))
     }
 
     /**
@@ -244,9 +244,6 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
                 )
             }
 
-            def intentMatchWeight(w: Seq[Int]): String =
-                s"${y("<")}${w.head}, ${w(1)}, ${w(2)}, ${w(3)}, ${w(4)}, 
${w(5)}${y(">")}"
-
             val sorted = matches.sortWith((m1: MatchHolder, m2: MatchHolder) ⇒
                 // 1. First with maximum weight.
                 m1.intentMatch.weight.compare(m2.intentMatch.weight) match {
@@ -255,8 +252,8 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
                     case x1 ⇒
                         require(x1 == 0)
 
-                        val mw1 = m1.intentMatch.weight.toSeq
-                        val mw2 = m2.intentMatch.weight.toSeq
+                        val mw1 = m1.intentMatch.weight
+                        val mw2 = m2.intentMatch.weight
 
                         val v1 = m1.variant
                         val v2 = m2.variant
@@ -276,27 +273,18 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
 
                         tbl += (
                             s"${c("Intent Match Weight")}",
-                            intentMatchWeight(mw1),
-                            intentMatchWeight(mw2)
+                            mw1,
+                            mw2
                         )
 
-                        def variantWeight(w: NCIntentSolverVariant): String =
-                            s"${y("<")}" +
-                                s"${w.userToks}, " +
-                                s"${w.wordCnt}, " +
-                                s"${w.totalUserDirect}, " +
-                                s"${w.avgWordsPerTokPct}, " +
-                                s"${w.totalSparsity}" +
-                            s"${y(">")}"
-    
                         tbl += (
                             s"${c("Variant Weight")}",
-                            variantWeight(v1),
-                            variantWeight(v2)
+                            v1,
+                            v2
                         )
 
                         logger.warn(
-                            s"Two matching intents have the ${y("same 
weight")} for their matches.\n" +
+                            s"Two matching intents have the ${y(bo("same 
weight"))} for their matches (variants weight will be used further):\n" +
                             tbl.toString
                         )
 
@@ -331,8 +319,7 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
 
                 sorted.foreach(m ⇒ {
                     val im = m.intentMatch
-                    val w = im.weight.toSeq
-                    val ws = intentMatchWeight(w)
+                    val w = im.weight
 
                     if (m == sorted.head)
                         tbl += (
@@ -345,14 +332,14 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
                                 g(bo("best match"))
                             ),
                             mkPickTokens(im),
-                            ws
+                            w
                         )
                     else
                         tbl += (
                             s"#${m.variantIdx + 1}",
                             im.intent.id,
                             mkPickTokens(im),
-                            ws
+                            w
                         )
 
                     if (logHldr != null)
@@ -399,9 +386,7 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
         var grpIdx = 0
 
         for (grp ← im.tokenGroups) {
-            val term = grp.term
-
-            buf += s"  ${term.dsl}"
+            buf += s"  ${grp.term}"
 
             grpIdx += 1
 
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
index 56e2d22..5594161 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
@@ -17,6 +17,7 @@
 
 package org.apache.nlpcraft.model.intent.solver
 
+import org.apache.nlpcraft.common._
 import org.apache.nlpcraft.model.NCToken
 import org.apache.nlpcraft.model.impl.NCTokenPimp._
 
@@ -79,13 +80,5 @@ case class NCIntentSolverVariant(tokens: util.List[NCToken]) 
extends Ordered[NCI
         else 0
     }
 
-    override def toString: String =
-        s"Variant [" +
-            s"userToks=$userToks" +
-            s", wordCnt=$wordCnt" +
-            s", totalUserDirect=$totalUserDirect" +
-            s", avgWordsPerTokPct=$avgWordsPerTokPct" +
-            s", sparsity=$totalSparsity" +
-            s", toks=$tokens" +
-            "]"
+    override def toString: String = s"${y("<")}$userToks, $wordCnt, 
$totalUserDirect, $avgWordsPerTokPct, $totalSparsity${y(">")}"
 }

Reply via email to