Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "sparkle"

Title:Prolog-friendly interface to SPARQL endpoints
Rating:
(1/1)
Latest version:0.1.1
SHA1 sum:1890c52141a1f6a0b5d6ef4a218eda40cb3617c4
Author:Samer Abdallah <samer.abdallah.00@gmail.com>
Download URL:https://raw.githubusercontent.com/samer--/prolog/master/sparkle/release/sparkle-0.1.1.tgz
Requires:dcgutils

Reviews

Write a review or add a rating.

Really nice way to run SPARQL queries. With support for concurrency and auto paging this can be used for large scale federated processing of RDF. Fits great with ClioPatria's SWISH plugin. Two small points:

  • I wonder about the high-priority ?? operator. Possibly it is ok because we have module-specific operators ...
  • Is it necessary to have an explicit filter(Filter) term?
Sunday 19 April 2015, Jan Wielemaker

Details by download location

VersionSHA1#DownloadsURL
0.0.16f00c8235a7630116359aecfed8eff816ee0a7a71https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.1.tgz
0.0.27600abb1be8020936e3c40e6dcdd84551bad23d71https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.2.tgz
0.0.3ff9ae590f3c54198736c23bf21e3da477ef54bcf3https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.3.tgz
0.0.406f539a4fec052ea1b27d22f01253b055b4a0d631https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.4.tgz
0.0.5e96e8d80bd65fd7476f5efa197f04981c89466e31https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.5.tgz
0.0.6c9dbd2f572ca87f3a1db93c552c26ce1ff3a105b1https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.6.tgz
0.0.765fc41bad2ee749d1f82441c338134007335078b1https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.7.tgz
0.0.85f496c6446616b3efdc0227d1545bc534f53f0791https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.8.tgz
0.0.908b800f8fce1de648be85eed633e170707174b8570https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.0.9.tgz
0.1.11890c52141a1f6a0b5d6ef4a218eda40cb3617c49https://github.com/samer--/prolog/raw/master/sparkle/release/sparkle-0.1.1.tgz

This package provides a more natural (from a Prolog point of view) interface to SPARQL endpoints. There are two layers. The first, lower layer, defines a DCG for generating SPARQL queries from a structured term. The second provides a translation from representation that looks more or less like a Prolog goal built from rdf/3 goals (with conjunction, disjunction etc) to a term in the term language understood by the SPARQL DCG.

In addition, the library provides a mechanism to register known SPARQL endpoints so that they can be referred to by a short name, or to enable a query to be run against all registered endpoints.

The library is based on the idea implemented in Yves Raimond's swic package, but the code has been completely re-implemented.

Prerequisites

You just need SWI Prolog with its Semantic Web libraries.

Simple usage

The (??)/2 and (??)/1 operators have a high precedence so that conjuction and disjunctive queries can be written to the right of it without parentheses.

?- rdf_register_prefix(foaf,'http://xmlns.com/foaf/0.1/')
?- rdf_register_prefix(dbont,'http://dbpedia.org/ontology/')
?- sparql_endpoint( dbp, 'http://dbpedia.org/sparql/').
?- debug(sparkle).  % to show queries

?-	dbp ?? rdf(Class,rdf:type,owl:'Class'), rdf(Instance,rdf:type,Class).
?- dbp ?? rdf(Person,rdf:type,foaf:'Person'),
          rdf(Person,foaf:Name,Name),
          filter(regex('Colt.*',Name)).
?- dbp ?? rdf(A,rdf:type,dbont:'Photographer'); rdf(A, rdf:type, dbont:'MusicalArtist').

Change log

0.0.8: concurrent_or/3 moved to separate module, fixes to concurrent_or/3.

0.0.7: More documentation. Renamed endpoint_query/3 to query_sparql/3.
Non-autopaged queries now use sparkle:limit setting for default limit to
avoid getting huge amounts of data when no limit is supplied.

New in version 0.0.6: both (??)/2 and query_goal/3 can accept a variable
as an endpoint. If this is the case, then multiple queries are made in parallel.
Each successful result binds the endpoint variable to the source of that data, eg
==
EP ?? rdf(Class,rdf:type,owl:'Class').
==
will bind Class to all known classes and EP to the endpoint which reported that class.
If the same bindings can be returned from several endpoints, then (??)/2 will produce
those binding multiple times, with EP bound to different values each time, even if the
query reduces to an ASK SPARQL query. It's up to you to use once/1 etc as necessary
if this is not the behaviour you want.

Also new in 0.0.6, autopaged queries, that is, you can forget about OFFSET and LIMIT;
multiple queries will be made as necessary to fetch data on demand. The default
batch size is determined by the sparkle:limit setting.

Contents of pack "sparkle"

Pack contains 7 files holding a total of 63.9K bytes.