Permalink
Browse files

Very basic Jess system run from Java

  • Loading branch information...
1 parent e49f8a8 commit be16c09dec4f87e97c20a3c1769ea38670311785 @joelburget committed Apr 29, 2012
Showing with 44 additions and 0 deletions.
  1. +21 −0 rules.clp
  2. +23 −0 src/miftiwac/Miftiwac.java
View
@@ -0,0 +1,21 @@
+;(deftemplate bpm-range
+; (slot min)
+; (slot max))
+
+(deftemplate genre
+ (slot name)
+; (slot bpm-range))
+ (slot min-bpm)
+ (slot max-bpm))
+
+; startup vs deffacts
+(defrule startup ""
+ =>
+ (assert (genre (name house) (min-bpm 118) (max-bpm 135)))
+ (assert (genre (name disco) (min-bpm 90) (max-bpm 115)))
+ )
+
+(defrule print-possibilities
+ ?g <- (genre {min-bpm < 125 && max-bpm >= 125})
+ =>
+ (printout t "genre is " ?g.name crlf))
View
@@ -0,0 +1,23 @@
+package miftiwac;
+
+import jess.*;
+
+public class Miftiwac {
+ public static void main(String[] args) {
+ try {
+ // Create a Jess rule engine
+ Rete engine = new Rete();
+ engine.reset();
+
+ // Load the pricing rules
+ engine.batch("rules.clp");
+
+ // Mark end of catalog data for later
+ WorkingMemoryMarker marker = engine.mark();
+
+ engine.run();
+ } catch (JessException e) {
+ System.out.println(e);
+ }
+ }
+}

0 comments on commit be16c09

Please sign in to comment.