The only blog on Jess that I’ve found.
Lisa is a production-rule system implemented in the Common Lisp Object System (CLOS), and is heavily influenced by CLIPS and the Java Expert System Shell (JESS).
Here are many great posts by John Lindberg.
Custom JESS REPL
If you want to use a custom JESS REPL with Emacs then set up a shell script
jsjs-repl like this:
#!/bin/bash mvn --file /home/gcr/git/jess-sample-java-setup/jsjs/pom.xml compile -Pjess-repl
And then make this call in EMACS before calling
(setq inferior-jess-program "/home/gcr/git/jess-sample-java-setup/jsjs/jsjs-repl")
My background is custom software development in a consulting and stuff sup role. My work has been primarily in insurance, manufacturing, and the financial industries with clients ranging from large to small. Tech/training wise I studied mscs, computing, and computational sciences at MU; and have practiced software engineering at my day job for the past eleven years, and I mean practice, it is something I am constantly trying to get better at. Tech wise I am a pretty typical GNU/Linux & Windows person more or less, doing Java, .NET, Lisp, and recently Python.
A commonality among nearly every project I’ve worked on is the eventual occurrence of if statements 5-levels deep repeated across multiple call-sites (40+ typically) through no want/action/desire of my own. When I look at stuff like this, I feel like in addition to refactoring (regardless of the system type) there might be a better way. From what I’ve learned so far, rules engines seem like they might be a good fit.
Part of my goal here was to find a tool that not only provided a rules engine, but also helps the user to understand and debug what is happening, when, how, and why, with the intent that the developer implementing the rules can do it in a non-arcane manner and also share the behavior of the engine with business-related users to help them down the path of thinking in that manner.
jess-mode Cheat Sheet
Before tackling the CLIPS literature I felt like I ought to ramp up on the key-bindings for jess-mode in EMACS. Here are some good ones, you will find that they are basically what you would expect in the grouping that I view them in order to help the development process:
\C-c,f‘inf-jess-get-facts: Retrieve the fact list from the inferior Jess process.
\C-c,r‘inf-jess-get-rules: Retrieve the rule list from the inferior Jess process.
\C-c,a‘inf-jess-get-agenda: Retrieve the agenda from the inferior Jess process.
\C-c,v‘inf-jess-get-view: The view command displays a live snapshot of the Rete network in a graphical window. I added this one myself.
\C-c,g‘inf-jess-run-engine: Run the inference engine in the inferior Jess process.
\C-c,i‘inf-jess-reset-engine: Reset the inference engine running in the inferior Jess process.
\C-x\C-e‘inf-jess-eval-last-sexp: Send the previous sexp to the inferior Jess process. Prefix argument means switch to the Jess buffer afterwards.
\C-c,e‘inf-jess-eval-region: Send the current region to the inferior Jess process. Prefix argument forces switch to Jess buffer afterwards.
\C-c,b‘inf-jess-eval-buffer: Send the entire buffer to the Inferior Jess process. Prefix argument means switch to the Jess buffer afterwards.
\C-c,t‘inf-jess-eval-deftemplate: Send the current deftemplate to the inferior Jess process. Prefix argument means switch to the Jess buffer afterwards.
\M-\C-x‘inf-jess-eval-deffunction: Send the current deffunction to the inferior Jess process. Prefix argument means switch to the Jess buffer afterwards.
I bound ‘inf-jess-val-buffer to , that is what I do for all lisp modes, but that is a personal preference thing.
To set the JESS interpreter command (make sure it is a shell scrip):
(setq inferior-jess-program "foo")
To start JESS in EMACS run:
For fun I worked through the CLIPS 6.30 beta literature specifically the user’s guide and basic programming guide. These are so, so helpful; they are aimed and programmers who have never worked in an expert system before. It goes in a lot more depth what you may do in CLIPS, and consequently JESS, than JESS does.
sudo apt-get install clips clips-common clips-doc
Installing it provides
- the interpreter
- a nice man page
- a help file accessible within the interpreter via ‘(help)
- /usr/share/doc/clips-common/CLIPS-FAQ a compressed FAQ file readable with zcat or zless or zless to read it.
- /usr/share/doc/clips-common/html/ Local copy of the main website with links out to stuff like documentation
- /usr/share/doc/clips-common/examples/ “A number of examples of CLIPS program are available so you can test the interpreter and learn how it works. You can, for example, load one of them with (load “/usr/share/doc/clips-common/examples/wordgame.clp”) and run it using (reset) and (run).”
CLIPS seems like a great place to start with learning at least parts of JESS. I’m guessing that there is a lot of good material between the docs and examples.
This project will start out with a typical Java development setup:
- Ubuntu 12.04 LTS GNU/Linux: http://www.ubuntu.com/
- IntelliJ Idea, the most pleasant development environment out there (Eclipse
usually copies the good features within 3-9 months, but it is still pretty
- jprofiler: http://www.ej-technologies.com/products/jprofiler/overview.html
- GNU Emacs 24, for everything that Idea doesn’t do well: https://www.gnu.org/software/emacs/
- Oracle’s JDK 1.7, it is the newest out there: http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
- Apache Maven, dependency management at its best: https://maven.apache.org/
- Jess 7.1p2, you need to obtain it directly from the source, and it is free for
most of us. READ THE LICENSE AGREEMENT and you may download it immediately: http://www.jessrules.com/jess/download.shtml
- Graphviz, for state diagrams: http://www.graphviz.org/
For a couple of months I have thought about how fun it would be to set up a real simple Java+Jess project to help myself out with the basics of dependency management and logistics of interaction between Java and Jess. Recently it made sense to start using GitHub. With the hope that lowering the barriers to anyone interested in using Jess, I decided to throw the project out here. More so, because I will be working on it piecemeal, I decided to log progress in this diary and also on the blog I’m hoping it will serve as a resource for anyone interested in the project. My particular interest in Jess is for where a rules engine might fit in a 3 month to 2 year long Java project with a team of 3-12.
Here are some of my goals:
- Provide a preconfigured project setup using Maven
- Demonstrate some sample projects
- Learn and cover interesting aspects of how Java and Jess work together
- Learn or create nice ways of testing the system
Here are some of the options for sample projects to drive it:
- Porting CLIPS samples
- Logic puzzles
- Video games
- HVAC system
- Form data validation
- Data conversion
Here are some of ways to test it:
My preparation so far has been to read virtually everything available on Jess ( http://herzberg.ca.sandia.gov/), twice, and additionally read whatever I can find about CLIPS (http://clipsrules.sourceforge.net/), rules engines, and expert systems in books and on the Internet.
Getting started with Git meant reading the official docs (http://git-scm.com/documentation) and man pages, and GitHub itself has excellent documentation (https://help.github.com/). One helpful page was for the basic Markdown syntax which I had never learned officially (http://daringfireball.net/projects/markdown/basics) (except for using it in various wikis).
Admittedly, the Jess wiki cites a project like the above to be outside the sweet-spot of Jess. My worldview right now, though, is that the rules engine way-of-thinking has a lot to offer beyond mega-million enterprise-style projects, and that anyone who masters it will have a very valuable and powerful tool in his kit when he is done!