AI-ExpertSystem-Advanced

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

        This dictionary (see AI::ExpertSystem::Advanced::Dictionary has the
        sasme data of initial_facts but with the additional feature(s) of
        proviing iterators and a quick way to find elements.

    goals_to_check
            my $ai = AI::ExpertSystem::Advanced->new(
                    viewer_class => 'terminal',
                    knowledge_db => $yaml_kdb,
                    goals_to_check => ['J']);

        When doing the backward() algorithm it's required to have at least
        one goal (aka hypothesis).

        This could be pretty similar to initial_facts, with the difference
        that the initial facts are used more with the causes of the rules
        and this one with the goals (usually one in a well defined knowledge
        database).

        The same rule of initial_facts apply here, you can provide the sign
        of the facts and you can provide the id or the name of them.

README  view on Meta::CPAN

    (eg that a patient has *X* disease). However in case there's still no
    clue, then a set of questions (done by the call of backward()) of
    symptons related to the initial symptoms will be asked to the user. For
    example, we know that that the patient has a headache but that doesn't
    give us any positive answer, what if the patient has flu or another
    disease? Then a set of these *related* symptons will be asked to the
    user.

  summary($return)
    The main purpose of any expert system is the ability to explain: what is
    happening, how it got to a result, what assumption(s) it required to
    make, the fatcs that were excluded and the ones that were used.

    This method will use the viewer (or return the result) in YAML format of
    all the rules that were shot. It will explain how it got to each one of
    the causes so a better explanation can be done by the viewer.

    If $return is defined (eg, it got any parameter) then the result wont be
    passed to the viewer, instead it will be returned as a string.

SEE ALSO

inc/Module/Install/Win32.pm  view on Meta::CPAN

	$self->load('get_file');

	require Config;
	return unless (
		$^O eq 'MSWin32'                     and
		$Config::Config{make}                and
		$Config::Config{make} =~ /^nmake\b/i and
		! $self->can_run('nmake')
	);

	print "The required 'nmake' executable not found, fetching it...\n";

	require File::Basename;
	my $rv = $self->get_file(
		url       => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
		ftp_url   => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
		local_dir => File::Basename::dirname($^X),
		size      => 51928,
		run       => 'Nmake15.exe /o > nul',
		check_for => 'Nmake.exe',
		remove    => 1,

lib/AI/ExpertSystem/Advanced.pm  view on Meta::CPAN

        is => 'ro',
        isa => 'AI::ExpertSystem::Advanced::Dictionary');

=item B<goals_to_check>

    my $ai = AI::ExpertSystem::Advanced->new(
            viewer_class => 'terminal',
            knowledge_db => $yaml_kdb,
            goals_to_check => ['J']);

When doing the L<backward()> algorithm it's required to have at least one goal
(aka hypothesis).

This could be pretty similar to L<initial_facts>, with the difference that the
initial facts are used more with the causes of the rules and this one with
the goals (usually one in a well defined knowledge database).

The same rule of L<initial_facts> apply here, you can provide the sign of the
facts and you can provide the id or the name of them.

From our example of symptoms and diseases lets imagine we have the hypothesis

lib/AI/ExpertSystem/Advanced.pm  view on Meta::CPAN

       
=item B<knowledge_db>

The object reference of the knowledge database L<AI::ExpertSystem::Advanced> is
using.

=cut
has 'knowledge_db' => (
        is => 'rw',
        isa => 'AI::ExpertSystem::Advanced::KnowledgeDB::Base',
        required => 1);

=item B<asked_facts>

During the L<backward()> algorithm there will be cases when there's no clarity
if a fact exists. In these cases the L<backward()> will be asking the user
(via automation or real questions) if a fact exists.

Going back to the L<initial_facts> example of symptoms and diseases. Imagine
the algorithm is checking a rule, some of the facts of the rule make a match
with the ones of L<initial_facts> or L<inference_facts> but some wont, for

lib/AI/ExpertSystem/Advanced.pm  view on Meta::CPAN

                }
            }
        }
        $self->forward();
    }
}

=head2 B<summary($return)>

The main purpose of any expert system is the ability to explain: what is
happening, how it got to a result, what assumption(s) it required to make,
the fatcs that were excluded and the ones that were used.

This method will use the L<viewer> (or return the result) in YAML format of all
the rules that were shot. It will explain how it got to each one of the causes
so a better explanation can be done by the L<viewer>.

If C<$return> is defined (eg, it got any parameter) then the result wont be
passed to the L<viewer>, instead it will be returned as a string.

=cut

lib/AI/ExpertSystem/Advanced/KnowledgeDB/Base.pm  view on Meta::CPAN


=head1 NAME

AI::ExpertSystem::Advanced::KnowledgeDB::Base - Base class for knowledge DBs.

=head1 DESCRIPTION

All knowledge databases that L<AI::ExpertSystem::Advanced> uses should extend
from this class.

This base class implements the basic methods required for extracting the rules,
causes, goals and questions from the a plain text knowledge database, eg, all
the records remain in the application memory instead of a database engine such
as MySQL or SQLite.

=cut
use Moose;
use AI::ExpertSystem::Advanced::Dictionary;

our $VERSION = '0.03';

lib/AI/ExpertSystem/Advanced/KnowledgeDB/YAML.pm  view on Meta::CPAN

=item B<filename>

YAML file path to read

=back

=cut
has 'filename' => (
        is => 'rw',
        isa => 'Str',
        required => 1);

# Called when the object gets created
sub BUILD {
    my ($self) = @_;

    my $data = LoadFile($self->{'filename'});
    if (defined $data->{'rules'}) {
        $self->{'rules'} = $data->{'rules'}
    } else {
        confess "Couldn't find any rules in $self->{'filename'}";

lib/AI/ExpertSystem/Advanced/Viewer/Base.pm  view on Meta::CPAN

C<@options> cause otherwise L<AI::ExpertSystem::Advanced> will die.

=cut
sub ask {
    confess NO_ABSTRACT_CLASS_MSG;
}

=head2 B<explain($yaml_summary)>

Used to explain what happened. The passed argument is a YAML string that has
all the information required to make a good explanation.

=cut
sub explain {
    confess NO_ABSTRACT_CLASS_MSG;
}

=head1 AUTHOR
 
Pablo Fischer (pablo@pablo.com.mx).

lib/AI/ExpertSystem/Advanced/Viewer/Factory.pm  view on Meta::CPAN

# Created: 11/29/2009 19:12:25 PST 19:12:25
package AI::ExpertSystem::Advanced::Viewer::Factory;

=head1 NAME

AI::ExpertSystem::Advanced::Viewer::Factory - Viewer factory

=head1 DESCRIPTION

Uses the factory pattern to create viewer instances. The viewer instances are
useful (and required) to show data to the user.

=cut
use strict;
use warnings;
use Class::Factory;
use base qw(Class::Factory);

our $VERSION = '0.01';

sub new {



( run in 0.425 second using v1.01-cache-2.11-cpan-0a6323c29d9 )