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/08/03 17:44:03 UTC

[incubator-nlpcraft] branch NLPCRAFT-491 updated: WIP.

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

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


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

commit 113d80d622f6ce50273e66009c0bf3fa48e4cc55
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Wed Aug 3 10:43:56 2022 -0700

    WIP.
---
 .../main/scala/org/apache/nlpcraft/NCEntity.scala  |  2 +-
 .../scala/org/apache/nlpcraft/NCModelConfig.scala  |  1 +
 .../org/apache/nlpcraft/NCPipelineBuilder.scala    |  4 +--
 .../main/scala/org/apache/nlpcraft/NCRequest.scala | 31 ++++++++++++++--------
 .../main/scala/org/apache/nlpcraft/NCResult.scala  |  2 +-
 .../scala/org/apache/nlpcraft/NCResultType.scala   |  6 ++++-
 6 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala
index 32072a43..f3b27426 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala
@@ -18,7 +18,7 @@
 package org.apache.nlpcraft
 
 /**
-  * An enenity is a collection if one or more {@link NCToken tokens}. An entity typically has a
+  * An entity is a collection if one or more {@link NCToken tokens}. An entity typically has a
   * consistent semantic meaning and usually denotes a real-world object, such as persons, locations, number,
   * date and time, organizations, products, etc. - where such objects can be abstract or have a physical existence.
   * Entities are produced by {@link NCEntityParser}. See {@link NCPipeline} for documentation on the entities in the
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
index 08793d8e..e3ff4186 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
@@ -30,6 +30,7 @@ object NCModelConfig:
     def apply(id: String, name: String, ver: String) = new NCModelConfig(id, name, ver)
     def apply(id: String, name: String, ver: String, desc: String, orig: String) =
         new NCModelConfig(id, name, ver, Option(desc), Option(orig))
+        
 import org.apache.nlpcraft.NCModelConfig.*
 
 /**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala
index b710fd8d..a787e353 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala
@@ -147,7 +147,7 @@ class NCPipelineBuilder:
       * @return */
     def withTokenParser(tokParser: NCTokenParser): NCPipelineBuilder =
         require(tokParser != null, "Token parser cannot be null.")
-        this.tokParser = Some(tokParser)
+        this.tokParser = Option(tokParser)
         this
 
     /**
@@ -171,7 +171,7 @@ class NCPipelineBuilder:
     /**
       * */
     private def setEnComponents(): Unit =
-        tokParser = Some(mkEnOpenNLPTokenParser)
+        tokParser = Option(mkEnOpenNLPTokenParser)
         tokEnrichers += new NCOpenNLPLemmaPosTokenEnricher(NCResourceReader.getPath("opennlp/en-pos-maxent.bin"), NCResourceReader.getPath("opennlp/en-lemmatizer.dict"))
         tokEnrichers += new NCEnStopWordsTokenEnricher
         tokEnrichers += new NCEnSwearWordsTokenEnricher(NCResourceReader.getPath("badfilter/swear_words.txt"))
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCRequest.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCRequest.scala
index 55272631..952e6974 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCRequest.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCRequest.scala
@@ -18,42 +18,51 @@
 package org.apache.nlpcraft
 
 /**
-  * Descriptor for the input user request.
+  * Descriptor for the input user request. User request descriptor can be obtained via
+  * [[NCContext.getRequest]] method.
   *
-  * @see NCContext#getRequest() */
+  * @see [[NCContext.getRequest]]
+  */
 trait NCRequest:
     /**
       * Gets ID of the user on behalf of which this request was submitted. User ID is used by
-      * NLPCraft to manage the conversation state. It can be any value as long as it is constant
+      * NLPCraft to manage the conversation state. It can be any value as long as it is stable
       * and globally unique for the given user.
       *
-      * @return User ID. */
+      * @return User ID.
+      */
     def getUserId: String
 
     /**
       * Gets globally unique ID of the current request.
-      * <p>
+      *
       * A request is defined as a processing of a one user input request.
       * Note that the model can be accessed multiple times during processing of a single user request
       * and therefore multiple instances of this interface can return the same request ID. In fact, users
       * of this interfaces can use this fact by using this ID, for example, as a map key for a session
       * scoped storage.
       *
-      * @return Request ID. */
+      * @return Request ID.
+      */
     def getRequestId: String
 
     /**
-      * @return */
+      * Gets the original input text of this request.
+      *
+      * @return Input text of this request.
+      */
     def getText: String
 
     /**
-      * Gets UTC/GMT timestamp in millis when user input was received.
+      * Gets UTC/GMT timestamp in milliseconds when user input was received.
       *
-      * @return UTC/GMT timestamp in ms when user input was received. */
+      * @return UTC/GMT timestamp in milliseconds when user input was received.
+      */
     def getReceiveTimestamp: Long
 
     /**
-      * Gets optional user request data.
+      * Gets optional data associated with this user request.
       *
-      * @return Optional user request data, can be empty but never `null`. */
+      * @return Optional user request data, can be empty but never `null`.
+      */
     def getRequestData: Map[String, Any]
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala
index 90618e70..63c5cd60 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala
@@ -23,7 +23,7 @@ import org.apache.nlpcraft.NCResultType.*
   *
   */
 object NCResult:
-    def apply(body: Any, resultType: NCResultType, intentId: String): NCResult = new NCResult(body = body, resultType = resultType, Some(intentId))
+    def apply(body: Any, resultType: NCResultType, intentId: String): NCResult = new NCResult(body = body, resultType = resultType, Option(intentId))
     def apply(body: Any, resultType: NCResultType): NCResult = apply(body, resultType, intentId = None)
 
 /**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.scala
index f1b7b486..903b746e 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.scala
@@ -17,7 +17,11 @@
 
 package org.apache.nlpcraft
 
+/**
+  *
+  */
 enum NCResultType:
     /**
-      * Final result is ready and Ask user back engaging in dialog. */
+      * Final result is ready and Ask user back engaging in dialog.
+      */
     case ASK_RESULT, ASK_DIALOG
\ No newline at end of file