Project

clips

0.0
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
The C Language Integrated Production System (CLIPS), but in Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.16
~> 10.0
~> 3.0
 Project Readme

CLIPS for Ruby

Build Status

This is a reimplemtation of the CLIPS engine in Ruby, as well as a DSL for working with CLIPS rules.

The inference engine portion of this implementation has been structured to resemble Ruby's standard Set class. While this doesn't mirror the syntax used by the CLIPS language, it does stay true to the underlying functionality of the engine (ie. no duplicate facts).

The C implementation of CLIPS includes a command line shell, however this implementation does not. There are a million ways to make a shell-like interface in Ruby, none of which are appropriate to be included in this gem.

Usage

require 'clips'

clips = CLIPS.new
clips.add 'rule1', CLIPS::Rule.new(:foo, :actions => :bar)
clips.add :rule2, CLIPS::Rule.new(:bar) { puts "Rule 2!" }
clips.add :foo

clips.run	# => "Rule 2!"
clips.facts	# => #<Set: {[:foo], [:bar]}>

Facts and Rules

Facts are represented by Arrays, and Rules are instances of the Rule class. The first element of a fact must always be a Symbol. Rule names can be given as Symbols or Strings, and are converted to Symbols internally.

Default Facts

Named sets of default facts can be added to the engine. When reset is called, the default facts are asserted as facts.

clips.default_facts['my_defaults'] = Set[[:foo], [:bar]]
clips.facts	# => #<Set: {}>
...
clips.reset
clips.facts	# => #<Set: {[:foo], [:bar]}>

To remove a set of default facts, use the normal Hash delete method.

clips.default_facts.delete('my_defaults')

Installation

Add this line to your application's Gemfile:

gem 'clips'

And then execute:

$ bundle

Or install it yourself as:

$ gem install clips

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in clips.gemspec, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.