AI::ExpertSystem::Advanced::KnowledgeDB::Base - Base class for knowledge DBs.
All knowledge databases that 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.
This hash has the rules contained in the knowledge database. It's populated when an instance of AI::ExpertSystem::Advanced::KnowledgeDB::Base is created.
TIP: There's no sense in filling this hash if you are going to be using a database engine such as MySQL, SQLite or others. The hash is useful if your knowledge database will remain in application memory.
Similar and same concept of rules, but this will have a list (if available) of what questions should be done to certain facts.
rules
This method reads the knowledge database. This is the only method you need to define even if you are going to load the database in memory or if you are going to query it.
Returns all the goals (usually only one) of the given $rule.
$rule
The goals should be returned as a AI::ExpertSystem::Advanced::Dictionary.
NOTE: Rewrite this method if you are not going to use the rules hash (eg, you will use a database engine).
Returns all the causes of the given $rule.
Same as rule_goals(), the causes should be returned as a AI::ExpertSystem::Advanced::Dictionary.
rule_goals()
Looks for the first rule that has the given goal in its goals.
goal
If a rule is found then its number is returned, otherwise undef is returned.
undef
Looks for a question about the given $fact. If a question exists then this is returned, otherwise undef is returned.
$fact
Returns the ID of the next rule. When there are no more rules to work then undef should be returned.
When it starts looking for the first rule, $current_rule value will be undef.
$current_rule
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.
To install AI::ExpertSystem::Advanced, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::ExpertSystem::Advanced
CPAN shell
perl -MCPAN -e shell install AI::ExpertSystem::Advanced
For more information on module installation, please visit the detailed CPAN module installation guide.