Skip to content

Commit

Permalink
Added example in README
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
  • Loading branch information
noxdafox committed Oct 5, 2017
1 parent a4cf09d commit d63176a
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,49 @@ The CLIPS shared library and headers must be installed within the system.

If library and headers are not in the system default locations, they can be specified to the installer via the ``CFLAGS`` and ``LDFLAGS`` environment variables.

::
.. code:: bash
# CFLAGS="-I<headers path>" LDFLAGS="-L<library path>" pip install pyclips
Example
-------

.. code:: python
from clips import Environment, Symbol
environment = Environment()
# load constructs into the environment
environment.load('constructs.clp')
# assert a fact as string
environment.facts.assert_string('(a-fact)')
# retrieve a fact template
template = environment.facts.find_template('a-fact')
# create a new fact from the template
fact = template.new_fact()
# implied (ordered) facts are accessed as lists
fact.append(42)
fact.extend(("foo", "bar"))
# assert the fact within the environment
fact.assertit()
# retrieve another fact template
template = environment.facts.find_template('another-fact')
fact = template.new_fact()
# template (unordered) facts are accessed as dictionaries
fact["slot-name"] = Symbol("foo")
fact.assertit()
# execute the activations in the agenda
environment.agenda.run()
.. _CLIPS: http://www.clipsrules.net/

0 comments on commit d63176a

Please sign in to comment.