Did you know ... Search Documentation:
Pack sparkle -- prolog/sparkle.pl
PublicShow source

Samer Abdallah, Dept. of Computer Science, UCL (2014) Based on Yves Raimond's swic package, but completely re-written.

This module provides a little language for expressing SPARQL queries and a database of known SPARQL endpoints. Queries can be executed across multiple endpoints in parallel. When using auto-paging, multiple queries are made automatically to fetch new bindings as they are needed. For example,

EP ?? rdf(A,B,C).

will retrieve all triples from all endpoints in parallel, fetching 100 bindings at a time from each endpoint (assuming the setting sparkle:limit takes it's default value of 100).

 ??(+Goal:sparql_goal) is nondet
Equivalent to _ ?? Goal. Will query all endpoints in parallel. Identical bindings may be returned multiple times. See query_goal/3 for details.
 ??(EP, +Goal:sparql_goal) is nondet
Equivalent to query_goal(EP,Goal,Opts) where Opts is the value of the setting sparkle:select_options. See query_goal/3 for details. IF EP is unbound on entry, it is bound to the endpoint from which the current bindings were obtained.
 sparql_endpoint(+EP:ground, +URL:atom, +Options) is det
 sparql_endpoint(+EP:ground, +URL:atom) is det
Declares EP as a short name for a SPARQL endpoint with the given URL. No options are defined at the moment.
 current_sparql_endpoint(-EP:ground, -Host:atom, -Port:natural, -Path:atom, -Options:list) is nondet
Succeeds once for each known endpoint.
 query_goal(+EP, +Goal:sparql_goal, +Opts) is nondet
query_goal(-EP, +Goal:sparql_goal, +Opts) is nondet
Runs a SPARQL query against one or more SPARLQ endpoints. Goal is converted into a textual SPARQL query using the DCG defined in sparql_dcg.pl.

If EP is ground on entry, the query is run against the specified endpoint. If EP is unbound on entry, the query is run agains all endpoints in parallel, possibly returning multiple results from each.

(The following applies only to queries that return bindings, not to simple boolean questions, which return only true or false.) Options are as follows:

limit(L:natural)
At-most this many bindings will be returned per SPARQL call.
offset(O:natural)
Begin returning bindings from the Oth result on.
autopage(Auto:bool)
If false, a single SPARQL call is made using any limit and offset options if supplied. If true, the the offset option is ignored and multiple SPARQL queries are made as necessary to supply results, using the limit option to determine the number of results retrieved from the endpoint at a time. Other options are passed to phrase_to_sparql/2.
 query_phrase(+EP, +Q:sparqle_phrase(R), R) is nondet
query_phrase(-EP, +Q:sparqle_phrase(R), R) is nondet
Phrase-based queries using the DCG defined in sparql_dcg.pl. The return type depends on the query:
select(V:list(var), sparql_goal, options) :: sparql_phrase(row(N)) :- length(V,N).
describe(resource,sparql_goal)            :: sparql_phrase(rdf).
describe(resource)                        :: sparql_phrase(rdf).
ask(sparql_goal)                          :: sparql_phrase(bool).

rdf  ---> rdf(resource,resource,object).
bool ---> true; false.

row(N) is the type of terms of functor row/N.

 query_sparql(?EP, SPARQL, -Result) is nondet
Runs textual SPARQL query against an endpoint, exactly as with sparql_query/3. If EP is unbound on entry, all known endpoints will be tried sequentially.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 sparql_endpoint(Arg1, Arg2)