RbClips is a binary extension for Ruby language (MRI version), that allow you to use expert system tool CLIPS in your Ruby app.
I’m supposing that you’re already familiar with CLIPS tool and it’s user interface. Entire interface of rbClips have similar approach as ActiveRecord project.
Working with templates is done via Template class.
Example:
human_template = Template.new "human" do |s| s.slot name s.slot surname s.slot age, :constraint => { :type => :integer, :range => 0..120 } end
Facts are wrapped by Fact class - both ordered and nonordered
Example with ordered facts:
Fact.new "animal", ["dog"] Fact.new "child-f", %w(dog puppy)
Example with nonordered facts:
Fact.new human_template, :name => "Kocour", :surname => "Mikes", :age => 30
Entire work with rules is wrapped into Rule class.
Example:
mammal1 = Rule.new "mammal" do |r| r.pattern 'animal', :name r.pattern 'warm-blooded', :name r.not do |n| n.pattern 'lays-eggs', :name end r.assert 'mammal', :name end
# Load binary extension into memory require 'Clips' # Put it into local scope (avoid writing Clips:: before everything) include 'Clips' # Create facts Fact.new('animal', %w(dog)).save Fact.new('animal', %w(cat)).save Fact.new('animal', %w(duck)).save Fact.new('animal', %w(turtle)).save Fact.new('warm-blooded', %w(dog)).save Fact.new('warm-blooded', %w(cat)).save Fact.new('warm-blooded', %w(duck)).save Fact.new('lays-eggs', %w(duck)).save Fact.new('lays-eggs', %w(turtle)).save Fact.new('child-of', %w(dog puppy)).save Fact.new('child-of', %w(cat kitten)).save Fact.new('child-of', %w(tutrle hatchling)).save # First rule mammal1 = Rule.new "mammal" do |r| r.pattern 'animal', :name r.pattern 'warm-blooded', :name r.not do |n| n.pattern 'lays-eggs', :name end r.assert 'mammal', :name end mammal1.save # Second rule mammal2 = Rule.new "childs" do |r| r.pattern 'mammal', :name r.pattern 'child-of', :name, :young r.assert 'mammal', :young end mammal2.save # Run the app Base.run
Documentation can be build from source codes using Doxygen tool. To build documentation just run “doxygen” command in doc/doxygen subdirectory.
Project is licensed under ASLv2.