|
Algernon Software | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.algernon.app.AlgernonApplication org.algernon.Algernon
Algernon is an inference engine for knowledge-based systems that use a relational or frame-based system representation system. See org.algernon.kb for the required KB interface and for implementations of interfaces for other systems. See the following Algernon web pages:
Example usage:Algernon algy = new Algernon(); AlgernonKB kb1 = new AlgernonProtegeKB(".../mykb.pprj"); if (kb1 == null) // check for error opening the KB return; algy.addKB(kb1); // Can add multiple KBs with multiple calls. // Now call the load, ask or tell methods. ErrorSet errors = new ErrorSet(); load(".../myfile.txt"); // Load Algernon rules and commands LispValue result = ask("((...path...))", errors); if (errors.size() > 0) algy.printErrors(errors); else System.out.println(algy.printResultToString("ASK", result)); ...Algernon was originally implemented by James Crawford and Ben Kuipers circa 1990. It was reimplemented on the Algernon Abstract Machine by Micheal Hewett with help from Ben Kuipers and Spencer Bishop circa 1996. This reimplementation in Java commenced in 2002 by Micheal Hewett.
Field Summary | |
LispValue |
ANY
Used when defining a relation, indicates unlimited maximum cardinality. |
LispValue |
ANY_TYPE
|
static int |
BEST_FIRST
Controls how the set of activations is processed. |
LispValue |
BOOLEAN_TYPE
|
static int |
BREADTH_FIRST
Controls how the set of activations is processed. |
LispValue |
CLASS_TYPE
|
LispValue |
DEFAULT
Used when defining a relation. |
static String |
DEFAULT_KBSET_NAME
|
private static int |
DEFAULT_SERVER_PORT_NUMBER
Default port number when Algernon is running in Server mode. |
static int |
DEPTH_FIRST
Controls how the set of activations is processed. |
private Map |
f_allCommands
|
private AlgernonServer |
f_server
|
LispValue |
FALSE
Boolean false = :FALSE. |
LispValue |
FLOAT_TYPE
|
LispValue |
FOREIGN_TYPE
|
LispValue |
INCLUSIVE
Used in structure-traversing commands like :CHILD. |
LispValue |
INSTANCE_TYPE
|
LispValue |
INTEGER_TYPE
|
LispValue |
INVERSE
Used when defining a relation. |
LispValue |
LISP_TYPE_DOMAINS
|
protected AlgernonCompiler |
m_compiler
|
protected AlgernonCompilerState |
m_compileSettings
|
protected int |
m_dataColumn1
|
protected int |
m_dataColumn2
|
protected int |
m_dataColumn3
|
private HashMap |
m_evaluators
|
protected int |
m_executionOrder
|
protected Map |
m_KBSets
|
protected Jatha |
m_lisp
|
protected Processor |
m_processor
|
protected AlgernonSettings |
m_processSettings
|
protected RuleManager |
m_ruleManager
|
LispValue |
MAX_CARDINALITY
Used when defining a relation. |
LispValue |
MIN_CARDINALITY
Used when defining a relation. |
static int |
NEGATED
Used when processing clauses - stating that the clause is negated. |
LispValue |
NOT
This is used in the Algernon macro for adding a known false value to an object-relation. |
LispValue |
STRING_TYPE
|
LispValue |
SYMBOL_TYPE
|
LispValue |
TRUE
Boolean true = :TRUE. |
static char |
VARIABLE_START_CHAR
|
Fields inherited from class org.algernon.app.AlgernonApplication |
|
Constructor Summary | |
Algernon()
|
|
Algernon(AlgernonKB kb)
Create a new instance of Algernon. |
|
Algernon(AlgernonKBSet kbs)
Create a new instance of Algernon. |
Method Summary | |
void |
addClosure(Closure closure)
Adds a closure to the system. |
void |
addCommand(LispValue name,
Command command)
Adds a new command to Algernon. |
void |
addEvaluator(String language,
ExternalLanguageEvaluator evaluator)
Adds a new language evaluator. |
void |
addKB(AlgernonKB kb)
Adds a new KB to the list of KBs that Algernon accesses. |
void |
addKBSet(AlgernonKBSet kbset)
Adds a new AlgernonKBSet to this instantiation of Algernon. |
void |
addRule(Rule rule,
AlgernonFrame associatedFrame)
Adds a rule to the system. |
void |
addToActionQueue(Processor processor,
LispValue item)
Adds an activation to the action queue. |
LispValue |
ask(Path path,
AlgernonKBSet kbSet,
String comment,
ErrorSet errorSet,
BindingList blist,
AlgernonSettings processSettings)
See the single-parameter version for documentation. |
LispValue |
ask(String path)
Processes the path in QUERY mode. |
LispValue |
ask(String path,
AlgernonKB kb)
See the single-parameter version for documentation. |
LispValue |
ask(String path,
AlgernonKB kb,
ErrorSet errors)
See the single-parameter version for documentation. |
LispValue |
ask(String path,
AlgernonKB kb,
ErrorSet errors,
BindingList blist)
See the single-parameter version for documentation. |
LispValue |
ask(String path,
AlgernonKBSet kbSet)
See the single-parameter version for documentation. |
LispValue |
ask(String path,
AlgernonKBSet kbSet,
String comment)
See the single-parameter version for documentation. |
LispValue |
ask(String path,
AlgernonKBSet kbSet,
String comment,
ErrorSet errorSet)
See the single-parameter version for documentation. |
LispValue |
ask(String pathString,
AlgernonKBSet kbSet,
String comment,
ErrorSet errorSet,
BindingList blist,
AlgernonSettings processSettings)
See the single-parameter version for documentation. |
LispValue |
ask(String path,
ErrorSet errors)
See the single-parameter version for documentation. |
LispValue |
askForValue(String query,
LispValue valueType,
Collection possibleValues)
Requires the user to enter an item from the set of possibleValues. |
boolean |
askYorN(String query)
Asks the user to confirm whether the query is true. |
void |
clearAllRules()
Removes all known rules and rule continuations. |
void |
clearQueryHistory()
Clears the entire list of historical queries. |
LispValue |
compile(Path path,
AlgernonKBSet kbSet,
int compileMode,
ErrorSet errorSet)
Compiles a path (which may be a rule declaration, a query, an assert or part of a rule) and returns the AAM opcodes for the path. |
LispValue |
compile(String path,
AlgernonKBSet kbSet,
int compileMode,
ErrorSet errorSet)
Compiles a path (which may be a rule declaration, a query, an assert or part of a rule) and returns the AAM opcodes for the path. |
Collection |
compileRule(Rule rule,
AlgernonKBSet kbSet)
Compiles the given rule and returns the compiled code. |
AlgernonKB |
createKB(Clause clause)
Called by the USE-KB opcode to create a new KB. |
AlgernonRelation |
createRelation(AlgernonKB kb,
String slotName,
Set domains,
Set ranges,
Integer minCardinality,
Integer maxCardinality,
Object defaultValue,
AlgernonRelation inverseRelation)
Creates a new relation in the given KB. |
void |
createRule(Rule rule,
AlgernonKBSet kbSet,
AlgernonFrame frame)
Send in a rule instance. |
Object |
evaluateExpression(String language,
LispValue expression)
Evaluates a method in the given language. |
Boolean |
evaluateExpressionAsBoolean(String language,
LispValue expression)
Evaluates a method in the given language. |
boolean |
generalIsa(String child,
String parent)
Returns true if the first argument is an instance or subclass of the second argument. |
boolean |
generalIsa(String child,
String parent,
AlgernonKB kb)
Returns true if the first argument is an instance or subclass of the second argument. |
boolean |
generalIsa(String child,
String parent,
AlgernonKBSet kbset)
Returns true if the first argument is an instance or subclass of the second argument. |
boolean |
generalNotIsa(String child,
String parent)
Returns true if the first argument is not an instance or subclass of the second argument. |
boolean |
generalNotIsa(String child,
String parent,
AlgernonKB kb)
Returns true if the first argument is not an instance or subclass of the second argument. |
boolean |
generalNotIsa(String child,
String parent,
AlgernonKBSet kbset)
Returns true if the first argument is not an instance or subclass of the second argument. |
Collection |
getActivatedRules(AlgernonFrame frame,
int direction,
int type)
Returns a list of activatable rules that match the given criteria. |
Object |
getAlgernonBinding(String variable,
BindingList bindings)
Returns the binding of a variable from a result. |
static LispValue |
getArgs(LispValue value)
Returns the relation of the clause, which is the first element of the list. |
static LispValue |
getArguments(Clause value)
Returns the relation of the clause. |
Object |
getBinding(String variable,
BindingList bindings)
Returns the binding of a variable from a result. |
Command |
getCommand(LispValue name)
Retrieves a command by its name (a LispSymbol). |
AlgernonCompiler |
getCompiler()
Returns the current compiler used by Algernon. |
ExternalLanguageEvaluator |
getEvaluator(String language)
Returns a language evaluator for the given language. |
int |
getExecutionOrder()
Returns the value of ExecutionOrder. |
static LispValue |
getFrame(Clause value)
Returns the frame of the clause. |
static LispValue |
getFrame(LispValue value)
Returns the frame of the clause, which is the second element of the list. |
String |
getImportantSupersetSlotName()
Returns the name of the slot that represents the relation between a class and a superclass for inheritance purposes. |
AlgernonKBSet |
getKBSet()
Returns the set of KBs with the default AlgernonKBSet name. |
AlgernonKBSet |
getKBSet(String name)
Returns the set of KBs with the given name. |
Jatha |
getLisp()
|
LispParser |
getLispParser()
Returns a LISP parser. |
OpcodeSet |
getOpcodeSet()
|
Processor |
getProcessor()
|
RegisterSet |
getRegisters()
|
static LispValue |
getRelation(Clause value)
Returns the relation of the clause. |
static LispValue |
getRelation(LispValue value)
Returns the relation of the clause, which is the first element of the list. |
Rule |
getRule(String str)
Returns the rule with the given name. |
Collection |
getRules(String str)
Returns all rules with the given string in their names. |
int |
getServerPortNumber()
Returns the port number the server is running on. |
int |
getTraceLevel()
Returns the relation of the clause. |
LispValue |
getValueType(Object o)
Get the data type of the Java object passed in; we expect this to be Integer, Float, Boolean, Cls, or Instance |
LispValue |
getValueTypes()
|
LispValue |
insertDepthFirst(LispValue item,
LispValue queue)
This is the default actionQueueInsertionFunction. |
LispValue |
instantiate(LispValue term,
LispValue env)
|
boolean |
isClassToInstanceRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking an instance to its class in any KB of the default AlgernonKBSet. |
boolean |
isClassToInstanceRelation(String relationName,
AlgernonKB kb)
Returns true if the given string is the name of the relation/slot linking an instance to its class in the given KB. |
boolean |
isClassToInstanceRelation(String relationName,
AlgernonKBSet kbset)
Returns true if the given string is the name of the relation/slot linking an instance to its class in any KB of the given AlgernonKBSet. |
boolean |
isDisjointRelation(String relationName)
Returns true if the given string is the name of a relation specifying that two classes are disjoint |
boolean |
isDisjointRelation(String relationName,
AlgernonKB kb)
Returns true if the given string is the name of a relation specifying that two classes are disjoint in the given KB. |
boolean |
isDisjointRelation(String relationName,
AlgernonKBSet kbset)
Returns true if the given string is the name of a relation specifying that two classes are disjoint in any KB of the given AlgernonKBSet. |
boolean |
isFrame(String frameName)
Returns true if the given string is the name of a frame in any KB. |
boolean |
isFrame(String frameName,
AlgernonKB kb)
Returns true if the given string is the name of a frame in the given KB. |
boolean |
isFrame(String frameName,
AlgernonKBSet kbset)
Returns true if the given string is the name of a frame in any KB in the given AlgernonKBSet. |
static boolean |
isGroundClause(Clause clause)
Returns true if the given clause is ground (contains no variables). |
static boolean |
isGroundPath(Path path)
Returns true if the given clause is ground (contains no variables). |
boolean |
isInstance(Clause clause,
Clause pattern)
Determines whether clause is an instance of pattern, returning true or false. |
boolean |
isInstance(Clause clause,
Clause pattern,
BindingList clauseBindings,
BindingList patternBindings)
Determines whether clause is an instance of pattern, returning true or false. |
boolean |
isInstance(LispValue clause,
LispValue pattern)
Determines whether clause is an instance of pattern, returning true or false. |
boolean |
isInstance(LispValue clause,
LispValue pattern,
BindingList clauseBindings,
BindingList patternBindings)
Determines whether clause is an instance of pattern, returning true or false. |
boolean |
isInstanceToClassRelation(String relationName)
Returns true if the given string is the name of the relation/slot linking an instance to its class in any KB of the default AlgernonKBSet. |
boolean |
isInstanceToClassRelation(String relationName,
AlgernonKB kb)
Returns true if the given string is the name of the relation/slot linking an instance to its class in the given KB. |
boolean |
isInstanceToClassRelation(String relationName,
AlgernonKBSet kbset)
Returns true if the given string is the name of the relation/slot linking an instance to its class in any KB of the given AlgernonKBSet. |
boolean |
isNameRelation(String relationName)
Returns true if the given string is the name of the relation/attribute linking a frame to its name in any KB. |
boolean |
isNameRelation(String relationName,
AlgernonKB kb)
Returns true if the given string is the name of the relation/slot linking a frame to its name in the given KB. |
boolean |
isNameRelation(String relationName,
AlgernonKBSet kbset)
Returns true if the given string is the name of the relation/slot linking a frame to its name in any KB in the given AlgernonKBSet. |
boolean |
isRelation(String frameName)
Returns true if the given string is the name of a relation in any KB. |
boolean |
isRelation(String relationName,
AlgernonKB kb)
Returns true if the given string is the name of a relation in the given KB. |
boolean |
isRelation(String relationName,
AlgernonKBSet kbset)
Returns true if the given string is the name of a frame in any KB in the given AlgernonKBSet. |
boolean |
isSubclassToSuperclassRelation(String relationName)
Returns true if the given string is the name of the relation/attribute linking a class to its superclass in any KB. |
boolean |
isSubclassToSuperclassRelation(String relationName,
AlgernonKB kb)
Returns true if the given string is the name of the relation/slot linking a frame to its name in the given KB. |
boolean |
isSubclassToSuperclassRelation(String relationName,
AlgernonKBSet kbset)
Returns true if the given string is the name of the relation/slot linking a frame to its name in any KB in the given AlgernonKBSet. |
static boolean |
isVariable(LispValue value)
Returns true if the given value represents a variable in the system. |
void |
kbSetRenamed(AlgernonKBSet kbset,
String oldname,
String newname)
Call this when a AlgernonKBSet is renamed. |
void |
load(String filename)
Loads and executes a file of Algernon forms. |
void |
load(String filename,
int traceLevel)
Loads and executes a file of Algernon forms. |
void |
loadRulesFromKB(Collection rules)
Loads rules that have been stored in a KB. |
AlgernonClass |
lookupClass(String name)
Returns a class with the given name if it can find one in any of the KBs in the default KBSet. |
AlgernonClass |
lookupClass(String name,
AlgernonKB kb)
Returns a class with the given name if it can find one in the given KB. |
AlgernonClass |
lookupClass(String name,
AlgernonKBSet kbset)
Returns a class with the given name if it can find one in any of the KBs in the given KBSet. |
Collection |
lookupDirectInstances(AlgernonClass theClass)
Returns a list of all direct instances of the given class. |
Collection |
lookupDirectSubclasses(AlgernonClass theClass)
Returns a list of all subclasses, whether indirect or direct, of the given class. |
AlgernonFrame |
lookupFrame(String name)
Returns a frame with the given name if it can find one in any of the KBs in the default KBSet. |
AlgernonFrame |
lookupFrame(String name,
AlgernonKB kb)
Returns a frame with the given name if it can find one in the given KB. |
AlgernonFrame |
lookupFrame(String name,
AlgernonKBSet kbset)
Returns a class with the given name if it can find one in any of the KBs in the given KBSet. |
Collection |
lookupInstances(AlgernonClass theClass)
Returns a list of all instances, whether indirect or direct, of the given class. |
AlgernonRelation |
lookupRelation(String name)
Returns a relation with the given name if it can find one in any of the KBs in the default KBSet. |
AlgernonRelation |
lookupRelation(String name,
AlgernonKB kb)
Returns a relation with the given name if it can find one in the given KB. |
AlgernonRelation |
lookupRelation(String name,
AlgernonKBSet kbset)
Returns a relation with the given name if it can find one in any of the KBs in the given KBSet. |
Collection |
lookupSubclasses(AlgernonClass theClass)
Returns a list of all subclasses, whether indirect or direct, of the given class. |
static void |
main(String[] args)
The command line arguments are files to be processed. |
void |
printBindingList(int index,
int indent,
PrintWriter s,
BindingList bindings,
LispValue varsToPrint)
Prints a binding list to the given stream. |
void |
printBindingList(PrintWriter s,
BindingList bindings)
This method has the original Algernon output format. |
static void |
printErrors(ErrorSet errs)
Prints an ErrorSet to System.err. |
static String |
printErrorsToString(ErrorSet errs)
Prints an ErrorSet to a String. |
void |
printResult(PrintWriter s,
String operation,
LispValue results,
LispValue varsToPrint)
Prints the results of Algernon execution in a nice format. |
void |
printResults(PrintWriter s,
Result result,
LispValue varsToPrint)
Prints the actual binding lists from the execution. |
String |
printResultToString(String operation,
LispValue results)
Prints the results of Algernon execution in a nice format to a string |
String |
printResultToString(String operation,
LispValue results,
LispValue varsToPrint)
Prints the results of Algernon execution in a nice format to a string |
static void |
printWarnings(ErrorSet errs)
Only prints warnings to System.err. |
static String |
printWarningsToString(ErrorSet errs)
Prints only the warnings in an ErrorSet to a String. |
LispValue |
process(LispValue code,
AlgernonKBSet kbset,
ErrorSet errors)
Executes a set of AAM opcodes. |
LispValue |
queueInsertionFunction(LispValue item,
LispValue values)
Default queue insertion function. |
boolean |
relationIsFull(AlgernonFrame frame,
AlgernonRelation relation)
Returns true if the frame/relation combination is full - that is, the number of values stored in the slot is equal to the slot's maximum cardinality. |
void |
removeKB(AlgernonKB kb)
Removes a KB from the default KB Set. |
void |
removeKB(AlgernonKB kb,
AlgernonKBSet kbset)
Removes a KB from the given KB Set. |
Iterator |
ruleNameIterator()
An iterator that iterates over all Rules in the system. |
boolean |
serverIsRunning()
Returns true if the server is running. |
void |
setCompilerDebug(boolean state)
Use this to turn compiler debug mode on and off. |
void |
setExecutionOrder(int newExecutionOrder)
Sets the value of ExecutionOrder. |
void |
setTraceLevel(int newTraceLevel)
|
void |
shutdownServer()
Shut down the Algernon server. |
String |
startServer(int portNumber)
Starts the Algernon server. |
LispValue |
tell(Path path,
AlgernonKBSet kbSet,
String comment,
ErrorSet errorSet,
AlgernonSettings processSettings)
See the single-parameter version for documentation. |
LispValue |
tell(String path)
Processes the path in ASSERT mode. |
LispValue |
tell(String path,
AlgernonKB kb)
See the single-parameter version for documentation. |
LispValue |
tell(String path,
AlgernonKB kb,
ErrorSet errors)
See the single-parameter version for documentation. |
LispValue |
tell(String path,
AlgernonKBSet kbSet)
See the single-parameter version for documentation. |
LispValue |
tell(String path,
AlgernonKBSet kbSet,
String comment)
See the single-parameter version for documentation. |
LispValue |
tell(String path,
AlgernonKBSet kbSet,
String comment,
ErrorSet errorSet)
See the single-parameter version for documentation. |
LispValue |
tell(String pathString,
AlgernonKBSet kbSet,
String comment,
ErrorSet errorSet,
AlgernonSettings processSettings)
See the single-parameter version for documentation. |
LispValue |
tell(String path,
ErrorSet errors)
See the single-parameter version for documentation. |
LispValue |
toValueType(Object typeName)
Converts an object like ":INTEGER" to an official type. |
void |
trace(int traceLevel,
String message)
Prints a trace message, dependent on the current level of tracing. |
void |
trace(int traceLevel,
String message,
boolean newLine)
Prints a trace message, dependent on the current level of tracing. |
Methods inherited from class org.algernon.app.AlgernonApplication |
getName, getVersionDate, getVersionMajor, getVersionMicro, getVersionMinor, getVersionString, getVersionType, getVersionURL |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String DEFAULT_KBSET_NAME
public static final char VARIABLE_START_CHAR
public static int NEGATED
public LispValue ANY_TYPE
public LispValue BOOLEAN_TYPE
public LispValue CLASS_TYPE
public LispValue FLOAT_TYPE
public LispValue FOREIGN_TYPE
public LispValue INSTANCE_TYPE
public LispValue INTEGER_TYPE
public LispValue STRING_TYPE
public LispValue SYMBOL_TYPE
public LispValue LISP_TYPE_DOMAINS
public static final int DEPTH_FIRST
public static final int BREADTH_FIRST
public static final int BEST_FIRST
public LispValue NOT
public LispValue TRUE
public LispValue FALSE
public LispValue INCLUSIVE
public LispValue MIN_CARDINALITY
public LispValue MAX_CARDINALITY
public LispValue DEFAULT
public LispValue INVERSE
public LispValue ANY
private static int DEFAULT_SERVER_PORT_NUMBER
private Map f_allCommands
protected int m_executionOrder
protected AlgernonCompiler m_compiler
protected Processor m_processor
protected AlgernonSettings m_processSettings
protected AlgernonCompilerState m_compileSettings
protected RuleManager m_ruleManager
protected Map m_KBSets
protected int m_dataColumn1
protected int m_dataColumn2
protected int m_dataColumn3
protected Jatha m_lisp
private HashMap m_evaluators
private AlgernonServer f_server
Constructor Detail |
public Algernon() throws AlgernonException
public Algernon(AlgernonKB kb) throws AlgernonException
kb
- The instance of AlgernonKB. KBs can be
added or removed at runtime.public Algernon(AlgernonKBSet kbs) throws AlgernonException
kbs
- A collection of instances of AlgernonKB. KBs can be
added or removed at runtime.Method Detail |
public LispParser getLispParser()
public LispValue ask(String path)
The path is validated and compiled into AAM machine code, then executed. A Result is returned. If the returned value is null or the size of the ErrorSet is non-zero, the caller should check the ErrorSet for errors and warnings.
If the result is m_lisp.NIL, the operation failed. Otherwise, use Result.iterator() to iterator over the BindingList objects in the Result.
The execution can be controlled by passing in an instance of AlgernonSettings, in which case they will be in effect for this call only, or by setting the parameters individually as a global setting.
If kbSet is null, the default KBSet will be used. If you specifically don't want to use any KBs in the query, send in an empty KBSet.
path
- a String containing a path.
ErrorSet
,
BindingList
,
Result
,
AlgernonSettings
public LispValue ask(String path, AlgernonKB kb)
public LispValue ask(String path, ErrorSet errors)
public LispValue ask(String path, AlgernonKB kb, ErrorSet errors)
public LispValue ask(String path, AlgernonKB kb, ErrorSet errors, BindingList blist)
public LispValue ask(String path, AlgernonKBSet kbSet)
public LispValue ask(String path, AlgernonKBSet kbSet, String comment)
public LispValue ask(String path, AlgernonKBSet kbSet, String comment, ErrorSet errorSet)
public LispValue ask(String pathString, AlgernonKBSet kbSet, String comment, ErrorSet errorSet, BindingList blist, AlgernonSettings processSettings)
public LispValue ask(Path path, AlgernonKBSet kbSet, String comment, ErrorSet errorSet, BindingList blist, AlgernonSettings processSettings)
public LispValue tell(String path)
The path is validated and compiled into AAM machine code, then executed. A ResultSet is returned. If the returned value is null, the caller should check the ErrorSet for errors and warnings.
The execution can be controlled by passing in an instance of AlgernonSettings, in which case they will be in effect for this call only, or by setting the parameters individually as a global setting.
path
- a String containing a path.ErrorSet
,
AlgernonSettings
public LispValue tell(String path, AlgernonKB kb)
public LispValue tell(String path, ErrorSet errors)
public LispValue tell(String path, AlgernonKB kb, ErrorSet errors)
public LispValue tell(String path, AlgernonKBSet kbSet)
public LispValue tell(String path, AlgernonKBSet kbSet, String comment)
public LispValue tell(String path, AlgernonKBSet kbSet, String comment, ErrorSet errorSet)
public LispValue tell(String pathString, AlgernonKBSet kbSet, String comment, ErrorSet errorSet, AlgernonSettings processSettings)
public LispValue tell(Path path, AlgernonKBSet kbSet, String comment, ErrorSet errorSet, AlgernonSettings processSettings)
public static void printErrors(ErrorSet errs)
public static void printWarnings(ErrorSet errs)
public static String printErrorsToString(ErrorSet errs)
public static String printWarningsToString(ErrorSet errs)
public void addKBSet(AlgernonKBSet kbset)
public void clearQueryHistory()
public void addRule(Rule rule, AlgernonFrame associatedFrame)
public void addClosure(Closure closure)
public void clearAllRules()
public Jatha getLisp()
public LispValue compile(Path path, AlgernonKBSet kbSet, int compileMode, ErrorSet errorSet) throws AlgernonException
AlgernonException
public LispValue compile(String path, AlgernonKBSet kbSet, int compileMode, ErrorSet errorSet) throws AlgernonException
AlgernonException
public Collection compileRule(Rule rule, AlgernonKBSet kbSet)
public void createRule(Rule rule, AlgernonKBSet kbSet, AlgernonFrame frame)
public Object evaluateExpression(String language, LispValue expression)
ExternalLanguageEvaluator
public Boolean evaluateExpressionAsBoolean(String language, LispValue expression)
public void addEvaluator(String language, ExternalLanguageEvaluator evaluator)
addEvaluator("PERL", new myPerlEvaluator()); enables the form: (:TEST (:PERL (3 > (length ?sequence))))All language strings are converted to upper case.
language
- a String such as "JAVA" or "LISP".evaluator
- the language evaluator for that language.public ExternalLanguageEvaluator getEvaluator(String language)
public void load(String filename) throws IOException
(tellTraceLevel is Tracer.NORMAL by default.) or (ask )
IOException
public void load(String filename, int traceLevel) throws IOException
(tellTraceLevel is Tracer.NORMAL by default.) or (ask )
IOException
public Iterator ruleNameIterator()
public LispValue process(LispValue code, AlgernonKBSet kbset, ErrorSet errors) throws AlgernonException
AlgernonException
public void addKB(AlgernonKB kb)
public void removeKB(AlgernonKB kb)
public void removeKB(AlgernonKB kb, AlgernonKBSet kbset)
public AlgernonKBSet getKBSet()
public AlgernonKBSet getKBSet(String name)
public static LispValue getFrame(LispValue value)
public static LispValue getFrame(Clause value)
public static LispValue getRelation(LispValue value)
public static LispValue getRelation(Clause value)
public Rule getRule(String str)
public Collection getRules(String str)
public Collection getActivatedRules(AlgernonFrame frame, int direction, int type)
RuleManager
public int getTraceLevel()
public static LispValue getArgs(LispValue value)
public static LispValue getArguments(Clause value)
public Object getBinding(String variable, BindingList bindings)
To get the bindings from a result, do this:
LispValue result = algy.ask("..."); if (result == null) ... else { for (Iterator iterator = ((Result)result).iterator(); iterator.hasNext();) { BindingList bl = (BindingList) iterator.next(); Object value = algy.getBinding("?x", bl); // Object will either be a Java Object (Integer, Float, etc.) // or a KB object (typically a Protege Instance). // If you want Algernon objects, use getAlgernonBinding(). } }
variable
- a string containing the variable name (case-sensitive)bindings
- a BindingList obtained by iterating through a result.getAlgernonBinding(java.lang.String, org.algernon.datatype.BindingList)
public Object getAlgernonBinding(String variable, BindingList bindings)
To get the bindings from a result, do this:
LispValue result = algy.ask("..."); if (result == null) ... else { for (Iterator iterator = ((Result)result).iterator(); iterator.hasNext();) { BindingList bl = (BindingList) iterator.next(); Object value = algy.getAlgernonBinding("?x", bl); // Object will either be a Java Object (Integer, Float, etc.) // or an instance of AlgernonFrame. If you want KB-specific // objects (e.g. a Protege Instance), use getBinding(). } }
variable
- a string containing the variable name (case-sensitive)bindings
- a BindingList obtained by iterating through a result.getBinding(java.lang.String, org.algernon.datatype.BindingList)
public AlgernonCompiler getCompiler()
public String getImportantSupersetSlotName()
public static boolean isVariable(LispValue value)
public int getExecutionOrder()
public void setExecutionOrder(int newExecutionOrder)
public void addToActionQueue(Processor processor, LispValue item) throws AlgernonDataException
AlgernonDataException
public AlgernonRelation createRelation(AlgernonKB kb, String slotName, Set domains, Set ranges, Integer minCardinality, Integer maxCardinality, Object defaultValue, AlgernonRelation inverseRelation) throws AlgernonDataException
AlgernonDataException
public LispValue queueInsertionFunction(LispValue item, LispValue values)
public LispValue insertDepthFirst(LispValue item, LispValue queue)
public LispValue instantiate(LispValue term, LispValue env)
public boolean isInstance(LispValue clause, LispValue pattern)
public boolean isInstance(Clause clause, Clause pattern)
public boolean isInstance(Clause clause, Clause pattern, BindingList clauseBindings, BindingList patternBindings)
public boolean isInstance(LispValue clause, LispValue pattern, BindingList clauseBindings, BindingList patternBindings)
public void kbSetRenamed(AlgernonKBSet kbset, String oldname, String newname)
public String printResultToString(String operation, LispValue results, LispValue varsToPrint)
public String printResultToString(String operation, LispValue results)
public void printResult(PrintWriter s, String operation, LispValue results, LispValue varsToPrint)
public void printResults(PrintWriter s, Result result, LispValue varsToPrint)
public void printBindingList(int index, int indent, PrintWriter s, BindingList bindings, LispValue varsToPrint)
public void printBindingList(PrintWriter s, BindingList bindings)
public void setTraceLevel(int newTraceLevel)
public boolean relationIsFull(AlgernonFrame frame, AlgernonRelation relation) throws AlgernonException
AlgernonException
public static boolean isGroundClause(Clause clause)
public static boolean isGroundPath(Path path)
public boolean isFrame(String frameName) throws AlgernonDataException
AlgernonDataException
public boolean isFrame(String frameName, AlgernonKB kb) throws AlgernonDataException
AlgernonDataException
public boolean isFrame(String frameName, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public boolean isNameRelation(String relationName) throws AlgernonDataException
AlgernonDataException
public boolean isNameRelation(String relationName, AlgernonKB kb)
public boolean isNameRelation(String relationName, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public boolean isInstanceToClassRelation(String relationName)
public boolean isInstanceToClassRelation(String relationName, AlgernonKBSet kbset)
public boolean isInstanceToClassRelation(String relationName, AlgernonKB kb)
public boolean isClassToInstanceRelation(String relationName)
public boolean isClassToInstanceRelation(String relationName, AlgernonKBSet kbset)
public boolean isClassToInstanceRelation(String relationName, AlgernonKB kb)
public boolean isDisjointRelation(String relationName)
public boolean isDisjointRelation(String relationName, AlgernonKB kb)
public boolean isDisjointRelation(String relationName, AlgernonKBSet kbset)
public boolean isSubclassToSuperclassRelation(String relationName)
public boolean isSubclassToSuperclassRelation(String relationName, AlgernonKB kb)
public boolean isSubclassToSuperclassRelation(String relationName, AlgernonKBSet kbset)
public boolean isRelation(String frameName) throws AlgernonDataException
AlgernonDataException
public boolean isRelation(String relationName, AlgernonKB kb) throws AlgernonDataException
AlgernonDataException
public boolean isRelation(String relationName, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public boolean generalIsa(String child, String parent) throws AlgernonDataException
AlgernonDataException
public boolean generalIsa(String child, String parent, AlgernonKB kb) throws AlgernonDataException
AlgernonDataException
public boolean generalIsa(String child, String parent, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public boolean generalNotIsa(String child, String parent) throws AlgernonDataException
AlgernonDataException
public boolean generalNotIsa(String child, String parent, AlgernonKB kb)
public boolean generalNotIsa(String child, String parent, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public AlgernonClass lookupClass(String name) throws AlgernonDataException
AlgernonDataException
public AlgernonClass lookupClass(String name, AlgernonKB kb) throws AlgernonDataException
AlgernonDataException
public AlgernonClass lookupClass(String name, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public AlgernonFrame lookupFrame(String name) throws AlgernonDataException
AlgernonDataException
public AlgernonFrame lookupFrame(String name, AlgernonKB kb) throws AlgernonDataException
AlgernonDataException
public AlgernonFrame lookupFrame(String name, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public AlgernonRelation lookupRelation(String name) throws AlgernonDataException
AlgernonDataException
public AlgernonRelation lookupRelation(String name, AlgernonKB kb) throws AlgernonDataException
AlgernonDataException
public AlgernonRelation lookupRelation(String name, AlgernonKBSet kbset) throws AlgernonDataException
AlgernonDataException
public Collection lookupDirectInstances(AlgernonClass theClass)
theClass
- the class whose instances are returned.
public Collection lookupInstances(AlgernonClass theClass)
theClass
- the class whose instances are returned.
public Collection lookupSubclasses(AlgernonClass theClass)
theClass
- the class whose instances are returned.
public Collection lookupDirectSubclasses(AlgernonClass theClass)
theClass
- the class whose instances are returned.
public void trace(int traceLevel, String message)
Tracer
public void trace(int traceLevel, String message, boolean newLine)
Tracer
public boolean askYorN(String query) throws AlgernonRuntimeException
query
- The query to ask of the user. Printed directly to the console.
AlgernonRuntimeException
public LispValue askForValue(String query, LispValue valueType, Collection possibleValues) throws AlgernonRuntimeException
query
- The query printed for the user.valueType
- The type of value requested: BOOLEAN_TYPE, INTEGER_TYPE, etc.possibleValues
- a set of legal answers.
AlgernonRuntimeException
BOOLEAN_TYPE
,
FLOAT_TYPE
,
CLASS_TYPE
,
INTEGER_TYPE
,
SYMBOL_TYPE
,
STRING_TYPE
public static void main(String[] args)
-s silent - does not print any messages.
args
- files to be sent to Algernon.load().load(java.lang.String)
public void loadRulesFromKB(Collection rules) throws IOException, AlgernonDataException
rules
- A Collection of AlgernonInstances that contain the required slots.
IOException
AlgernonDataException
public boolean serverIsRunning()
public int getServerPortNumber()
public String startServer(int portNumber)
public void shutdownServer()
public void addCommand(LispValue name, Command command)
public Command getCommand(LispValue name)
public Processor getProcessor()
public OpcodeSet getOpcodeSet()
public RegisterSet getRegisters()
public LispValue getValueTypes()
public LispValue toValueType(Object typeName)
typeName
-
public LispValue getValueType(Object o)
public AlgernonKB createKB(Clause clause) throws AlgernonDataException
(:USE-KB name type arg1 arg2...) (:USE-KB :KB-1 Protege "mypath/myKB.pprj") (:USE-KB :KB-2 Google "com.google.soap.search" "google-api-key") (:USE-KB :KB-3 Hibernate "your.java.api.interface package" "your.java.api.impl package") (:USE-KB :KB-4 JavaAPI "your.java.api.interface package" "your.java.api.impl package")
clause
-
AlgernonDataException
public void setCompilerDebug(boolean state)
|
Algernon Software | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |