Skip to content

Python CFFI bindings for the 'C' Language Integrated Production System CLIPS

License

Notifications You must be signed in to change notification settings

noxdafox/clipspy

Folders and files

NameName
Last commit message
Last commit date
Mar 16, 2025
Mar 17, 2025
Feb 3, 2025
Nov 3, 2021
Mar 17, 2025
Oct 14, 2019
Apr 6, 2020
May 7, 2023
May 7, 2023
Dec 25, 2017
Feb 16, 2025
Feb 15, 2025
Feb 17, 2025
Oct 14, 2019
Feb 3, 2025

CLIPS Python bindings

Python CFFI bindings for the 'C' Language Integrated Production System CLIPS 6.42.

Source:https://github.com/noxdafox/clipspy
Documentation:https://clipspy.readthedocs.io
Download:https://pypi.python.org/pypi/clipspy

Build Status Documentation Status

Initially developed at NASA's Johnson Space Center, CLIPS is a rule-based programming language useful for creating expert and production systems where a heuristic solution is easier to implement and maintain than an imperative one. CLIPS is designed to facilitate the development of software to model human knowledge or expertise.

CLIPSPy brings CLIPS capabilities within the Python ecosystem.

Installation

Linux

On Linux CLIPSPy is packaged for x86_64 and aarch64 architectures as a wheel according to PEP-513 guidelines. PEP-656 is supported solely for x86_64 at the moment. Minimum Python version is 3.9.

$ pip install clipspy

macOS

Apple Intel and Silicon are supported for Python versions starting from 3.9.

$ pip install clipspy

Windows

CLIPSPy comes as a wheel for Python versions starting from 3.9.

> pip install clipspy

Building from sources

The provided Makefiles take care of retrieving the CLIPS source code and compiling the Python bindings together with it.

$ make
# make install

Please check the documentation for more information regarding building CLIPSPy from sources.

Example

import clips

DEFTEMPLATE_STRING = """
(deftemplate person
  (slot name (type STRING))
  (slot surname (type STRING))
  (slot birthdate (type SYMBOL)))
"""

DEFRULE_STRING = """
(defrule hello-world
  "Greet a new person."
  (person (name ?name) (surname ?surname))
  =>
  (println "Hello " ?name " " ?surname))
"""

environment = clips.Environment()

# define constructs
environment.build(DEFTEMPLATE_STRING)
environment.build(DEFRULE_STRING)

# retrieve the fact template
template = environment.find_template('person')

# assert a new fact through its template
fact = template.assert_fact(name='John',
                            surname='Doe',
                            birthdate=clips.Symbol('01/01/1970'))

# fact slots can be accessed as dictionary elements
assert fact['name'] == 'John'

# execute the activations in the agenda
environment.run()