Jess, Java Expert System Shell
Originally
a core Clips implementation in Java Evolved into Java-influenced environment, details refer to Jess
Extendable
can be extended using Userfunction
Java program: import jess.*; public class ExMyUpcase implements { // The name method returns the
Userfunction
name by which the function will appear in Jess code. public String getName() { return "my-upcase"; }
public Value call(ValueVector vv, Context context) throws JessException { return new Value([Link](1).stringValue(context).toUpperCase() , [Link]); } }
Every datum in Jess is represented by an object of [Link]. The [Link] represents an execution context for the evaluation of function calls and the resolution of variables. The [Link] class is Jess's internal representation of a list, and is used to represent multifields.
Jess commands: Jess> (load-function ExMyUpcase) Jess> (my-upcase foo)
Embeddable
can embeded in a Java program:
import jess.*; public class ExPt { public static void main(String[] unused) throws JessException
{ Rete r = new Rete(); [Link]("(batch jess/[Link])"); [Link]("(deftemplate point \"A 2D point\" (slot x) (slot y))"); [Link]("(assert (point (x 37) (y 49)))"); [Link]("(facts)"); } }
Executing a Jess File
import jess.*; // ... // Create a Jess engine Rete rete = new Rete(); // Open the file [Link] FileReader fr = new FileReader("[Link]"); // Create a parser for the file, telling it where to take input // from and which engine to send the results to Jesp j = new Jesp(fr, rete); try { // parse and execute one construct, without printing a prompt [Link](false); } catch (ReteException re) { // All Jess errors are reported as 'ReteException's. [Link]([Link]()); }
Example 1: fixed rule-base file name
Java
source: [Link] Jess source: [Link] Example 2: user-specified rule-base file name
Java
source: [Link] Jess source: [Link]
Object Support
Create and manipulate Java objects directly from Jess,
(bind (call (call (call ?ht ?ht ?ht ?ht (new [Link])) put "key1" "element1") put "key2" "element2") get "key1")
Run-time Environment
1. Command Line
java [Link]
2. Graphics Console
java [Link]