NAME

AI::ExpertSystem::Simple - A simple expert system shell

VERSION

This document refers to verion 1.2 of AI::ExpertSystem::Simple, released June 10, 2003

SYNOPSIS

This class implements a simple expert system shell that reads the rules from an XML knowledge base and questions the user as it attempts to arrive at a conclusion.

DESCRIPTION

Overview

This class is where all the work is being done and the other three classes are only there for support. At present there is little you can do with it other than run it. Future version will make subclassing of this class feasable and features like logging will be introduced.

To see how to use this class there is a simple shell in the bin directory which allows you to consult the example knowledge bases and more extensive documemtation in the docs directory.

There is a Ruby version that reads the same XML knowledge bases, if you are interested.

Constructors and initialisation

new( )

The constructor takes no arguments and just initialises a few basic variables.

Public methods

reset( )

Resets the system back to its initial state so that a new consoltation can be run

load( FILENAME )

This method takes the FILENAME of an XML knowledgebase and attempts to parse it to set up the data structures required for a consoltation.

process( )

Once the knowledgebase is loaded the consultation is run by repeatedly calling this method.

It returns four results:

"question"

The system has a question to ask of the user.

The question and list of valid responses is available from the get_question( ) method and the users response should be returned via the answer( ) method.

Then simply call the process( ) method again.

"continue"

The system has calculated some data but has nothing to ask the user but has still not finished.

This response will be removed in future versions.

Simply call the process( ) method again.

"finished"

The consoltation has finished and the system has an answer for the user which is available from the answer( ) method.

"failed"

The consoltation has finished and the system has failed to find an answer for the user. It happens.

get_question( )

If the process( ) method has returned "question" then this method will return the question to ask the user and a list of valid responses.

answer( VALUE )

The user has been presented with the question from the get_question( ) method along with a set of valid responses and the users selection is returned by this method.

get_answer( )

If the process( ) method has returned "finished" then the answer to the users query will be returned by this method.

log( )

Returns a list of the actions undertaken so far and clears the log.

explain( )

Explain how the given answer was arrived at. The explanation is added to the log.

Private methods

_goal

A private method to get the goal data from the knowledgebase.

_rule

A private method to get the rule data from the knowledgebase.

_question

A private method to get the question data from the knowledgebase.

_add_to_log

A private method to add a message to the log.

_explain_this

A private method to explain how a single attribute was set.

ENVIRONMENT

None

DIAGNOSTICS

Simple->new() takes no arguments

When the constructor is initialised it requires no arguments. This message is given if some arguments were supplied.

Simple->reset() takes no arguments

When the method is called it requires no arguments. This message is given if some arguments were supplied.

Simple->load() takes 1 argument

When the method is called it requires one argument. This message is given if more or less arguments were supplied.

Simple->load() argument 1 (FILENAME) is undefined

The corrct number of arguments were supplied with the method call, however the first argument, FILENAME, was undefined.

Simple->load() XML parse failed

XML Twig encountered some errors when trying to parse the XML knowledgebase.

Simple->load() unable to use file

The file supplied to the load( ) method could not be used as it was either not a file or not readable.

Simple->process() takes no arguments

When the method is called it requires no arguments. This message is given if some arguments were supplied.

Simple->get_question() takes no arguments

When the method is called it requires no arguments. This message is given if some arguments were supplied.

Simple->answer() takes 1 argument

When the method is called it requires one argument. This message is given if more or less arguments were supplied.

Simple->answer() argument 1 (VALUE) is undefined

The corrct number of arguments were supplied with the method call, however the first argument, VALUE, was undefined.

Simple->get_answer() takes no arguments

When the method is called it requires no arguments. This message is given if some arguments were supplied.

Simple->log() takes no arguments

When the method is called it requires no arguments. This message is given if some arguments were supplied.

Simple->explain() takes no arguments

When the method is called it requires no arguments. This message is given if some arguments were supplied.

BUGS

None

FILES

See the Simple.t file in the test directory and simpleshell in the bin directory.

SEE ALSO

AI::ExpertSystem::Simple::Goal - A utility class

AI::ExpertSystem::Simple::Knowledge - A utility class

AI::ExpertSystem::Simple::Rule - A utility class

AUTHORS

Peter Hickman (peterhi@ntlworld.com)

COPYRIGHT

Copyright (c) 2003, Peter Hickman. All rights reserved.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.