wwaites / swipy

SWI Prolog Python Bindings and RDFLib Store
http://github.com/wwaites/swipy
GNU General Public License v3.0
7 stars 2 forks source link

== Python bindings for SWI-Prolog == ... and store for RDFLib

This packages provides a generic interface to the SWI Prolog from Python. The main motivation for it was the promise of a reasoning RDF store that could be used with RDFLib.

is similar to the similarly named package pyswip except that pyswip pyswip uses ctypes to interface with the SWI-Prolog shared library and we build a C module using Cython.

The package provides two modules, the first, swi' contains the low-level interface to prolog. The secondswipy' provides the store that is compatible with RDFLib. To this end it bundles the SeRQL package from Clio Patria which provides a SPARQL query interface with entailment and the Henry package which provides Notation 3 parsing and entailment.

== Installing ==

Requirements:

* SWI-Prolog 3.8.0 or newer
* Cython version 0.12 or newer
* RDFLib 2.5 or SVN (for using the RDFLib Store)

On Mac OSX or other BSD systems it should be sufficient to install SWI-Prolog from the ports (macports) tree. This is the case as well on Gentoo Linux which uses a similar packaging infrastructure.

I have not had very much success on Debian and Debian based systems such as Ubuntu Linux with the pre-packaged binaries. It is recommended to build SWI-Prolog from source in this case.

If you intend to use the RDF store's native (SeRQL) SPARQL query interface or the Henry N3 entailment modules it is important to build SWI-Prolog with the XPCE package. XPCE contains the regex routines used by the serql(sparql) and henry(n3_load).

Make sure swipl' orpl' is in your path, then,

python setup.py build
python setup.py install

== Testing ==

nosetests -v -s tests

## and look at some of the test cases for ideas how
## to use

== Using ==

from swipy.store import SWIStore
from rdflib.graph import Graph

g = Graph(SWIStore())
g.store.entailment = "n3"

etc ...

Note that there are essentially two modes of operation of the store, normal' where it behaves like any named graph aware store andentailing' which is enabled by setting the entailment property on the store object to a non-null value (the name of one of the entailment modules). If entailment is enabled triples are returned from the entire store -- ignoring which graph they may belong to.