E2glite Tutorial Part1
E2glite Tutorial Part1
E2glite Tutorial Part1
e2gLite Tutorial
_Part 1
Prepared by Louise
Hawkins and Sylvia
Ward (2008)
Table of Contents
e2gLite________________________________________________________2
Introduction________________________________________________________2
Expertise2go demo___________________________________________________2
Tutorial A______________________________________________________3
To build your own Knowledgebase_____________________________________3
Steps required to develop a knowledge base_____________________________________3
Understanding the components of your knowledge base___________________________6
How to go about debugging knowledge bases___________________________________8
Introduction
e2gLite
Expert systems shell.
T
Icons:
his tutorial will assist you to learn how to use e2gLite. e2gLite is a rule-based expert
system shell. e2gLite is a development toolkit (a 'shell') developed by eXpertise2GO.
Access to the e2gLite documentation provided by eXpertise2Go is available from
http://expertise2go.com/webesie/e2gdoc/ .
The icons (below) are used throughout the manual to highlight key concepts.
I C O N
K E Y
Warning
Save now
Expertise2go demo
To start, go to http://expertise2go.com/webesie/e2gdoc/ and click on Module 1. Click on the Graduate
school admissions, demonstration: end-user mode link and run the graduate admissions demo. You
will see a webpage open up. Click on the button Start the consultation to run the demo. Answer each
question and the expert system will provide you with advice. (This is an American demonstration so
you may not understand what the questions are asking, but answer the questions with any appropriate
response to see the result).
Tutorial A
he components that make up a knowledge base using e2gLite consists of three files, the
e2gLite.jar file, the .kb file and the .html file. The e2gLite.jar file is the executable file
which is the expert system shell. The .kb file is the knowledge base which includes the
goals, the rules by which the goals will be reached, and the questions (prompts) which the
user must answer. The .html file is used to provide an appropriate interface for the system.
The following is a very simple example of an expert system using e2gLite.
Is it likely to rain?
Wear a parka
Wear a shirt
The decision table below shows the inputs and outputs for the decision above.
Temperature
Low
Low
high
high
Rain
yes
no
yes
no
1:
First,
you
need
to
download
the
e2glite.jar
file
from
http://expertise2go.com/webesie/e2gdoc/e2mod2.htm. (Link: I agree to the conditions of use
Download e2gLite). This is the executable file that your expert system will use to run your
knowledge base.
Step 2: Create a folder for your expert system files and save the e2glite.jar file in this folder.
Step 3: Open a text editor (DOS based editor included with Windows or Notepad). (Do not use a word
processing application).
Step 4: Now type the following into the text file:
REM What to wear based on weather conditions
(what_to_wear.kb)
REM Decide how to proceed
RULE [temperature low and weather wet]
If [temperature] = "low" and
[rain] = "yes"
Then [the recommendation] = "wear a parka"
RULE [temperature high and weather wet]
If [temperature] = "high" and
[rain] = "yes"
Then [the recommendation] = "wear a rain coat"
RULE [temperature low and weather dry]
If [temperature] = "low" and
[rain] = "no"
Then [the recommendation] = "wear a sports coat"
RULE [temperature high and weather dry]
If [temperature] = "high" and
[rain] = "no"
Then [the recommendation] = "wear a shirt"
REM Prompts
PROMPT [temperature] MultChoice
"Is the temperature high or low?"
"high"
"low"
PROMPT [rain] MultChoice
"Is it likely to rain?"
"yes"
"no"
GOAL [the recommendation]
Type in the name of the knowledgebase, what_to_wear.txt and save the file in the same folder
as you saved the e2gLite.jar file.
Step 6: Go to Windows Explorer and change the file extension from .txt to .kb by right clicking on the
file name and typing in the new extension. (Do not try to save the file as a .kb while in the text
editor).
Step 7: Now download the .txt template from the resources page on the course website.
Step 8: You will now need to use Notepad to develop the html file. Open the .txt template in Notepad
and change the appropriate sections. Remember to enter your name and student number in Line
11. The html file needs to look like this:
<HTML>
<HEAD><TITLE>Example 1</TITLE></HEAD>
<BODY BGCOLOR="white">
<FONT FACE="Arial,Helvetica" SIZE=2>
<CENTER><H2>What to wear</H2></CENTER>
This system allows you to decide what clothing to wear, based on different
weather conditions
<H4>Student name and student number</H4>
<P>
<CENTER>
<P><H3>What to wear (end-user mode)</H3>
<APPLET CODE="e2glite.e2g.class" archive="e2glite.jar" WIDTH=450 HEIGHT=300>
<PARAM NAME="KBURL" VALUE="what_to_wear.kb">
<PARAM NAME="APPTITLE" VALUE="What to wear">
<PARAM NAME="PROMPTCOLOR" VALUE="#ff0000">
<PARAM NAME="BGCOLOR" VALUE="#00ff00">
<PARAM NAME="DEBUG" VALUE="false">
Java-enabled browser required
</APPLET>
<P><H3>What to wear (debug mode)</H3>
<APPLET CODE="e2glite.e2g.class" archive="e2glite.jar" WIDTH=450 HEIGHT=300>
<PARAM NAME="KBURL" VALUE="what_to_wear.kb">
<PARAM NAME="APPTITLE" VALUE="What to wear">
<PARAM NAME="DEBUG" VALUE="true">
Java-enabled browser required
</APPLET>
</FONT>
</CENTER>
</BODY>
</HTML>
Step 9: Save the html file as what_to_wear.txt in the same folder as the .jar and .kb file. Go to
Windows Explorer and change the file extension from .txt to .html by right clicking on the file
name and typing in the new extension. (Do not try to save the file as a .html while in the text
editor).
Step 10: Now that you have created the three files for your expert system, go to the files using
Windows Explorer and double click on the .html file. Your knowledge base should start to run.
Step 11: Test your knowledge base by answering the questions and checking to see that you get an
appropriate answer.
Step 12: If your knowledge base does not work and you get an error message you will need to correct
the errors in the .kb and .html files.
Step 13: Use the debug link on the interface page to see where your errors are located.
The next section explains the elements in your knowledge base and provides some suggestions of
potential errors.
The first line begins with RULE followed by a short identifying description
of the rule enclosed in square brackets.
The next line begins the rule premise with IF followed by a logical
expression consisting of:
o
The next line following a premise logical expression that doesn't end with
AND or OR begins the rule consequent with THEN followed by an
PROMPT definitions: Prompts should be included in the knowledge base after all
rules are defined. Possible elements of each prompt include:
The first line begins with PROMPT followed by an attribute name enclosed
in square brackets followed by the prompt type. In addition to MultChoice
(multiple choice) shown in the example, prompt types include Choice
(drop down list box), AllChoice (accept multiple responses), YesNo
(Boolean input) and Numeric (accept a numeric value).
GOAL definitions: Each GOAL is defined on a single line that begins with GOAL
followed by the name of the goal attribute enclosed in square brackets. GOALs
may be specified before or after PROMPTS, but must follow RULE definitions.
There has to be at least one GOAL statement in a knowledge base: GOALs are
the attributes for which the inference engine seeks values.