Skip to main content

Write your SPARQL query directly in the JSON-LD you would like to have in output

Project description

Py SPARQL Transformer

Write your SPARQL query directly in the JSON-LD you would like to have in output. Python version of SPARQL Transformer for JavaScript.

Table of Contents

How to use

Install by pip.

pip install SPARQLTransformer

Use in your JS application (node or browser).

from SPARQLTransformer import sparqlTransformer

out = sparqlTransformer(query, options)

The first parameter (query) is the query in the JSON-LD format. The JSON-LD can be:

  • an already parsed JS object (or defined real time),
  • ONLY if running in NodeJS, the local path of a JSON file (that will then be read and parsed).

The options parameter is optional, and can define the following:

OPTION DEFAULT NOTE
context http://schema.org/ The value in @context. It overwrites the one in the query.
sparqlFunction None A function receiving in input the transformed query in SPARQL, returning a Promise. If not specified, the module performs the query on its own1 against the specified endpoint.
endpoint http://dbpedia.org/sparql Used only if sparqlFunction is not specified.
debug False Enter in debug mode. This allow to print in console the generated SPARQL query.

See test.js for further examples.

Credits

If you use this module for your research work, please cite:

Pasquale Lisena and Raphaël Troncy. Transforming the JSON Output of SPARQL Queries for Linked Data Clients. In WWW'18 Companion: The 2018 Web Conference Companion, April 23–27, 2018, Lyon, France. https://doi.org/10.1145/3184558.3188739

BIB file


1: Using virtuoso-sparql-client.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SPARQLTransformer-1.6.3.tar.gz (6.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page