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 65d5202  WIP.
65d5202 is described below

commit 65d5202430fc49e26384e5c7df2d178cbd6a2c7c
Author: Nikita Ivanov <>
AuthorDate: Sun Dec 5 11:19:42 2021 -0800

    WIP.
---
 .../scala/org/apache/nlpcraft/NCConversation.java  | 48 ++++++++++++++++++++++
 .../{NCConversation.java => NCDialogFlowItem.java} |  2 +-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java
index dd93935..aefce08 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java
@@ -17,8 +17,56 @@
 
 package org.apache.nlpcraft;
 
+import java.util.List;
+import java.util.function.Predicate;
+
 /**
  *
  */
 public interface NCConversation {
+    /**
+     * Gets an ordered list of tokens stored in the conversation's STM 
(short-term memory) for the current
+     * user. Tokens in the returned list are ordered by their conversational 
depth, i.e.
+     * the tokens from more recent requests appear before tokens from older 
requests.
+     * <p>
+     * Note also that rules by which STM operates are undefined for the 
purpose of this function (i.e. callers
+     * should not rely on any observed behavior of how STM stores and evicts 
its content).
+     *
+     * @return List of tokens for this conversation's STM. The list can be 
empty which indicates that
+     *      conversation is brand new (or timed out).
+     */
+    List<NCToken> getTokens();
+
+    /**
+     * Gets the chronologically ordered list of previously matched intents 
sorted from oldest to newest
+     * for the current user.
+     *
+     * @return List of chronologically ordered previously matched dialog flow 
items.
+     */
+    List<NCDialogFlowItem> getDialogFlow();
+
+    /**
+     * Removes all tokens satisfying given token predicate from the 
conversation's STM.
+     * <p>
+     * This is particularly useful when the logic processing the user input 
makes an implicit
+     * assumption not present in the user input itself. Such assumption may 
alter the conversation (without
+     * having an explicit token responsible for it) and therefore this method 
can be used to remove "stale" tokens
+     * from conversation's STM.
+     *
+     * @param filter Token remove filter.
+     */
+    void clearStm(Predicate<NCToken> filter);
+
+    /**
+     * Removes all previously matched intents using given dialog flow item 
predicate.
+     * <p>
+     * History of matched intents (i.e. the dialog flow) can be used in intent 
definition as part of its
+     * matching template. NLPCraft maintains the window of previously matched 
intents based on time, i.e.
+     * after certain period of time the oldest previously matched intents are 
forgotten and removed from
+     * dialog flow. This method allows explicitly clear previously matched 
intents from the
+     * dialog flow based on user logic other than time window.
+     *
+     * @param filter Dialog flow filter.
+     */
+    void clearDialog(Predicate<NCDialogFlowItem> filter);
 }
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCDialogFlowItem.java
similarity index 95%
copy from nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java
copy to nlpcraft/src/main/scala/org/apache/nlpcraft/NCDialogFlowItem.java
index dd93935..5abe931 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCConversation.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCDialogFlowItem.java
@@ -20,5 +20,5 @@ package org.apache.nlpcraft;
 /**
  *
  */
-public interface NCConversation {
+public interface NCDialogFlowItem {
 }

Reply via email to