Skip to main content

Build Status PyPI

This module wraps sparqlprog, providing a Python API for executing logic program queries over SPARQL endpoints.

Example:

from prologterms import TermGenerator, PrologRenderer, Program, Var
from sparqlprog import SPARQLProg
P = TermGenerator()

S = SPARQLProg(endpoint='wd')
C = Var('C')
N = Var('N')

# logic programming query: continent(C), enlabel(C,N)
query = (P.continent(C), P.enlabel(C, N))
for r in S.query(query):
    print(f"{r['C']} {r['N']}")

Example Notebooks

See:

Installation

To install

python3 -m venv venv
source venv/bin/activate
export PYTHONPATH=.:$PYTHONPATH
pip install -r requirements.txt

You will need access to a sparqlprog service. You can use the public one on Heroku (default) or run your own.

Running your own is easy if you have Docker:

docker run -p 9083:9083 cmungall/sparqlprog

You can then pass http://localhost:9083 as the service URL parameter. E.g

Query wikidata for continents and their names:

./sparqlprog.py -u http://localhost:9083 -e wd “continent(X),enlabel(X,N)”

You can also use the default service on heroku, but it is not guaranteed to be running:

./sparqlprog.py -e wd “continent(X), enlabel(X,N)”

Release files for sparqlprog 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sparqlprog 0.0.3
File Size Uploaded
sparqlprog-0.0.3.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sparqlprog 0.0.3
File Interpreter ABI Platform
sparqlprog-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / sparqlprog-0.0.3.tar.gz

Download URL sparqlprog-0.0.3.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ae8b69cb8b16618a75459bc0f24a650433df33bdc6a10acfa02d1ae1b3e45d2
BLAKE2b-256 checksum
How to use checksums
8f50be95213d90c7cd08231b7f202741338aa3e8feae94e65f256a30255e1d97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

Release files / sparqlprog-0.0.3-py3-none-any.whl

Download URL sparqlprog-0.0.3-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
15a96b0dd045278d23ed82bdb53aa6abc014828c55a4961684232646a07d7bf5
BLAKE2b-256 checksum
How to use checksums
d7b62f7b8e364f4bdf0d17bc9b4d1f58a1e79edd1fb0604296b4a061e77cac81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page