nlpcraft-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aradzin...@apache.org
Subject [incubator-nlpcraft] branch NLPCRAFT-369 updated: WIP on NLPCRAFT-369.
Date Tue, 27 Jul 2021 06:35:27 GMT
This is an automated email from the ASF dual-hosted git repository.

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


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

commit e47876917ee2ca4beaddb316304056e24c007d53
Author: Aaron Radzinski <aradzinski@datalingvo.com>
AuthorDate: Mon Jul 26 23:35:19 2021 -0700

    WIP on NLPCRAFT-369.
---
 .../model/intent/solver/NCIntentSolverEngine.scala |  2 +-
 .../model/tools/test/NCTestClientBuilder.java      | 22 +++++++++++-----------
 .../nlpcraft/probe/mgrs/cmd/NCCommandManager.scala |  4 ++--
 .../probe/mgrs/conversation/NCConversation.scala   | 16 ++++++++--------
 .../mgrs/dialogflow/NCDialogFlowManager.scala      |  6 +++---
 .../probe/mgrs/nlp/NCProbeEnrichmentManager.scala  | 12 ++++++------
 nlpcraft/src/test/resources/log4j2.xml             |  2 +-
 .../model/intent/idl/options/NCStmOnlySpec.scala   |  9 +++++----
 8 files changed, 37 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 660c737..dd59a88 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
@@ -345,7 +345,7 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace
{
                         )
                 })
 
-                tbl.info(logger, Some(s"Found ${sorted.size} matching intents (sorted $G${BO}best$RST
to worst):"))
+                tbl.info(logger, Some(s"Found ${sorted.size} matching ${if (sorted.size >
1) "intents" else "intent"} (sorted $G${BO}best$RST to worst):"))
             }
             else
                 logger.info("No matching intent found.")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClientBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClientBuilder.java
index 434a773..72e7234 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClientBuilder.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClientBuilder.java
@@ -569,7 +569,7 @@ public class NCTestClientBuilder {
                 resJs = restAskSync(txt);
             }
             catch (NCTestClientException e) {
-                log.info("'ask' request '{}' answered unsuccessfully with error: {}",
+                log.trace("'ask' request '{}' answered unsuccessfully with error: {}",
                     txt,
                     e.getLocalizedMessage()
                 );
@@ -613,7 +613,7 @@ public class NCTestClientBuilder {
                 srvReqId = restAsk(txt);
             }
             catch (NCTestClientException e) {
-                log.info("'ask' request '{}' answered unsuccessfully with error: {}",
+                log.trace("'ask' request '{}' answered unsuccessfully with error: {}",
                     txt,
                     e.getLocalizedMessage()
                 );
@@ -674,7 +674,7 @@ public class NCTestClientBuilder {
                 assert res.getResultType().isPresent() && res.getResult().isPresent();
 
                 if (respLog) {
-                    log.info("'ask' request '{}' answered successfully with '{}' result:\n{}",
+                    log.trace("'ask' request '{}' answered successfully with '{}' result:\n{}",
                         txt,
                         res.getResultType().get(),
                         mkPrettyString(
@@ -688,7 +688,7 @@ public class NCTestClientBuilder {
                 assert res.getResultError().isPresent();
 
                 if (respLog) {
-                    log.info("'ask' request '{}' answered unsuccessfully with result:\n{}",
txt,
+                    log.trace("'ask' request '{}' answered unsuccessfully with result:\n{}",
txt,
                         res.getResultError().get());
                 }
             }
@@ -896,7 +896,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private void restCancel() throws IOException, NCTestClientException {
-            log.info("'cancel' request sent.");
+            log.trace("'cancel' request sent.");
 
             checkStatus(
                 gson.fromJson(
@@ -915,7 +915,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private void restClearConversation() throws IOException, NCTestClientException {
-            log.info("'clear/conversation' request sent for data model: {}", mdlId);
+            log.trace("'clear/conversation' request sent for data model: {}", mdlId);
 
             checkStatus(gson.fromJson(
                 post(
@@ -933,7 +933,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private void restClearDialog() throws IOException, NCTestClientException {
-            log.info("'clear/dialog' request sent for data model: {}", mdlId);
+            log.trace("'clear/dialog' request sent for data model: {}", mdlId);
 
             checkStatus(gson.fromJson(
                 post(
@@ -951,7 +951,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private String restSignin() throws IOException, NCTestClientException {
-            log.info("'/signin' request sent for: {}", email);
+            log.trace("'/signin' request sent for: {}", email);
 
             String res = post("/signin", Pair.of("email", email), Pair.of("passwd", pswd));
 
@@ -969,7 +969,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private NCRequestResultJson restAskSync(String txt) throws IOException, NCTestClientException
{
-            log.info("'ask/sync' request '{}' sent for data model: {}", txt, mdlId);
+            log.trace("'ask/sync' request '{}' sent for data model: {}", txt, mdlId);
 
             return
                 gson.fromJson(
@@ -990,7 +990,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private String restAsk(String txt) throws IOException, NCTestClientException {
-            log.info("'ask' request '{}' sent for data model: {}", txt, mdlId);
+            log.trace("'ask' request '{}' sent for data model: {}", txt, mdlId);
 
             Map<String, Object> m = gson.fromJson(post(
                 "ask",
@@ -1009,7 +1009,7 @@ public class NCTestClientBuilder {
          * @throws NCTestClientException Thrown in case of test client errors.
          */
         private void restSignout() throws IOException, NCTestClientException {
-            log.info("'/signout' request sent for: {}", email);
+            log.trace("'/signout' request sent for: {}", email);
 
             checkStatus(gson.fromJson(
                 post(
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
index 79a4605..9bd578d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
@@ -106,7 +106,7 @@ object NCCommandManager extends NCService {
 
                         NCConversationManager.getConversation(usrId, mdlId, span).clearTokens((_:
NCToken) => true)
 
-                        logger.info(s"Cleared conversation history upon server request [usrId=$usrId,
mdlId=$mdlId]")
+                        logger.trace(s"Cleared conversation history upon server request [usrId=$usrId,
mdlId=$mdlId]")
 
                     case "S2P_CLEAR_DLG" =>
                         val usrId = msg.data[Long]("usrId")
@@ -114,7 +114,7 @@ object NCCommandManager extends NCService {
 
                         NCDialogFlowManager.clear(usrId, mdlId, span)
 
-                        logger.info(s"Cleared dialog history upon server request [usrId=$usrId,
mdlId=$mdlId]")
+                        logger.trace(s"Cleared dialog history upon server request [usrId=$usrId,
mdlId=$mdlId]")
 
                     case "S2P_ASK" =>
                         NCProbeEnrichmentManager.ask(
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversation.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversation.scala
index def79a0..7b1e564 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversation.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/conversation/NCConversation.scala
@@ -88,7 +88,7 @@ case class NCConversation(
             if (now - lastUpdateTstamp > timeoutMs) {
                 stm.clear()
 
-                logger.info(s"STM is reset by timeout [" +
+                logger.trace(s"STM is reset by timeout [" +
                     s"usrId=$usrId, " +
                     s"mdlId=$mdlId" +
                 s"]")
@@ -96,7 +96,7 @@ case class NCConversation(
             else if (depth > maxDepth) {
                 stm.clear()
 
-                logger.info(s"STM is reset after reaching max depth [" +
+                logger.trace(s"STM is reset after reaching max depth [" +
                     s"usrId=$usrId, " +
                     s"mdlId=$mdlId" +
                 s"]")
@@ -113,7 +113,7 @@ case class NCConversation(
                     if (delHs.nonEmpty) {
                         item.holders --= delHs
 
-                        logger.info(
+                        logger.trace(
                             s"STM tokens removed [" +
                                 s"usrId=$usrId, " +
                                 s"mdlId=$mdlId, " +
@@ -152,7 +152,7 @@ case class NCConversation(
                 ctx = ctx.asScala.filter(tok => !p.test(tok)).asJava
             }
 
-            logger.info(s"STM is cleared [" +
+            logger.trace(s"STM is cleared [" +
                 s"usrId=$usrId, " +
                 s"mdlId=$mdlId" +
             s"]")
@@ -174,7 +174,7 @@ case class NCConversation(
      */
     private def stepLogTokens(toks: Seq[NCToken]): Unit =
         for (tok <- toks)
-            logger.info(s"  ${c("+--")} $tok")
+            logger.trace(s"  ${c("+--")} $tok")
 
     /**
       * Adds given tokens to the conversation.
@@ -208,7 +208,7 @@ case class NCConversation(
                         lastUpdateTstamp
                     )
     
-                    logger.info(
+                    logger.trace(
                         s"Added new tokens to STM [" +
                             s"usrId=$usrId, " +
                             s"mdlId=$mdlId, " +
@@ -236,7 +236,7 @@ case class NCConversation(
                                 item.holders --= hs
     
                                 for (tok <- hs.map(_.token))
-                                    logger.info(s"STM token overridden: $tok")
+                                    logger.trace(s"STM token overridden: $tok")
 
                             case None => registered += grps
                         }
@@ -257,7 +257,7 @@ case class NCConversation(
         require(Thread.holdsLock(stm))
 
         if (ctx.isEmpty)
-            logger.info(s"STM is empty for [" +
+            logger.trace(s"STM is empty for [" +
                 s"mdlId=$mdlId, " +
                 s"usrId=$usrId" +
             s"]")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
index 88bb84c..8c5f2c1 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/dialogflow/NCDialogFlowManager.scala
@@ -137,7 +137,7 @@ object NCDialogFlowManager extends NCService {
                 flow.notifyAll()
             }
 
-            logger.info(s"Added matched intent to dialog flow [" +
+            logger.trace(s"Added matched intent to dialog flow [" +
                 s"mdlId=$mdlId, " +
                 s"intentId=$intentId, " +
                 s"userId=$usrId" +
@@ -214,7 +214,7 @@ object NCDialogFlowManager extends NCService {
                 flow.notifyAll()
             }
 
-            logger.info(s"Dialog flow history is cleared [" +
+            logger.trace(s"Dialog flow history is cleared [" +
                 s"usrId=$usrId, " +
                 s"mdlId=$mdlId" +
             s"]")
@@ -238,7 +238,7 @@ object NCDialogFlowManager extends NCService {
                 flow.notifyAll()
             }
 
-            logger.info(s"Dialog flow history is cleared [" +
+            logger.trace(s"Dialog flow history is cleared [" +
                 s"usrId=$usrId, " +
                 s"mdlId=$mdlId" +
             s"]")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
index 196ed9c..4b6c697 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/nlp/NCProbeEnrichmentManager.scala
@@ -349,24 +349,24 @@ object NCProbeEnrichmentManager extends NCService with NCOpenCensusModelStats
{
             if (errMsg.isEmpty)
                 logger.info(s"" +
                     s"\n" +
-                    s"${g(">")}\n" +
-                    s"${g(">")} ${bo(g("SUCCESS"))} result sent back to server [" +
+                    s"${g("|>")}\n" +
+                    s"${g("|>")} ${bo(g("SUCCESS"))} result sent back to server [" +
                         s"srvReqId=${m(srvReqId)}, " +
                         s"type=${resType.getOrElse("")}, " +
                         s"dur=${durMs}ms" +
                     s"]\n" +
-                    s"${g(">")}"
+                    s"${g("|>")}"
                 )
             else
                 logger.info(s"" +
                     s"\n" +
-                    s"${r("X")}\n" +
-                    s"${r("X")} ${bo(r("REJECT"))} result sent back to server [" +
+                    s"${r("|X")}\n" +
+                    s"${r("|X")} ${bo(r("REJECT"))} result sent back to server [" +
                         s"srvReqId=${m(srvReqId)}, " +
                         s"response=${errMsg.get}, " +
                         s"dur=${durMs}ms" +
                     s"]\n" +
-                    s"${r("X")}"
+                    s"${r("|X")}"
                 )
         }
 
diff --git a/nlpcraft/src/test/resources/log4j2.xml b/nlpcraft/src/test/resources/log4j2.xml
index e5ad404..d9a627b 100644
--- a/nlpcraft/src/test/resources/log4j2.xml
+++ b/nlpcraft/src/test/resources/log4j2.xml
@@ -19,7 +19,7 @@
 
 <Configuration status="INFO">
     <Properties>
-        <Property name="pattern">%highlight{%d{MMM-dd|HH:mm:ss}|%level{WARN=WRN, DEBUG=DBG,
ERROR=ERR, TRACE=TRC, INFO=INF}| %C{1} - (%F:%L) - %m%n}</Property>
+        <Property name="pattern">%highlight{%d{MMM-dd|HH:mm:ss}|%level{WARN=WRN, DEBUG=DBG,
ERROR=ERR, TRACE=TRC, INFO=INF}| %m%n}</Property>
     </Properties>
     <Appenders>
         <Console name="stdout" target="SYSTEM_OUT">
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
index d078bb2..e41f938 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/options/NCStmOnlySpec.scala
@@ -58,8 +58,8 @@ class NCStmOnlyModel extends NCAbstractTokensModel {
         "        'unused_usr_toks': false, " +
         "        'allow_stm_only': true" +
         "    }" +
-        "    term(a)={tok_id() == 'a'}" +
-        "    term(b)={tok_id() == 'b'}"
+        "    term(a)~{tok_id() == 'a'}" +
+        "    term(b)~{tok_id() == 'b'}"
     )
     def i1(): NCResult = NCResult.text("i1")
 
@@ -95,8 +95,9 @@ class NCStmOnlySpec extends NCMetaSpecAdapter {
         checkResult("b a d c", "before")
         checkResult("a b", "i1")
 
-//        clear()
-
+        // This should match as 'i1' intent allows:
+        //   - unmatched free words, and
+        //   - all of its matched tokens to come from STM
         checkResult("x y", "i1")
     }
 

Mime
View raw message