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 7292d0cc Scaladoc.
7292d0cc is described below
commit 7292d0cc8dd43a5c3da2ce7967fd716f6a3a030e
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sun Nov 20 12:06:35 2022 -0800
Scaladoc.
---
.../scala/org/apache/nlpcraft/NCModelConfig.scala | 60 +++++++++++++++++++++-
.../scala/org/apache/nlpcraft/NCPropertyMap.scala | 45 ++++++++--------
2 files changed, 82 insertions(+), 23 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
index 94de8f20..e6eecb50 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.scala
@@ -20,18 +20,34 @@ package org.apache.nlpcraft
import java.time.Duration
/**
- *
+ * Model configuration factory.
*/
object NCModelConfig:
val DFLT_CONV_TIMEOUT: Long = Duration.ofMinutes(60).toMillis
val DFLT_CONV_DEPTH = 3
+ /**
+ * Creates model configuration with given parameters.
+ *
+ * @param id Unique, immutable, global model ID.
+ * @param name Human readable model name.
+ * @param ver Model version.
+ */
def apply(id: String, name: String, ver: String): NCModelConfig =
new NCPropertyMapAdapter with NCModelConfig:
override val getId: String = id
override val getName: String = name
override val getVersion: String = ver
+ /**
+ * Creates model configuration with given parameters.
+ *
+ * @param id Unique, immutable, global model ID.
+ * @param name Human readable model name.
+ * @param ver Model version.
+ * @param desc Model description.
+ * @param orig Model origin.
+ */
def apply(id: String, name: String, ver: String, desc: String, orig:
String): NCModelConfig =
new NCPropertyMapAdapter with NCModelConfig:
override val getId: String = id
@@ -40,6 +56,17 @@ object NCModelConfig:
override val getDescription: Option[String] = desc.?
override val getOrigin: Option[String] = orig.?
+ /**
+ * Creates model configuration with given parameters.
+ *
+ * @param id Unique, immutable, global model ID.
+ * @param name Human readable model name.
+ * @param ver Model version.
+ * @param desc Model description.
+ * @param orig Model origin.
+ * @param convTimeout Conversation timeout in millis.
+ * @param convDepth Maximum conversation depth.
+ */
def apply(id: String, name: String, ver: String, desc: String, orig:
String, convTimeout: Long, convDepth: Int): NCModelConfig =
new NCPropertyMapAdapter with NCModelConfig:
override val getId: String = id
@@ -53,13 +80,42 @@ object NCModelConfig:
import org.apache.nlpcraft.NCModelConfig.*
/**
- *
+ * Model configuration container.
*/
trait NCModelConfig extends NCPropertyMap:
+ /**
+ * Gets unique, immutable, global model ID.
+ */
def getId: String
+
+ /**
+ * Gets readable model name. Note that unlike model ID the model name can
be changed.
+ */
def getName: String
+
+ /**
+ * Gets model version.
+ */
def getVersion: String
+
+ /**
+ * Gets optional model description. Default value is `None`.
+ */
def getDescription: Option[String] = None
+
+ /**
+ * Gets optional model origin. Default value is `None`.
+ */
def getOrigin: Option[String] = None
+
+ /**
+ * Gets timeout in millis after which the current conversation for a
given user will
+ * be "forgotten" and its context removed from the STM.
+ */
def getConversationTimeout: Long = DFLT_CONV_TIMEOUT
+
+ /**
+ * Gets maximum depth of the conversation (i.e. number of subsequent
individual user requests) after
+ * which the older requests will be "forgotten" and removed from the
conversation context.
+ */
def getConversationDepth: Int = DFLT_CONV_DEPTH
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPropertyMap.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPropertyMap.scala
index d964adf1..e639e534 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPropertyMap.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPropertyMap.scala
@@ -20,27 +20,26 @@ package org.apache.nlpcraft
/**
* Map-like container that provides support for mutable runtime-only
properties or metadata.
*
- * @see [[NCPropertyMapAdapter
- * @see [[NCToken
- * @see [[NCEntity */
+ * @see [[NCPropertyMapAdapter]]
+ * @see [[NCToken]]
+ * @see [[NCEntity]]
+ * @see [[NCModelConfig]]
+ */
trait NCPropertyMap:
/**
* Returns the value to which the specified key is mapped, or `null` if
this map contains no mapping for the key.
*
* @param key The key whose associated value is to be returned.
- * @param <T> Type of the returned value.
- * @return The value to which the specified key is mapped, or `null` if
this map contains no mapping for the key. */
+ * @return The value to which the specified key is mapped, or `null` if
this map contains no mapping for the key.
+ */
def apply[T](key: String): T
/**
- * Returns the value to which the specified key is mapped as an optional.
This method is equivalent to:
- * <pre class="brush: java">
- * return Optional.ofNullable((T)map.get(key));
- * </pre>
+ * Returns the value to which the specified key is mapped.
*
* @param key The key whose associated value is to be returned.
- * @param <T> Type of the returned value.
- * @return The value to which the specified key is mapped as an optional.
*/
+ * @return The value to which the specified key is mapped as an optional.
+ */
def get[T](key: String): Option[T]
/**
@@ -49,8 +48,8 @@ trait NCPropertyMap:
*
* @param key Key with which the specified value is to be associated.
* @param obj Value to be associated with the specified key.
- * @param <T> Type of the value.
- * @return The previous value associated with key, or `null` if there was
no mapping for key. */
+ * @return The previous value associated with key, or `null` if there was
no mapping for key.
+ */
def put[T](key: String, obj: Any): T
/**
@@ -59,22 +58,23 @@ trait NCPropertyMap:
*
* @param key Key with which the specified value is to be associate
* @param obj Value to be associated with the specified key
- * @param <T> Type of the value.
- * @return The previous value associated with the specified key, or
`null` if there was no mapping for the key. */
+ * @return The previous value associated with the specified key, or
`null` if there was no mapping for the key.
+ */
def putIfAbsent[T](key: String, obj: T): T
/**
* Returns `true` if this map contains a mapping for the specified key.
*
- * @return `true` if this map contains a mapping for the specified key. */
+ * @return `true` if this map contains a mapping for the specified key.
+ */
def contains(key: String): Boolean
/**
* Removes the mapping for a key from this map if it is present.
*
* @param key Key whose mapping is to be removed from the map.
- * @param <T> Type of the value.
- * @return The previous value associated with key, or `null` if there was
no mapping for key. */
+ * @return The previous value associated with key, or `null` if there was
no mapping for key.
+ */
def remove[T](key: String): T
/**
@@ -82,15 +82,18 @@ trait NCPropertyMap:
*
* @param key Key with which the specified value is associated value.
* @param obj Value expected to be associated with the specified key.
- * @return `true` if the value was removed */
+ * @return `true` if the value was removed.
+ */
def remove(key: String, obj: Any): Boolean
/**
* Returns a set view of the keys contained in this map.
*
- * @return A set view of the keys contained in this map */
+ * @return A set view of the keys contained in this map.
+ */
def keysSet: Set[String]
/**
- * Removes all of the mappings from this map. The map will be empty after
this call returns. */
+ * Removes all of the mappings from this map. The map will be empty after
this call returns.
+ */
def clear(): Unit