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 2022/09/06 18:33:40 UTC

[incubator-nlpcraft] branch master updated: scaladoc.

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


The following commit(s) were added to refs/heads/master by this push:
     new 621c6371 scaladoc.
621c6371 is described below

commit 621c6371b159bc91dc9b770154cfe6deb22adf7e
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Tue Sep 6 11:33:33 2022 -0700

    scaladoc.
---
 .../main/scala/org/apache/nlpcraft/NCIntentMatch.scala | 18 +++++++-----------
 .../{NCFiredIntent.scala => NCMatchedCallback.scala}   |  4 ++--
 .../main/scala/org/apache/nlpcraft/NCModelClient.scala |  4 ++--
 .../intent/matcher/NCIntentSolverManager.scala         |  4 ++--
 .../nlpcraft/internal/impl/NCModelClientSpec3.scala    |  8 ++++----
 5 files changed, 17 insertions(+), 21 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCIntentMatch.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCIntentMatch.scala
index c04b81e0..8aeb3c36 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCIntentMatch.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCIntentMatch.scala
@@ -34,43 +34,39 @@ trait NCIntentMatch:
       * to the order and index of terms in the matching intent. Number of sub-lists will always be the same
       * as the number of terms in the matched intent.
       *
-      * Consider using [[NCIntentTerm]] annotation instead for simpler access to the intent entities.
+      * Consider using `NCIntentTerm` annotation instead for simpler access to the intent entities.
       *
       * @return List of lists of entities representing matched intent.
       * @see [[getVariant()]]
-      * @see [[NCIntentTerm]]
       */
     def getIntentEntities: List[List[NCEntity]]
 
     /**
       * Gets entities for given term. This is a companion method for [[getIntentEntities()]] method.
       *
-      * Consider using [[NCIntentTerm]] annotation instead for simpler access to the intent entities.
+      * Consider using `NCIntentTerm` annotation instead for simpler access to the intent entities.
       *
       * @param idx Index of the term (starting from `0`).
       * @return List of entities, potentially `null`, for given term.
-      * @see [[NCIntentTerm]]
-      * @see [[getTermEntities()]]
       */
     def getTermEntities(idx: Int): List[NCEntity]
 
     /**
       * Gets entities for given term. This is a companion method for [[getIntentEntities()]].
       *
-      * Consider using [[NCIntentTerm]] annotation instead for simpler access to the intent entities.
+      * Consider using `NCIntentTerm` annotation instead for simpler access to the intent entities.
       *
       * @param termId ID of the term for which to get entities.
       * @return List of entities, potentially `null`, for given term.
-      * @see [[NCIntentTerm
-      * @see #getTermEntities(int) */
+      */
     def getTermEntities(termId: String): List[NCEntity]
 
     /**
       * Gets parsing variant that produced the matching for this intent. Returned variant is one of the
-      * variants provided by {@link NCContext# getVariants ( )} methods. Note that entities returned by this method are
-      * a superset of the entities returned by {@link # getIntentEntities ( )}  method, i.e. not all entities
+      * variants provided by [[NCContext.getVariants()]] methods. Note that entities returned by this method are
+      * a superset of the entities returned by [[getIntentEntities()]] method, i.e. not all entities
       * from this variant may have been used in matching of the winning intent.
       *
       * @return Parsing variant that produced the matching for this intent.
-      * @see #getIntentEntities() */
+      */
     def getVariant: NCVariant
\ No newline at end of file
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCFiredIntent.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCMatchedCallback.scala
similarity index 94%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/NCFiredIntent.scala
rename to nlpcraft/src/main/scala/org/apache/nlpcraft/NCMatchedCallback.scala
index 6c7093c0..0115a09b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCFiredIntent.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCMatchedCallback.scala
@@ -20,13 +20,13 @@ package org.apache.nlpcraft
 /**
   * A descriptor of the intent callback returned by [[NCModelClient.debugAsk()]] method. This descriptor
   * defines the callback for the intent that was detected as a winning intent but whose callback wasn't
-  * fired as per [[NCModelClient.debugAsk()]] method.
+  * fired as per [[NCModelClient.debugAsk()]] method's semantic.
   *
   * Using this descriptor the user can execute callback itself, if necessary.
   *
   * @see [[NCModelClient.debugAsk()]]
   */
-trait NCFiredIntent:
+trait NCMatchedCallback:
     /**
       * Gets ID of the matched intent.
       */
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala
index 24aa4c65..a339fb1c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala
@@ -78,7 +78,7 @@ class NCModelClient(mdl: NCModel) extends LazyLogging, AutoCloseable:
       * @param typ
       * @return
       */
-    private def ask0(txt: String, data: Map[String, Any], usrId: String, typ: NCIntentSolveType): Either[NCResult, NCFiredIntent] =
+    private def ask0(txt: String, data: Map[String, Any], usrId: String, typ: NCIntentSolveType): Either[NCResult, NCMatchedCallback] =
         val plData = plMgr.prepare(txt, data, usrId)
 
         val userId = plData.request.getUserId
@@ -170,7 +170,7 @@ class NCModelClient(mdl: NCModel) extends LazyLogging, AutoCloseable:
       * @param saveHist
       * @return
       */
-    def debugAsk(txt: String, usrId: String, saveHist: Boolean, data: Map[String, AnyRef] = Map.empty): NCFiredIntent =
+    def debugAsk(txt: String, usrId: String, saveHist: Boolean, data: Map[String, AnyRef] = Map.empty): NCMatchedCallback =
         require(txt != null, "Input text cannot be null.")
         require(data != null, "Data cannot be null.")
         require(usrId != null, "User id cannot be null.")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverManager.scala
index 0d5f5617..bc7877ef 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverManager.scala
@@ -89,7 +89,7 @@ object NCIntentSolverManager:
         getIntentId: String,
         getCallbackArguments: List[List[NCEntity]],
         getCallback: List[List[NCEntity]] => NCResult
-    ) extends NCFiredIntent
+    ) extends NCMatchedCallback
 
     /**
       *
@@ -183,7 +183,7 @@ object NCIntentSolverManager:
       */
     private case class IntentEntity(var used: Boolean, var conv: Boolean, entity: NCEntity)
 
-    type ResultData = Either[NCResult, NCFiredIntent]
+    type ResultData = Either[NCResult, NCMatchedCallback]
 
     /**
       *
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
index b1a98634..c108693c 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
@@ -41,10 +41,10 @@ class NCModelClientSpec3 extends AnyFunSuite:
             def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("t1") t1: NCEntity): NCResult = TEST_RESULT
 
         Using.resource(new NCModelClient(mdl)) { client =>
-            def ask(): NCFiredIntent = client.debugAsk("e1", "userId", true)
-            def execCallback(cb: NCFiredIntent): NCResult = cb.getCallback.apply(cb.getCallbackArguments)
-            def execCallbackOk(cb: NCFiredIntent): Unit = println(s"Result: ${execCallback(cb).getBody}")
-            def execCallbackFail(cb: NCFiredIntent): Unit =
+            def ask(): NCMatchedCallback = client.debugAsk("e1", "userId", true)
+            def execCallback(cb: NCMatchedCallback): NCResult = cb.getCallback.apply(cb.getCallbackArguments)
+            def execCallbackOk(cb: NCMatchedCallback): Unit = println(s"Result: ${execCallback(cb).getBody}")
+            def execCallbackFail(cb: NCMatchedCallback): Unit =
                 try execCallback(cb)
                 catch case e: NCException => println(s"Expected error: ${e.getMessage}")