Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Tree [af73bc] default /
History



File Date Author Commit
Test 2009-10-28 mtnyogi mtnyogi [cde070] Automated merge with file:///home/bruce/python/...
doc 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...
examples 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...
experimental 2009-10-28 mtnyogi mtnyogi [efe1d1] merge with release_1 test changes
pyke 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...
.hgignore 2009-10-20 mtnyogi mtnyogi [c237fe] Automated merge with file:///home/bruce/python/...
.hgtags 2009-10-20 mtnyogi mtnyogi [c237fe] Automated merge with file:///home/bruce/python/...
HTMLTemplate.py 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...
MANIFEST.in 2009-10-28 mtnyogi mtnyogi [efe1d1] merge with release_1 test changes
README 2009-10-28 mtnyogi mtnyogi [efe1d1] merge with release_1 test changes
README-3.x 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...
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
RELEASE_NOTES-0.6 2008-12-31 mtnyogi mtnyogi [a022d9] - Checking in Release documentation for 0.6 rel...
RELEASE_NOTES-0.7 2009-01-17 mtnyogi mtnyogi [500e14] - Preparing release 0.7
RELEASE_NOTES-1.0 2009-03-18 mtnyogi mtnyogi [dce036] Preparing release 1.0
RELEASE_NOTES-1.0.1 2009-04-03 mtnyogi mtnyogi [361e09] Merged in changes from trunk, through r233.
RELEASE_NOTES-1.0.2 2009-04-21 mtnyogi mtnyogi [39689d] Merged in changes related to release 1.0.2 from...
RELEASE_NOTES-1.0.3 2009-10-20 mtnyogi mtnyogi [c237fe] Automated merge with file:///home/bruce/python/...
copyright_license 2007-10-15 mtnyogi mtnyogi [9cc939] Added svn:keywords properties. Some work on doc...
hgrc_keywords 2009-10-20 mtnyogi mtnyogi [c237fe] Automated merge with file:///home/bruce/python/...
make_doc_tarball 2009-10-20 mtnyogi mtnyogi [c237fe] Automated merge with file:///home/bruce/python/...
make_examples_tarball 2009-10-20 mtnyogi mtnyogi [c237fe] Automated merge with file:///home/bruce/python/...
run_2to3 2009-10-28 mtnyogi mtnyogi [5282b4] Removed "hg revert doctest_file.py ez_setup.py"...
run_pre_test 2009-11-04 mtnyogi mtnyogi [af73bc] Changed pyke3.1 to pyke3 for zip prefix in run_...
setup.py 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...
testall 2009-10-28 mtnyogi mtnyogi [29e965] Automated merge with file:///home/bruce/python/...

Read Me

Pyke: Python Knowledge Engine

Version: 1.0.3

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
rules.

COPYRIGHT AND LICENSE:

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

DOCUMENTATION:

The documentation is at:

    http://pyke.sourceforge.net

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

    pyke_doc_html-1.0.3.tar.gz

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


INSTALLATION:

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

    $ python --version

You can download this at:

    http://www.python.org

There is another branch of Pyke that is ready for Python3.x.  If you want
Python3.x support, read this:

    http://pyke.hg.sourceforge.net/hgweb/pyke/pre_2to3/file/8788b112f5f6/README-3.x

Otherwise (if you want Pyke on Python2.5 or later 2.x release)...

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

    $ easy_install pyke

If you don't have easy_install, you can install it by looking at:

    http://pypi.python.org/pypi/setuptools/

Then you've got two choices for pyke:

    pyke-1.0.3-py2.5.egg or pyke-1.0.3-py2.6.egg (used by easy_install)
 or the source distribution (see next section)


SOURCE DISTRIBUTION:

The pyke source distribution is the file:

    pyke-1.0.3.tar.gz

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

EXAMPLES:

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

    pyke_examples-1.0.3.tar.gz

You need to unpack this into a directory that is on your PYTHON PATH.

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
problem.

The sqlgen example uses Sqlite3 (or MySQL) and the python sqlite3 (or MySQLdb)
modules.  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
statements 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 (install this with "easy_install HTMLTemplate", be sure to
get version 1.5 or later).  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 makes it run a full 10 times faster than the same
example done in TurboGears 2!  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.


TO INSTALL FROM THE SOURCES:

    $ python setup.py install


RUNNING DOCTESTS:

Pyke uses the doctest-tools package to run its doctests.  You can run the
"testall" program from doctest-tools in any subdirectory, or in the top-level
directory.  You can install doctest-tools with:

    $ sudo easy-install doctest-tools

The top-level directory also has it's own "testall" script that removes all
compiled_krb directories, then runs the standard testall scripts twice.  The
first time forces pyke to recompile everything, and the second time runs the
same tests again having pyke re-use the compiled results from the previous
run.  This "testall" program should not be on your path, so run it as:

    $ ./testall

to distinguish it from the "testall" program installed with doctest-tools.


COMPILING kfbparser_tables.py, krbparser_tables.py and scanner_tables.py:

    $ python
    >>> from pyke.krb_compiler import kfbparser, krbparser, scanner
    >>> scanner.init(scanner, 0, True)
    >>> krbparser.init(krbparser, True)
    >>> kfbparser.init(kfbparser, True)

    or just run the "testall" program from the doctest-tools package:

    $ cd pyke/krb_compiler
    $ testall


COMPILING THE COMPILER.KRB FILE:

In pyke/krb_compiler:

    $ PYTHONPATH=../.. python
    >>> from pyke import krb_compiler
    >>> krb_compiler.compile_krb('compiler', 'compiled_krb', 'compiled_krb', 'compiler.krb')
    $ mv compiled_krb/compiler_bc.py .

COMPILING THE DOCUMENTATION:

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 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:

    $ python
    >>> 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:

    http://sourceforge.net/projects/docutils
    http://sourceforge.net/projects/rest2web

To regenerate the html:

    $ cd doc/source
    $ bin/gen_html

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

If you want to run doctest on all of the *.txt files in doc/source, use the
"testall" program from the doctest-tools package:

    $ cd doc
    $ testall