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/12/31 08:37:01 UTC

[incubator-nlpcraft] branch master updated (7456d58 -> 5014de5)

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

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


    from 7456d58  Fix for dialog flow tests.
     new ced7b3b  Further fixes for dialog flow tests.
     new 5014de5  Update NCIntentSolverEngine.scala

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../nlpcraft/model/intent/impl/NCIntentSolverEngine.scala  | 14 +++++++++++---
 .../org/apache/nlpcraft/model/dialog/NCDialogSpec.scala    |  8 +++++---
 2 files changed, 16 insertions(+), 6 deletions(-)


[incubator-nlpcraft] 02/02: Update NCIntentSolverEngine.scala

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5014de51441994d751120b412cb92ef16ee77770
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Thu Dec 31 00:36:45 2020 -0800

    Update NCIntentSolverEngine.scala
---
 .../model/intent/impl/NCIntentSolverEngine.scala     | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
index c18d284..5058302 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
@@ -374,6 +374,7 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
       * @param convToks
       * @return
       */
+    //noinspection DuplicatedCode
     private def solveIntent(
         ctx: NCContext,
         intent: NCDslIntent,
@@ -386,24 +387,21 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
         val varStr = s"(variant #${varIdx + 1})"
         val flowRegex = intent.flowRegex
 
-        val histS = s"  |-- ${c("History:")} ${hist.mkString(" ")}"
+        def logFlowMatch(s: String) = {
+            logger.info(s)
+            logger.info(s"  |-- ${c("Dialog flow:")} ${hist.mkString(" ")}")
+            logger.info(s"  +-- ${c("Match regex:")} ${flowRegex.get.toString}")
+        }
 
         // Check dialog flow first.
         if (intent.flowRegex.isDefined && !flowRegex.get.matcher(hist.mkString(" ")).find(0)) {
-            logger.info(s"Intent '$intentId' ${r("did not")} match because of dialog flow $varStr:")
-            logger.info(histS)
-            logger.info(s"  +-- ${c("Regex:")}   ${flowRegex.get.toString}")
+            logFlowMatch(s"Intent '$intentId' ${r("did not")} match because of dialog flow $varStr:")
 
             None
         }
         else {
-            logger.whenDebugEnabled {
-                if (intent.flowRegex.isDefined) {
-                    logger.debug(s"Intent '$intentId' ${g("matched")} dialog flow $varStr:")
-                    logger.debug(histS)
-                    logger.debug(s"  +-- ${c("Regex:")}   ${flowRegex.get.toString}")
-                }
-            }
+            if (intent.flowRegex.isDefined)
+                logFlowMatch(s"Intent '$intentId' ${g("matched")} dialog flow $varStr:")
 
             val intentW = new Weight()
             val intentGrps = mutable.ListBuffer.empty[TermTokensGroup]


[incubator-nlpcraft] 01/02: Further fixes for dialog flow tests.

Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ced7b3b321563a7d5bcafa7df6f6c11983b72b35
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Thu Dec 31 00:27:03 2020 -0800

    Further fixes for dialog flow tests.
---
 .../nlpcraft/model/intent/impl/NCIntentSolverEngine.scala    | 12 +++++++++++-
 .../org/apache/nlpcraft/model/dialog/NCDialogSpec.scala      |  8 +++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
index 0da10af..c18d284 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
@@ -386,15 +386,25 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
         val varStr = s"(variant #${varIdx + 1})"
         val flowRegex = intent.flowRegex
 
+        val histS = s"  |-- ${c("History:")} ${hist.mkString(" ")}"
+
         // Check dialog flow first.
         if (intent.flowRegex.isDefined && !flowRegex.get.matcher(hist.mkString(" ")).find(0)) {
             logger.info(s"Intent '$intentId' ${r("did not")} match because of dialog flow $varStr:")
-            logger.info(s"  |-- ${c("History:")} ${hist.mkString(" ")}")
+            logger.info(histS)
             logger.info(s"  +-- ${c("Regex:")}   ${flowRegex.get.toString}")
 
             None
         }
         else {
+            logger.whenDebugEnabled {
+                if (intent.flowRegex.isDefined) {
+                    logger.debug(s"Intent '$intentId' ${g("matched")} dialog flow $varStr:")
+                    logger.debug(histS)
+                    logger.debug(s"  +-- ${c("Regex:")}   ${flowRegex.get.toString}")
+                }
+            }
+
             val intentW = new Weight()
             val intentGrps = mutable.ListBuffer.empty[TermTokensGroup]
             var abort = false
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
index 3d98c1b..b37a0d9 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/dialog/NCDialogSpec.scala
@@ -82,10 +82,14 @@ class NCDialogSpec extends NCTestContext {
 
         cli.clearConversation()
         cli.clearDialog()
+
+        go()
+
+        cli.clearConversation()
+        cli.clearDialog()
     }
 
     @Test
-    @throws[Exception]
     private[dialog] def test1(): Unit =
         f(
             "a2" → null,
@@ -97,7 +101,6 @@ class NCDialogSpec extends NCTestContext {
         )
 
     @Test
-    @throws[Exception]
     private[dialog] def test2(): Unit =
         f(
             "a3" → null,
@@ -109,7 +112,6 @@ class NCDialogSpec extends NCTestContext {
         )
 
     @Test
-    @throws[Exception]
     private[dialog] def test3(): Unit =
         f(
             "a4" → null,