https://github.com/noxdafox/clipspy
Python CFFI bindings for the 'C' Language Integrated Production System CLIPS
https://github.com/noxdafox/clipspy
artificial-intelligence cffi clips expert-system python
Last synced: 5 months ago
JSON representation
Python CFFI bindings for the 'C' Language Integrated Production System CLIPS
- Host: GitHub
- URL: https://github.com/noxdafox/clipspy
- Owner: noxdafox
- License: bsd-3-clause
- Created: 2017-09-24T16:06:11.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-17T20:53:29.000Z (7 months ago)
- Last Synced: 2025-04-19T02:14:54.143Z (6 months ago)
- Topics: artificial-intelligence, cffi, clips, expert-system, python
- Language: Python
- Homepage:
- Size: 303 KB
- Stars: 185
- Watchers: 13
- Forks: 35
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
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 badge| |docs badge|
.. |build badge| image:: https://github.com/noxdafox/clipspy/actions/workflows/linux-wheels.yml/badge.svg
:target: https://github.com/noxdafox/clipspy/actions/workflows/linux-wheels.yml
:alt: Build Status
.. |docs badge| image:: https://readthedocs.org/projects/clipspy/badge/?version=latest
:target: http://clipspy.readthedocs.io/en/latest/?badge=latest
:alt: Documentation StatusInitially 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.
.. code:: bash
$ pip install clipspy
macOS
+++++Apple Intel and Silicon are supported for Python versions starting from 3.9.
.. code:: bash
$ pip install clipspy
Windows
+++++++CLIPSPy comes as a wheel for Python versions starting from 3.9.
.. code:: batch
> 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.
.. code:: bash
$ make
# make installPlease check the documentation_ for more information regarding building CLIPSPy from sources.
Example
-------.. code:: python
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().. _CLIPS: http://www.clipsrules.net/
.. _CFFI: https://cffi.readthedocs.io/en/latest/index.html
.. _PEP-513: https://www.python.org/dev/peps/pep-0513/
.. _PEP-656: https://peps.python.org/pep-0656/
.. _documentation: https://clipspy.readthedocs.io