|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opencyc.conversation.Interpreter
Contains the attributes and behavior of a chat fsm interpreter.
The chat conversation is in the form of a text conversation using asynchronous receiving and sending of messages. This interpreter models the chat interaction with nested fsms in a stack. Mixed initiative is supported by a dictionary of fsm stacks, one of which is active, and the rest suspended. Sub fsms are passed a list of attribute/value pairs which form the initial state attributes. When done, sub fsms pass back result attribute/value pairs to the calling fsm's state attributes.
Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.
THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Field Summary | |
protected ChatterBot |
chatterBot
reference to the parent ChatterBot |
protected ChatUserModel |
chatUserModel
Reference to the user model, which contains user state and history information, persisted in the Cyc KB. |
protected State |
currentState
finite state machine current node |
protected Fsm |
fsm
reference to the active fsm |
protected StackWithPointer |
fsmStack
Reference to the current fsm stack, which is a stack of FsmInfo elements. |
protected java.util.HashMap |
fsmStacks
dictionary of fsm stacks fsmStackId --> fsm stack |
protected Performative |
nextPerformative
Next computed Performative, or null if none. |
protected Performer |
performer
Performs fsm actions. |
protected java.util.HashMap |
stateAttributes
Dictionary of state attribute and object values. |
protected TemplateFactory |
templateFactory
Makes Template objects for the TemplateParser. |
protected TemplateParser |
templateParser
Parses the users input text. |
Constructor Summary | |
protected |
Interpreter()
Constructs a new Interpreter without arguments. |
|
Interpreter(ChatterBot chatterBot,
java.lang.String chatUserNickname,
java.lang.String chatUserUniqueId,
java.lang.String fsmStackId,
Fsm fsm)
Constructs a new Interpreter object given the parent ChatterBot. |
Method Summary | |
java.lang.Object |
getStateAttribute(java.lang.Object attribute)
Returns the value for the given state attribute. |
void |
initialize(java.lang.String fsmStackId,
Fsm fsm)
Initializes the fsm interpreter. |
protected Arc |
lookupArc(Performative performative)
Returns the arc which corresponds to the performative received in the current state. |
void |
popFsmStateInfo()
Pops the fsm state stack and restores the previous fsm state. |
void |
pushFsmStateInfo(FsmStateInfo fsmStateInfo)
Pushes the given fsm state onto the current fsm stack. |
void |
receiveChatMessage(java.lang.String chatMessage)
Receives the given chat message from the given chat partner, obtains the performative, transitions to the corresponding state and performs the required action. |
void |
sendChatMessage(java.lang.String chatMessage)
Sends the given chat message into the chat system. |
void |
setNextPerformative(Performative nextPerformative)
Sets the value of the computed next performative. |
void |
setStateAttribute(java.lang.String attribute,
java.lang.Object value)
Sets the value for the given state attribute. |
void |
setupSubFsm(Fsm fsm,
java.util.ArrayList arguments)
Sets up the given sub fsm and the input arguments as a list of attribute/value pairs. |
protected void |
transitionState(Arc arc)
Transitions to the to-state given in the arc, and performs the action. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected ChatterBot chatterBot
protected ChatUserModel chatUserModel
protected java.util.HashMap fsmStacks
protected StackWithPointer fsmStack
protected Fsm fsm
protected State currentState
protected java.util.HashMap stateAttributes
protected Performative nextPerformative
protected TemplateFactory templateFactory
protected TemplateParser templateParser
protected Performer performer
Constructor Detail |
protected Interpreter()
public Interpreter(ChatterBot chatterBot, java.lang.String chatUserNickname, java.lang.String chatUserUniqueId, java.lang.String fsmStackId, Fsm fsm)
chatterBot
- the parent ChatterBotchatUserNickname
- the preferred name (possibly not unique) of the
chat partnerchatUserUniqueId
- the unique id assigned to the user by the chat
systemMethod Detail |
public void receiveChatMessage(java.lang.String chatMessage) throws CycApiException, java.io.IOException, java.net.UnknownHostException, ChatException
chatPartner
- the name of the chat partnerchatMessage
- the chat messageprotected Arc lookupArc(Performative performative)
performative
- the performativeprotected void transitionState(Arc arc)
arc
- the finite state machine arcpublic void initialize(java.lang.String fsmStackId, Fsm fsm)
fsmStackId
- provides an id for the first
fsm stackfsm
- the initial fsm, which is also the
sole object on the fsm stackpublic void sendChatMessage(java.lang.String chatMessage) throws ChatException
chatMessage
- the chat messagepublic void setStateAttribute(java.lang.String attribute, java.lang.Object value)
attribute
- the key objectvalue
- the value objectpublic void setNextPerformative(Performative nextPerformative)
nextAction
- the computed next performativepublic java.lang.Object getStateAttribute(java.lang.Object attribute)
attribute
- the key objectpublic void setupSubFsm(Fsm fsm, java.util.ArrayList arguments)
fsm
- the new fsmarguments
- a list of Object arrays of length two, the first array element is the
attribute and the second array element is its valuepublic void pushFsmStateInfo(FsmStateInfo fsmStateInfo)
fsmStateInfo
- the new fsm and its statepublic void popFsmStateInfo()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |