| AI-ExpertSystem-Advanced documentation | Contained in the AI-ExpertSystem-Advanced distribution. |
AI::ExpertSystem::Advanced::KnowledgeDB::YAML - YAML Knowledge DB driver
A YAML knowledge database driver.
It reads a given YAML file and looks for the rules hash key. All of the
elements of rules (causes and goals) are copied to the rules hash
key of AI::ExpertSystem::Advanced::KnowledgeDB::Base.
If no rules are found then it ends unsuccessfully.
It also looks for any available questions under the questions hash key, however if no questions are found then they are not copied :-)
YAML file path to read
Pablo Fischer (pablo@pablo.com.mx).
Copyright (C) 2010 by Pablo Fischer.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| AI-ExpertSystem-Advanced documentation | Contained in the AI-ExpertSystem-Advanced distribution. |
# # AI::ExpertSystem::Advanced::KnowledgeDB::YAML # # Author(s): Pablo Fischer (pfischer@cpan.org) # Created: 12/13/2009 16:12:43 PST 16:12:43 package AI::ExpertSystem::Advanced::KnowledgeDB::YAML;
use Moose; use YAML::Syck; extends 'AI::ExpertSystem::Advanced::KnowledgeDB::Base'; our $VERSION = '0.01';
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'}"; } if (defined $data->{'questions'}) { $self->{'questions'} = $data->{'questions'}; } }
1;