Expertise2Go

Table of Contents

Expertise2Go 1

Acquiring and installing the software 2

Overview of Key Commands 3

Creating a knowledge base 5

Using the Rule Writer Interface 6

Example Decision Table 6

Expected Knowledge Base 7

Acquiring and installing the software

·  All information you need regarding what you can do with this software is available at: http://expertise2go.com/e2g3g/e2g3gdoc/e2gmod2.htm

·  The software is packaged as a zip file accessible at http://expertise2go.com/e2g3g/e2g3gdoc/e2g3g.zip.

·  To install, unzip to a folder you can access easily.

·  The way in which you will be developing, you will running your applications from a web page by including the information that loads the e2gRuleEngine and specifies the knowledge base to be used. This information is included between the html tags (<applet...> to </applet>). When you open this page via a browser, the knowledge base should load and you can interact via the browser.

·  You will be working locally so you do not require a web server.

Navigate to expertis2Go folder (should be available in Applications\Program Files\e2g3g on the lab machines)

You will find:

·  e2gRuleEngine.jar This is a Java Archive (JAR) file containing a set of compiled

Java classes implementing a rule based system shell. You will not need to modify this file.

·  e2gRuleWriter.jar This is a Java Archive containing a set of compiled classes that provide an interface to the rule based system shell to allow you to create knowledge bases.

·  *.kb These are “knowledge base” files, which provides a body of rules to be used by e2g.

·  *.kbt These are decision table files, associated with knowledge bases.

·  weather.kb This is another knowledge base which we will be using later on.

·  *.html This are HTML files that are used for running the e2g applet.

Recommendation: Copy this folder to your own network drive

Overview of Key Commands

Open wine.htm in a browser. This will launch an interaction with the rule engine using the wine.kb knowledge base.

Open wine.kb using a text editor. You will notice the following:

REM statements: These are single line comments, ignored when the knowledge base is processed. The REM command must appear at the beginning of the line, everything following is ignored until the next command is encountered.

Blank lines: Empty lines are optional and are ignored. They may be used to break up the file to make it more readable.

RULE definitions: Possible elements of each rule include:

·  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  An attribute name enclosed in square brackets.

o  A relational operator: = (equal) in the example. The other possibilities include < > ! : representing less-than, greater-than, not-equal-to and equals-any-of.

o  A comparison quantity enclosed in matching single or double quotes if it is a string. Other possiblities are a numeric value or the Boolean values TRUE or FALSE.

·  You can use the logical operators AND or OR if there are multiple logical expressions in the rule premise. If there is more than one premise logical expression, they must all be connected by the same logical operator. Each premise clause consisting of an attribute name, relational operator and comparison quantity is entered on a separate line. The final premise clause must not end with AND or OR.

·  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 assignment statement consisting of:

o  An attribute name enclosed in square brackets

o  The assignment operator (=)

o  The value to be assigned to the attribute: enclosed in matching

o  single or double quotes if it is a string. Other possibilities are a

o  numeric value or the Boolean values TRUE or FALSE.

·  If the value is to be assigned to the attribute with less than 100% certainty, the value is followed by @ and a numeric value between 1 and 100 representing the certainty factor.

·  If there is to be another assignment statement in the rule consequent, end the line with AND. A line in the rule consequent that does not end with AND ends the rule.

Note:

Rule elements are not case sensitive.

Each element of a rule must be on a separate line.

Attributes have one of three types: String (text), numeric and Boolean. An attribute's type is established the first time it is encountered in a rule and is based on the type of the comparison quantity (if first found in a rule premise) or assigned value (if first found in a rule consequent). Any subsequent use of the attribute that implies a different type is an error.

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.

·  Types include MultChoice (multiple choice), Choice (drop down list box), AllChoice (accept multiple responses), YesNo (Boolean input) and Numeric (accept a numeric value).

·  Ending the first line of the PROMPT with CF allows the expert system user to enter a certainty factor when the PROMPT is displayed. If CF is not specified, the user's input will be accepted with 100% certainty.

·  The second line provides the stem of the prompt enclosed in matching single or double quotes. This is the question that will be presented to the expert system user if the PROMPT is invoked by the inference engine.

·  For MultChoice, Choice and AllChoice prompt types, alternate values to be presented to the expert system user are presented on successive lines enclosed in matching single or double quotes, one per line.

·  For the Numeric prompt type, the minimum and maximum values to accept are provided on the next two lines and must be enclosed in matching single or double quotes.

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. The inferencing process ends when all GOALs have been resolved or cannot be resolved.

Open wine.htm. You will see the following

<applet code="e2gRuleEngine" archive="e2gRuleEngine.jar" width=500 height=400>

param name="KBURL" value="wine.kb"> name of knowledge base to use

param name="APPTITLE" value="Budget Wine Selector"> title to give your system

param name="APPSUBTITLE" value="an eXpertise2Go Demonstration"> - additional descriptions

param name="BGCOLOR" value="#990033"> Colours and layout

param name="TITLECOLOR" value="#ffff00">

param name="PROMPTCOLOR" value="#ffffff">

param name="STARTBUTTON" value="Help me choose a wine">

param name="WORDWRAP" value="true">

param name="DEBUG" value="false">

Java-enabled browser required

</applet>

Creating a knowledge base

This is a synopsis of http://expertise2go.com/e2g3g/e2g3gdoc/e2gmod4.htm

Create a file using a text editor, enter the following commands:

REM Test Knowledge Base (weather.kb)

RULE [Is it going to rain?]

If [precipitation] = "expected"

Then [the recommendation] = "wear a raincoat"

PROMPT [precipitation] MultChoice CF

"According to the weather forecast, precipitation is:"

"expected"

"not expected"

GOAL [the recommendation]

Save as weather.kb

Copy one of the htm files in the expertise2Go folder and save as weater.htm

Change the KBURL to weather.kb and change the APPTITLE and APPSUBTITLE parameters to the titles you want.

Open weather.htm in a browser and see how it works.

Using the Rule Writer Interface

Double-click e2gRuleWriter.jar. This will launch the interface to defining your decision table.

Work through defining the conditions, actions and rules.

·  To add a condition, hit add condition

o  You define the Prompt to get the required values with the condition definition

·  To add an action, hit add action

·  To add a rule, highlight the rule column you want to work on, select the values of the conditions and give the rule a name

o  You must define a goal for the system

·  Save both the decision table and the knowledge base (available when entering rules)

Example Decision Table

Here you will be entering rules, the associated prompts and all other information you need to include.

This example assumes that you are in a big city and the goal of this knowledgebase is to be able to decide what mode of transport to take today to get to the university.

The questions relating to the inputs are:

·  Do you need to go to university?

·  Is your car running (does it work)?

·  Do you have adequate petrol?

·  Are you in a hurry?

·  Will your trip occur during rush hour?

·  Has an accident been reported on the motorway?

·  Do you have enough cash?

·  Is it raining?

The inputs for this decision are:

·  Go_uni (yes, no)

·  Car_running (yes, no)

·  Petrol (yes, no)

·  Hurry (yes, no)

·  Rush_hour (yes, no)

·  Accident (yes, no)

·  Cash (yes, no)

·  Rain (yes, no)

The outputs for this decision are:

·  Take a taxi

·  Take a bus

·  Stay home

·  Car on freeway

·  Car on alternative route

The decision tables below show the inputs and outputs for the decision above.

Go uni / Car running / Adequate petrol / hurry / Advice – take the car
Yes / Yes / No / Yes / No
Yes / No / No
Yes / Yes / Yes / Yes
Yes / Yes / No / No / Yes
No / Stay home
Go uni / Car / hurry / Rush hour / Accident / Cash / Rain / Advice on which transport
Yes / Yes / yes / Car on alternative route
Yes / Yes / Yes / Car on alternative route
Yes / Yes / Yes / Car on alternative route
Yes / Yes / No / No / No / Car on freeway
Yes / No / No / bus
Yes / No / No / Yes / Bus or taxi
Yes / No / Yes / Yes / Taxi

Expected Knowledge Base

Your final kb should look like:

REM What transport to take to university based on a number of factors

REM Decide whether to take the car

RULE [go uni, car running, need petrol, hurry]

If [go uni] = "yes" and

[car running] = "yes" and

[adequate petrol] = "no" and

[hurry] = "yes"

Then [car] = "no"

RULE [go uni, car not running]

If [go uni] = "yes" and

[car running] = "no"

Then [car] = "no"

RULE [go uni, car running, don't need petrol]

If [go uni] = "yes" and

[car running] = "yes" and

[adequate petrol] = "yes"

Then [car] = "yes"

RULE [go uni, car running, need petrol, no hurry]

If [go uni] = "yes" and

[car running] = "yes" and

[adequate petrol] = "no" and

[hurry] = "no"

Then [car] = "yes"

RULE [no uni]

If [go uni] = "no"

Then [the recommendation] = "stay home" and

[the action] = "no transport required"

REM Take car. Which route?

RULE [go uni, car, rush hour]

If [car] = "yes" and

[rush hour] = "yes"

Then [the recommendation] = "the motorway will be busy" and

[the action] = "take car on alternative route"

RULE [go uni, car, accident]

If [car] = "yes" and

[accident] = "yes"

Then [the recommendation] = "the motorway will be blocked" and

[the action] = "take car on alternative route"

RULE [go uni, car, rain]

If [car] = "yes" and

[rain] = "yes"

Then [the recommendation] = "the motorway will be slippery" and

[the action] = "car on alternative route"

RULE [go uni, car, no rush hour, no accident, no rain]

If [car] = "yes" and

[rush hour] = "no" and

[accident] = "no" and

[rain] = "no"

Then [the recommendation] = "The motorway should be clear" and

[the action] = "Take the car on the motorway"

REM No car which transport

RULE [go uni, no car, no cash]

If [car] = "no" and

[cash] = "no"

Then [the recommendation] = "Taxi is too expensive" and

[the action] = "Take a bus"

RULE [to uni, no car, cash]

If [car] = "no" and

[hurry] = "yes" and

[cash] = "yes"

Then [the recommendation] = "Need to get their fast" and

[the action] = "Take a taxi"

RULE [to uni, no car, cash, hurry]

If [car] = "no" and

[hurry] = "no" and

[cash] = "yes"

Then [the recommendation] = "You choose the transport" and

[the action] = "Take either a taxi or bus"

REM Prompts

PROMPT [go uni] MultChoice

"Do you need to go to the university?"

"yes"

"no"

PROMPT [car running] MultChoice

"Is your car running (Does it work)?"

"yes"

"no"

PROMPT [adequate petrol] MultChoice

"Do you have adequate petrol?"

"yes"

"no"

PROMPT [hurry] MultChoice

"Are you in a hurry?"

"yes"

"no"

PROMPT [rush hour] MultChoice

"Will the trip occur during rush hour?"

"yes"

"no"

PROMPT [accident] MultChoice

"Has an accident been reported on the motorway?"

"yes"

"no"

PROMPT [rain] MultChoice

"Is it raining?"

"yes"

"no"

PROMPT [cash] MultChoice

"Do you have enough cash?"

"yes"

"no"

GOAL [the recommendation]

GOAL [the action]