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
.
-
DEBUG
- Whether debugging information should be printed to
System.out
;
false
by default.
-
PORT
- The ThoughtTreasure Server Protocol (TTSP) registered port number
listed by the Internet Assigned Numbers Authority (IANA); the port
number is 1832.
-
USECACHE
- Whether to cache results for later reuse without contacting
the ThoughtTreasure server;
true
by default.
-
TTConnection(InetAddress)
- Creates a new connection to the specified ThoughtTreasure server.
-
TTConnection(InetAddress, int)
- Creates a new connection to the specified ThoughtTreasure server.
-
TTConnection(String)
- Creates a new connection to the specified ThoughtTreasure server.
-
TTConnection(String, int)
- Creates a new connection to the specified ThoughtTreasure server.
-
ancestors(String)
- Returns the ancestors of the specified object.
-
bringdown()
- Forces ThoughtTreasure to break out of the server select loop,
so that it can process further ThoughtTreasure shell commands.
-
chatterbot(String, String)
- Sends natural language input text to the chatterbot and returns the
natural language response.
-
children(String)
- Returns the children of the specified object.
-
clearCache()
- Clears the cache.
-
clearContext()
- Clears the discourse context.
-
close()
- Closes the connection.
-
conceptToLexEntries(String)
- Returns the lexical entries associated with the specified object
(atomic concept) in the lexicon.
-
descendants(String)
- Returns the descendants of the specified object.
-
generate(String, Object)
- Generates the specified ThoughtTreasure assertion in natural language.
-
ISA(String, String)
- Tests whether the specified object is of the specified class.
-
isPartOf(String, String)
- Tests whether the specified object is a part of another specified object.
-
parents(String)
- Returns the parents of the specified object.
-
phraseToConcepts(String, String)
- Returns the objects (atomic concepts) for the specified
word or phrase (lexical entry) in the lexicon.
-
retrieve(int, int, int, String, String)
- Retrieves assertions from the database matching the specified pattern.
-
semanticParse(String, String)
- Semantically parses the specified natural language text.
-
status()
- Returns the status of the ThoughtTreasure server: "up" or "down".
-
syntacticParse(String, String)
- Syntactically parses the specified natural language text.
-
tag(String, String)
- Performs part-of-speech (and other) tagging of the specified
natural language text.
DEBUG
public static boolean DEBUG
- Whether debugging information should be printed to
System.out
;
false
by default.
USECACHE
public static boolean USECACHE
- Whether to cache results for later reuse without contacting
the ThoughtTreasure server;
true
by default.
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.
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
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
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
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
close
public void close() throws IOException
- Closes the connection.
- Throws: IOException
- if an I/O error occurs when closing the socket
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
status
public String status()
- Returns the status of the ThoughtTreasure server: "up" or "down".
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
clearCache
public void clearCache()
- Clears the cache.
All Packages Class Hierarchy This Package Previous Next Index