Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.opencyc.chat
Class ChatterBot

    java.lang.Object
      |
      +--org.opencyc.chat.ChatterBot

public class ChatterBot
extends java.lang.Object

Provides a chat conversation interface to Cyc.

The chat conversation is in the form of a text conversation using asynchronous receiving and sending of messages. This class intializes the Cyc server connection, and initializes the chat interpreter, for each chat partner, then delegates the conversation understanding and responses to the chat partner's chat interpreter.

Author:
  Stephen L. Reed

  Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.

  the license

  www.opencyc.org

  OpenCyc at SourceForge

  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 java.util.HashMap` | `chatInterpreters` Dictionary of chat interpreters, chatUserUniqueId --> ChatInterpreter
`protected ChatSender` | `chatSender` Sends messages to the chat system.
`protected java.util.HashMap` | `chatUserModels` Dictionary of chat user models, chatUserUniqueId --> ChatUserModel
`protected CycAccess` | `cycAccess` Provides wrappers for the Cyc API and manages the connection to the Cyc server.

Constructor Summary
`ChatterBot(ChatSender chatSender)` Creates a new ChatterBot object, given a ChatSender.

Method Summary
`void` | `finalize()` Closes this ChatterBot, in particular the connection to the Cyc server.
`ChatUserModel` | `getChatUserModel(java.lang.String chatUserUniqueId)` Returns the chat user model for the given chat partner.
`void` | `initialize()` Initializes this ChatterBot, in particular the connection to the Cyc server.
`protected ChatInterpreter` | `makeCharInterpreter(java.lang.String chatUserNickname, java.lang.String chatUserUniqueId)` Makes a new chat interpreter object for a new chat partner, and stores it in the dictionary for later lookup.
`void` | `receiveChatMessage(java.lang.String chatUserNickname, java.lang.String chatUserUniqueId, java.lang.String chatMessage)` Receives the given chat message from the given chat partner.
`void` | `sendChatMessage(java.lang.String chatMessage)` Sends the given chat message into the chat system.

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### chatSender

    protected ChatSender chatSender

  Sends messages to the chat system.

### chatUserModels

    protected java.util.HashMap chatUserModels

  Dictionary of chat user models, chatUserUniqueId --> ChatUserModel

### chatInterpreters

    protected java.util.HashMap chatInterpreters

  Dictionary of chat interpreters, chatUserUniqueId --> ChatInterpreter

### cycAccess

    protected CycAccess cycAccess

  Provides wrappers for the Cyc API and manages the connection to the Cyc server.

Constructor Detail

### ChatterBot

    public ChatterBot(ChatSender chatSender)

  Creates a new ChatterBot object, given a ChatSender.
  Parameters:
    `chatSender` - the object which connects the ChatterBot to the chat system.

Method Detail

### initialize

    public void initialize()
                    throws CycApiException,
                           java.net.UnknownHostException,
                           java.io.IOException,
                           ChatException

  Initializes this ChatterBot, in particular the connection to the Cyc server.

### makeCharInterpreter

    protected ChatInterpreter makeCharInterpreter(java.lang.String chatUserNickname,
                                                  java.lang.String chatUserUniqueId)

  Makes a new chat interpreter object for a new chat partner, and stores it in the dictionary for later lookup.
  Parameters:
    `chatUserNickname` - the preferred name (possibly not unique) of the chat partner
    `chatUserUniqueId` - the unique id assigned to the user by the chat system
  Returns:
    the new chat interpreter

### finalize

    public void finalize()

  Closes this ChatterBot, in particular the connection to the Cyc server.
  Overrides:
    `finalize` in class `java.lang.Object`

### receiveChatMessage

    public void receiveChatMessage(java.lang.String chatUserNickname,
                                   java.lang.String chatUserUniqueId,
                                   java.lang.String chatMessage)
                            throws CycApiException,
                                   java.io.IOException,
                                   java.net.UnknownHostException,
                                   ChatException

  Receives the given chat message from the given chat partner. Delegates the message understanding and response to the chat interpreter.
  Parameters:
    `chatUserNickname` - the preferred name (possibly not unique) of the chat partner
    `chatUserUniqueId` - the unique id assigned to the user by the chat system
    `chatMessage` - the chat message

### sendChatMessage

    public void sendChatMessage(java.lang.String chatMessage)
                         throws ChatException

  Sends the given chat message into the chat system.
  Parameters:
    `chatMessage` - the chat message

### getChatUserModel

    public ChatUserModel getChatUserModel(java.lang.String chatUserUniqueId)

  Returns the chat user model for the given chat partner. If not cached, retrieves the stored user model from the KB, or creates a new one if the chat partner is new.
  Parameters:
    `chatUserUniqueId` - the unique id assigned to the user by the chat system
  Returns:
    the chat user model

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD