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

sergeykamov 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 cd7dd75  Minor fixes.
cd7dd75 is described below

commit cd7dd75cae35ff6f70e16c18ddde1ea0bd77354e
Author: Sergey Kamov <skhdlem...@gmail.com>
AuthorDate: Sat Feb 19 00:16:30 2022 +0300

    Minor fixes.
---
 .../nlpcraft/internal/impl/NCModelClientImpl.scala | 25 +++++++++++-----------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelClientImpl.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelClientImpl.scala
index a4e6d62..2ab3b3b 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelClientImpl.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelClientImpl.scala
@@ -79,7 +79,6 @@ class NCModelClientImpl(mdl: NCModel) extends LazyLogging:
         dlgMgr.start()
         plMgr.start()
 
-
      /*
       * @param txt
       * @param data
@@ -112,7 +111,6 @@ class NCModelClientImpl(mdl: NCModel) extends LazyLogging:
 
         intentsMgr.solve(NCIntentSolverInput(ctx, mdl))
 
-
     /**
       *
       * @param usrId
@@ -145,21 +143,22 @@ class NCModelClientImpl(mdl: NCModel) extends LazyLogging:
         case class Result(intentId: String, text: String, pass: Boolean, 
error: Option[String], time: Long)
 
         val userId = UUID.randomUUID().toString
-        val results = mutable.ArrayBuffer.empty[Result]
+        val res = mutable.ArrayBuffer.empty[Result]
 
         def now: Long = System.currentTimeMillis()
 
         for (i <- intents; samples <- i.samples)
             for (sample <- samples)
-                val t = now
+                val start = now
+
+                val err: Option[String] =
+                    try
+                        ask(sample, null, userId)
 
-                try
-                    ask(sample, null, userId)
+                        None
+                    catch case e: Throwable => Option(e.getMessage)
 
-                    results += Result(i.intent.id, sample, true, None, now - t)
-                catch
-                    case e: Throwable =>
-                        results += Result(i.intent.id, sample, true, 
Option(e.getMessage), now - t)
+                res += Result(i.intent.id, sample, err.isEmpty, err, now - 
start)
 
             clearDialog(userId)
             clearStm(userId)
@@ -168,7 +167,7 @@ class NCModelClientImpl(mdl: NCModel) extends LazyLogging:
 
         tbl #= ("Intent ID", "+/-", "Text", "Error", "ms.")
 
-        for (res <- results)
+        for (res <- res)
             tbl += (
                 res.intentId,
                 if res.pass then "OK" else "FAIL",
@@ -177,8 +176,8 @@ class NCModelClientImpl(mdl: NCModel) extends LazyLogging:
                 res.time
             )
 
-        val passCnt = results.count(_.pass)
-        val failCnt = results.count(!_.pass)
+        val passCnt = res.count(_.pass)
+        val failCnt = res.count(!_.pass)
 
         tbl.info(logger, Option(s"Model auto-validation results: OK $passCnt, 
FAIL $failCnt:"))
 

Reply via email to