Tree [fe1a23] default /

Read Only access

File Date Author Commit
 Test 2008-11-22 mtnyogi mtnyogi [9b9741] Fixed bug when there are no facts in a fact lis...
 doc 2008-11-22 mtnyogi mtnyogi [9b9741] Fixed bug when there are no facts in a fact lis...
 examples 2008-12-27 mtnyogi mtnyogi [fe1a23] - Looks like sqlite3 conversion is working now....
 experimental 2008-08-30 mtnyogi mtnyogi [97f053] Commit in preperation for release.
 pyke 2008-12-25 mtnyogi mtnyogi [2825a9] - Changed initialization of PLY lex and yacc to...
 README 2008-11-10 mtnyogi mtnyogi [b3a32d] Release 0.5
 RELEASE_NOTES-0.1.alpha1 2007-11-09 mtnyogi mtnyogi [141a36] First try at 0.1.alpha1
 RELEASE_NOTES-0.1.alpha2 2008-02-13 mtnyogi mtnyogi [66bbff] This should be the alpha2 release!
 RELEASE_NOTES-0.2 2008-03-06 mtnyogi mtnyogi [5a44bd] Release 0.2
 RELEASE_NOTES-0.3 2008-06-08 mtnyogi mtnyogi [4ca57f] Release 0.3
 RELEASE_NOTES-0.4 2008-08-30 mtnyogi mtnyogi [00a03b] Final commit for release 0.4.
 RELEASE_NOTES-0.5 2008-11-09 mtnyogi mtnyogi [1b9ce9] - finished RELEASE_NOTES-0.5
 copyright_license 2007-10-15 mtnyogi mtnyogi [9cc939] Added svn:keywords properties. Some work on doc... 2008-09-24 mtnyogi mtnyogi [2bb500] - updated documentation to reflect the changes ... 2007-11-09 mtnyogi mtnyogi [141a36] First try at 0.1.alpha1
 make_doc_tarball 2008-02-13 mtnyogi mtnyogi [66bbff] This should be the alpha2 release!
 make_examples_tarball 2008-03-07 mtnyogi mtnyogi [0bd686] Added examples tarball to sourceforge downloads. 2008-12-27 mtnyogi mtnyogi [fe1a23] - Looks like sqlite3 conversion is working now....
 testall 2008-05-05 mtnyogi mtnyogi [ed186b] Added Test directory with testTest script, call...

Read Me

Pyke: Python Knowledge Engine

Version: 0.5

Both forward-chaining and backward-chaining rules (which may include python
code) are compiled into python. Can also automatically assemble python
programs out of python functions which are attached to backward-chaining


This is published under the MIT License.  The copyright and license are in
the file "copyright_license".


The documentation is at:

You can download a copy of this documentation to your hard drive:


See the end of this file for how to regenerate the html files.


Pyke requires python 2.5 (or later 2.x release).  Check with:

    $ python2.5 --version
 or $ python --version

You can download this at:

To install pyke with easy_install, at the shell prompt just type:

    $ easy_install-2.5 pyke

If you don't have easy_install, you should install it:

    then (as root) run: $ python2.5

Otherwise, you'll also need ply 2.3 or later from:

This can be checked as follows:

    $ python2.5
    >>> from ply import lex
    >>> lex.__version__

Then you got two choices for pyke:

 or the source distribution (see below)


The pyke source distribution is the file:


This contains the pyke source code, documentation (both source and html), and


Pyke examples may be downloaded separately from sourceforge if you've used
easy_install to install pyke (or installed the .egg file):


Each example has a README file that explains how to run it.

The family_relations example is a good place to start.  It shows several
solutions to the same problem.  It also has an example of a few rule
optimizations that result in a 100 times performance improvement on this

The sqlgen example uses MySQL and the python MySQLdb module.  It has a
function that reads the schema information into pyke facts.  Then the rules in
database.krb automatically figure out how to join tables together to retrieve
a list of column names, generate the SQL select statement and return a plan to
execute this SQL statement and return the results as a dictionary.

The web_framework example uses the sqlgen example.  This demonstrates the use
of multiple rule bases.  The web_framework is a WSGI application that uses the
HTMLTemplate package.  It gets the column names from the HTMLTemplate and
feeds those to the sqlgen example to generate a plan to retrieve the data.  It
then builds a plan to populate the template and return the finished HTML
document.  It also caches the plans so that they don't have to be re-generated
for each request.  This should make this run very fast!  The example includes
a wsgiref simple_server setup to run it as an http server so that you can
access it through your browser.

The learn_pyke example is an incomplete attempt at a computer based training
program.  It only deals with the topic of pattern matching.  It is left here
as an example of using question bases.

The findall, forall, knapsack, notany and towers_of_hanoi examples are each
very small.


    $ python2.5 install


To run doctests on all *.py files in the pyke directory, cd to the pyke
directory and:

    $ ./testpyke

To run doctests on the whole source directory, cd to the top-level directory

    $ ./testall


In pyke/krb_compiler:

    $ python2.5
    >>> from pyke import krb_compiler
    >>> krb_compiler.compile('.', 'compiled_krb', ('compiler.krb',))
    $ cp compiled_krb/ .
    $ rm -rf compiled_krb


To compile the documentation into html, you'll need docutils and rest2web.
If you're running linux, your distro may have packages for these already.
Or you can:

    $ easy_install-2.5 rest2web

I used version 0.4.1 of docutils and 0.5.0 of rest2web.  I don't know if
earlier versions work OK or not.

To check your versions:

    $ python2.5
    >>> import docutils
    >>> docutils.__version__
    >>> import rest2web
    >>> rest2web.__version__

If your linux distro doesn't have packages for these, and you don't want to
use easy_install, you can get them at:

To regenerate the html:

    $ cd doc/source
    $ bin/gen_html

This regenerates everything from doc/source into doc/html.  It takes about
8 seconds to run.

If you want to run doctest on all of the *.txt files in doc/source:

    $ cd doc
    $ ./testdocs