All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.signiform.tt.TTConnection

java.lang.Object
   |
   +----com.signiform.tt.TTConnection

public class TTConnection
extends Object
The TTConnection class provides an interface to the ThoughtTreasure natural language/commonsense server. It implements the ThoughtTreasure Server Protocol (TTSP).

Here is a simple program which asks the ThoughtTreasure server whether Evian is a beverage:

 import com.signiform.tt.*;
 public class Example {
 public static void main(String args[])
 {
   try {
     TTConnection tt = new TTConnection("somehost");
     System.out.println(tt.ISA("beverage", "Evian"));
     tt.close();
   } catch (Exception e) {
   }
 }
 }
 

To start the ThoughtTreasure server, start ThoughtTreasure and then issue the command:

 server
 
to listen on port 1832, the ThoughtTreasure Server Protocol (TTSP) registered port number listed by the Internet Assigned Numbers Authority (IANA), or:
 server -port PORT
 
to listen on port number PORT.

The discourse context is normally maintained across calls for a given TTConnection. This allows, for example, pronouns to be understood and generated. To clear the connection's discourse context, use clearContext.


Variable Index

 o DEBUG
Whether debugging information should be printed to System.out; false by default.
 o PORT
The ThoughtTreasure Server Protocol (TTSP) registered port number listed by the Internet Assigned Numbers Authority (IANA); the port number is 1832.
 o USECACHE
Whether to cache results for later reuse without contacting the ThoughtTreasure server; true by default.

Constructor Index

 o TTConnection(InetAddress)
Creates a new connection to the specified ThoughtTreasure server.
 o TTConnection(InetAddress, int)
Creates a new connection to the specified ThoughtTreasure server.
 o TTConnection(String)
Creates a new connection to the specified ThoughtTreasure server.
 o TTConnection(String, int)
Creates a new connection to the specified ThoughtTreasure server.

Method Index

 o ancestors(String)
Returns the ancestors of the specified object.
 o bringdown()
Forces ThoughtTreasure to break out of the server select loop, so that it can process further ThoughtTreasure shell commands.
 o chatterbot(String, String)
Sends natural language input text to the chatterbot and returns the natural language response.
 o children(String)
Returns the children of the specified object.
 o clearCache()
Clears the cache.
 o clearContext()
Clears the discourse context.
 o close()
Closes the connection.
 o conceptToLexEntries(String)
Returns the lexical entries associated with the specified object (atomic concept) in the lexicon.
 o descendants(String)
Returns the descendants of the specified object.
 o generate(String, Object)
Generates the specified ThoughtTreasure assertion in natural language.
 o ISA(String, String)
Tests whether the specified object is of the specified class.
 o isPartOf(String, String)
Tests whether the specified object is a part of another specified object.
 o parents(String)
Returns the parents of the specified object.
 o phraseToConcepts(String, String)
Returns the objects (atomic concepts) for the specified word or phrase (lexical entry) in the lexicon.
 o retrieve(int, int, int, String, String)
Retrieves assertions from the database matching the specified pattern.
 o semanticParse(String, String)
Semantically parses the specified natural language text.
 o status()
Returns the status of the ThoughtTreasure server: "up" or "down".
 o syntacticParse(String, String)
Syntactically parses the specified natural language text.
 o tag(String, String)
Performs part-of-speech (and other) tagging of the specified natural language text.

Variables

 o DEBUG
 public static boolean DEBUG
Whether debugging information should be printed to System.out; false by default.

 o USECACHE
 public static boolean USECACHE
Whether to cache results for later reuse without contacting the ThoughtTreasure server; true by default.

 o PORT
 public static int PORT
The ThoughtTreasure Server Protocol (TTSP) registered port number listed by the Internet Assigned Numbers Authority (IANA); the port number is 1832.

Constructors

 o TTConnection
 public TTConnection(String host) throws IOException
Creates a new connection to the specified ThoughtTreasure server. The IANA-listed registered port number is assumed.

Parameters:
host - the host name of the ThoughtTreasure server
Throws: IOException
if an I/O error occurs when creating the socket
 o TTConnection
 public TTConnection(InetAddress address) throws IOException
Creates a new connection to the specified ThoughtTreasure server. The IANA-listed registered port number is assumed.

Parameters:
address - the IP address of the ThoughtTreasure server
Throws: IOException
if an I/O error occurs when creating the socket
 o TTConnection
 public TTConnection(String host,
                     int port) throws IOException
Creates a new connection to the specified ThoughtTreasure server.

Parameters:
host - the host name of the ThoughtTreasure server
port - the port number of the ThoughtTreasure server
Throws: IOException
if an I/O error occurs when creating the socket
 o TTConnection
 public TTConnection(InetAddress address,
                     int port) throws IOException
Creates a new connection to the specified ThoughtTreasure server.

Parameters:
address - the IP address of the ThoughtTreasure server
port - the port number of the ThoughtTreasure server
Throws: IOException
if an I/O error occurs when creating the socket

Methods

 o close
 public void close() throws IOException
Closes the connection.

Throws: IOException
if an I/O error occurs when closing the socket
 o ISA
 public boolean ISA(String classname,
                    String objname) throws IOException
Tests whether the specified object is of the specified class.

Parameters:
classname - the name of the class object
objname - the name of the object
Throws: IOException
if an I/O error occurs communicating with the server
 o isPartOf
 public boolean isPartOf(String part,
                         String whole) throws IOException
Tests whether the specified object is a part of another specified object.

Parameters:
part - the name of the part object
whole - the name of the whole object
Throws: IOException
if an I/O error occurs communicating with the server
 o parents
 public Vector parents(String objname) throws IOException
Returns the parents of the specified object.

Parameters:
objname - the name of the object
Throws: IOException
if an I/O error occurs communicating with the server
 o children
 public Vector children(String objname) throws IOException
Returns the children of the specified object.

Parameters:
objname - the name of the object
Throws: IOException
if an I/O error occurs communicating with the server
 o ancestors
 public Vector ancestors(String objname) throws IOException
Returns the ancestors of the specified object.

Parameters:
objname - the name of the object
Throws: IOException
if an I/O error occurs communicating with the server
 o descendants
 public Vector descendants(String objname) throws IOException
Returns the descendants of the specified object.

Parameters:
objname - the name of the object
Throws: IOException
if an I/O error occurs communicating with the server
 o retrieve
 public Vector retrieve(int picki,
                        int anci,
                        int desci,
                        String mode,
                        String ptn) throws IOException
Retrieves assertions from the database matching the specified pattern.

Returns a Vector of Java Objects representing ThoughtTreasure assertions.

Parameters:
picki - if not -1, the index of the object to be picked out of the result assertion
anci - move up (mode="anc" or mode="ancdesc") the hierarchy on this index; should be -1 for mode not "anc" or "ancdesc"
desci - move down (mode="desc" or "ancdesc") the hierarchy on this index; should be -1 for mode not "desc" or "ancdesc"
mode - "exact" or "anc" or "desc" or "ancdesc"
ptn - pattern such as "duration-of attend-play ?"
Throws: IOException
if an I/O error occurs communicating with the server
 o phraseToConcepts
 public Vector phraseToConcepts(String feat,
                                String phrase) throws IOException
Returns the objects (atomic concepts) for the specified word or phrase (lexical entry) in the lexicon.

Returns a Vector of TTLexEntryToObj.

Parameters:
feat - a String containing single-character ThoughtTreasure features such as F_ENGLISH or F_FRENCH. The feature codes are defined in the TT class.
phrase - a ThoughtTreasure lexical entry
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TTLexEntryToObj, TT
 o conceptToLexEntries
 public Vector conceptToLexEntries(String objname) throws IOException
Returns the lexical entries associated with the specified object (atomic concept) in the lexicon.

Returns a Vector of TTLexEntryToObj.

Parameters:
objname - the name of the object
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TTLexEntryToObj
 o tag
 public Vector tag(String feat,
                   String text) throws IOException
Performs part-of-speech (and other) tagging of the specified natural language text.

Returns a Vector of TTPNode.

Parameters:
feat - a String containing single-character ThoughtTreasure features such as F_ENGLISH or F_FRENCH. The feature codes are defined in the TT class.
text - natural language text
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TTPNode, TT
 o syntacticParse
 public Vector syntacticParse(String feat,
                              String text) throws IOException
Syntactically parses the specified natural language text.

Returns a Vector of Java Objects representing parse trees.

Parameters:
feat - a String containing single-character ThoughtTreasure features such as F_ENGLISH or F_FRENCH. The feature codes are defined in the TT class.
text - natural language text
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TT
 o semanticParse
 public Vector semanticParse(String feat,
                             String text) throws IOException
Semantically parses the specified natural language text.

Returns a Vector of Java Objects representing ThoughtTreasure assertions and parse trees.

Parameters:
feat - a String containing single-character ThoughtTreasure features such as F_ENGLISH or F_FRENCH. The feature codes are defined in the TT class.
text - natural language text
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TT
 o generate
 public String generate(String feat,
                        Object obj) throws IOException
Generates the specified ThoughtTreasure assertion in natural language.

Parameters:
feat - a String containing single-character ThoughtTreasure features such as F_ENGLISH or F_FRENCH. The feature codes are defined in the TT class.
obj - Java Object representing a ThoughtTreasure assertion
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TT
 o chatterbot
 public String chatterbot(String feat,
                          String text) throws IOException
Sends natural language input text to the chatterbot and returns the natural language response.

Parameters:
feat - a String containing single-character ThoughtTreasure features such as F_ENGLISH or F_FRENCH. The feature codes are defined in the TT class.
text - natural language input text
Throws: IOException
if an I/O error occurs communicating with the server
See Also:
TT
 o clearContext
 public boolean clearContext()
Clears the discourse context.

If this does not seem to be working, remember that results are cached unless USECACHE is set to false.

See Also:
USECACHE
 o status
 public String status()
Returns the status of the ThoughtTreasure server: "up" or "down".

 o bringdown
 public void bringdown()
Forces ThoughtTreasure to break out of the server select loop, so that it can process further ThoughtTreasure shell commands.

If you would like ThoughtTreasure to exit in this situation, start ThoughtTreasure with a script:

 tt -f server.tt
 
where server.tt contains:
 server
 quit
 

 o clearCache
 public void clearCache()
Clears the cache.


All Packages  Class Hierarchy  This Package  Previous  Next  Index