edu.buffalo.sneps
Class JavaSnepsAPI

java.lang.Object
  extended by edu.buffalo.sneps.JavaSnepsAPI

public class JavaSnepsAPI
extends java.lang.Object

Class of connections between Java and the SNePS knowledge representation and reasoning system. Methods defined invoke their respective SNePS functions using Allegro Common Lisp's (ACL) Jlinker interface

Note: ACL or an instance of the SNePS executable is required to use this API.

See Also:
jLinker - A Dynamic Link between Lisp and Java

Constructor Summary
JavaSnepsAPI(int interface_port)
          Creates an instance of the JavaSnepsAPI using the specified port.
JavaSnepsAPI(java.lang.String config_file, int interface_port)
          Creates an instance of the JavaSnepsAPI using the specified port and config_file.
 
Method Summary
 java.util.HashSet<java.lang.String> ask(java.lang.String command)
          Given a valid ask input, invokes the SNePSLOG ask method on that input.
 java.util.HashSet<java.lang.String> askifnot(java.lang.String command)
          Given a valid ask input, invokes the SNePSLOG askifnot method on that input.
 java.util.HashSet<Substitution> askwh(java.lang.String command)
          Given a valid ask input, invokes the SNePSLOG askwh method on that input.
 java.util.HashSet<Substitution> askwhnot(java.lang.String command)
          Given a valid ask input, invokes the SNePSLOG askwhnot method on that input.
 void endLispConnection()
          Terminates the Java-Sneps connection.
 boolean isConnected()
          Returns true if the connection between Java and Sneps is still functioning.
 void tell(java.lang.String command)
          Given a proper command string, invokes the SNePSLOG tell method on that command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaSnepsAPI

public JavaSnepsAPI(int interface_port)
Creates an instance of the JavaSnepsAPI using the specified port. It is presumed that the user will manually start up the SNePS system and invoke the SNePS connection function as follows:

(snepslog:init-java-sneps-connection interface_port java-classpath)

The java-classpath is the classpath needed to compile and run this class.

Parameters:
interface_port - The port to use for this connection

JavaSnepsAPI

public JavaSnepsAPI(java.lang.String config_file,
                    int interface_port)
Creates an instance of the JavaSnepsAPI using the specified port and config_file. Starts SNePS using information specified in the config_file.

Parameters:
config_file - Location of the JavaSNePS config file (java_sneps_config.config). Typically this file is the JavaSneps subdirectory in the SNePS home directory. Ask the administrator who installed SNePS for its location.
interface_port - The port to use for this connection
Method Detail

isConnected

public boolean isConnected()
Returns true if the connection between Java and Sneps is still functioning.

Returns:
true if Java and SNePS are still connected, false otherwise.

tell

public void tell(java.lang.String command)
Given a proper command string, invokes the SNePSLOG tell method on that command.

Note: Unlike the SNePS version of tell, this tell returns nothing.

Parameters:
command - A SNePSLOG parsable string to invoke in SNePS.
See Also:
"SNePS 2.7.0 Manual - snepslog:tell"

ask

public java.util.HashSet<java.lang.String> ask(java.lang.String command)
Given a valid ask input, invokes the SNePSLOG ask method on that input. Returns a HashSet of strings representing the node results.

Parameters:
command - Valid ask input with which to query SNePS.
Returns:
A HashSet of String objects representing the query results
See Also:
"The SNePS 2.7.0 Manual - snepslog:ask"

askifnot

public java.util.HashSet<java.lang.String> askifnot(java.lang.String command)
Given a valid ask input, invokes the SNePSLOG askifnot method on that input. Returns a HashSet of strings representing the node results.

Parameters:
command - Valid ask input with which to query SNePS.
Returns:
A HashSet of String objects representing query results
See Also:
"The SNePS 2.7.0 Manual - snepslog:askifnot"

askwh

public java.util.HashSet<Substitution> askwh(java.lang.String command)
Given a valid ask input, invokes the SNePSLOG askwh method on that input. Returns a HashSet of the substitution objects representing the variable substitutions needed to answer the query.

Parameters:
command - Valid ask input with which to query SNePS.
Returns:
HashSet of Substitution
See Also:
"The get value from variable method", "The SNePS 2.7.0 Manual - snepslog:askwh"

askwhnot

public java.util.HashSet<Substitution> askwhnot(java.lang.String command)
Given a valid ask input, invokes the SNePSLOG askwhnot method on that input. Returns a HashSet of substitution objects representing the variable substitutions needed to answer the query.

Parameters:
command - Valid ask input with which to query SNePS.
Returns:
HashSet of Substitution
See Also:
"The get value from variable method", "The SNePS 2.7.0 Manual - snepslog:askwhnot"

endLispConnection

public void endLispConnection()
Terminates the Java-Sneps connection.