Skip to content

Commit

Permalink
Merge branch 'release-1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nilp0inter committed Mar 29, 2017
2 parents c0e96ed + 49aed54 commit d0e681a
Show file tree
Hide file tree
Showing 82 changed files with 7,250 additions and 2,661 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ docs/_build/
# PyBuilder
target/
.hypothesis/
.*.sw?

# Jupyter notebook checkpoints
.ipynb_checkpoints
19 changes: 10 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
language: python
python: 3.4
env:
- TOX_ENV=py34
python:
- "3.4"
- "3.5"
- "3.6"
install:
- pip install -r requirements/tox.txt
- pip install coveralls
- pip install -r requirements/develop.txt
- pip install codecov
- python setup.py develop
script:
- tox -e $TOX_ENV
- pycodestyle --show-source --show-pep8 pyknow
- coverage run $(which py.test) -m 'not wip' -v tests/unit
after_success:
- coverage combine
- coverage report
- coveralls
- codecov
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1.0.0
+++++

* RETE matching algorithm.
* Better Rule decorator system.
* Facts are dictionaries.
* Documentation.

<1.0.0
++++++

* Unestable API.
* Wrong matching algorithm.
* Bad performance
* PLEASE DON'T USE THIS.
79 changes: 54 additions & 25 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,37 +1,66 @@
PyKnow
======
PyKnow: Expert Systems for Python
=================================

Pure Python knowledge-based inference engine (inspired by CLIPS).
.. image:: https://img.shields.io/pypi/v/pyknow.svg
:target: https://pypi.python.org/pypi/pyknow

.. image:: https://img.shields.io/pypi/l/pyknow.svg
:target: https://pypi.python.org/pypi/pyknow

Why?
----
.. image:: https://img.shields.io/pypi/pyversions/pyknow.svg
:target: https://pypi.python.org/pypi/pyknow

There are a few ways to use CLIPS directly within python (such as pyclips),
but those are actually using CLIPS behind and does not allow you to provide
custom RHS in python. Also, you need to write the code in CLIPS and call
it within python, wich is not very pythonic.
.. image:: https://travis-ci.org/buguroo/pyknow.svg?branch=master
:target: https://travis-ci.org/buguroo/pyknow

.. image:: https://readthedocs.org/projects/pyknow/badge/?version=latest
:target: https://readthedocs.org/projects/pyknow/?badge=latest
:alt: Documentation Status

How
---
.. image:: https://codecov.io/gh/buguroo/pyknow/branch/develop/graph/badge.svg
:target: https://codecov.io/gh/buguroo/pyknow
:alt: codecov.io

We are trying to get an implementation as close as possible to CLIPS.
That means most of our examples and docs are direct references to CLIPs
reference manual or their examples

PyKnow is a Python library for building expert systems strongly inspired
by CLIPS_.

Example
-------
.. code-block:: python
::
from random import choice
from pyknow import *
class MyKnowledgeEngine(KnowledgeEngine):
@Rule(Fact(a=L(1)))
def my_rhs(self):
pass
engine = MyKnowledgeEngine()
engine.reset()
engine.declare(Fact(a=L(1)))
engine.run()
class Light(Fact):
"""Info about the traffic light."""
pass
class RobotCrossStreet(KnowledgeEngine):
@Rule(Light(color='green'))
def green_light(self):
print("Walk")
@Rule(Light(color='red'))
def red_light(self):
print("Don't walk")
@Rule('light' << Light(color=L('yellow') | L('blinking-yellow')))
def cautious(self, light):
print("Be cautious because light is", light["color"])
.. code-block:: python
>>> engine = RobotCrossStreet()
>>> engine.reset()
>>> engine.declare(Light(color=choice(['green', 'yellow', 'blinking-yellow', 'red'])))
>>> engine.run()
Be cautious because light is blinking-yellow
You can find some more examples on GitHub_.

.. _CLIPS: http://clipsrules.sourceforge.net
.. _GitHub: https://github.com/buguroo/pyknow/tree/develop/docs/examples

24 changes: 2 additions & 22 deletions TODO.rst
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
Activations / Capturations problems
-----------------------------------
TODO
====

Currently, we make the product of the capturations against
the activations to match facts against other activations.

That means this::

Rule(Fact(a=C('a')), Fact(b=V('a')))

declare(Fact(a=1))
declare(Fact(b=1))

Would work nicely, but this::

Rule(Fact(a=C('a'), b=V('a')))

declare(Fact(a=1, b=1))
declare(Fact(a=1, b=3))


Will launch 2 activations, as it will try to match fact 2 against fact 1's extracted
context, and it'll match.
Loading

0 comments on commit d0e681a

Please sign in to comment.