-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
82 changed files
with
7,250 additions
and
2,661 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,7 @@ docs/_build/ | |
# PyBuilder | ||
target/ | ||
.hypothesis/ | ||
.*.sw? | ||
|
||
# Jupyter notebook checkpoints | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.