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

This module allows you to write programs that can be executed on a triplestore or directly on the in-memory SWI-Prolog rdf database.

Sparqlprog defines predicates such as rdf_path/3 and str_starts/2. These are usually compiled down to SPARQL queries. This module provides prolog implementations for these predicates using predicates such as rdf/3

Many of the predicates here take an argument strlike - this can be either an atom or a string.

 regex(?String, +Pattern, +Flag) is nondet
 str_starts(+S:strlike, +Sub:strlike) is semidet
 str_ends(+S:strlike, +Sub:strlike) is semidet
 str_before(+S:strlike, +Sep:strlike, ?Sub:strlike) is det
 str_after(+S:strlike, +Sep:strlike, ?Sub:strlike) is det
 str_replace(+S:strlike, +Match:strlike, +Replace:strlike, ?NewStr:strlike) is det
 rdf_path(?S, +Path, ?O, ?G) is nondet
 rdf_path(?S, +Path, ?O) is nondet
Evaluate an rdf path expression in terms of rdf/3.

See https://www.w3.org/TR/sparql11-query/#propertypaths

Path = Pred OR \Path OR P|Q OR P\Q OR zeroOrMore(Path) OR oneOrMore(Path) OR inverseOf(Path)

 bind(?ReturnValue, +FunctionTerm)
evaluates a function term. The function term can be a:
  • SPARQL builtin (e.g. coalesce, regex)
  • An arithmetic term (e.g. 1 + (2 / X) )
  • An abritrary prolog goal term in which:
    • the final argument N is treated as result/output
    • the arguments 1..( N-1) are treated as inputs
    • inputs should be ground
    • determinism or semi-determinism assumed when inputs are ground
 seval(+FunctionTerm, ?ReturnValue)
evaluates a function term

Re-exported predicates

The following predicates are re-exported from other modules

 concat(+Atom1, +Atom2, -Atom) is det
- Use ISO atom_concat/3

Undocumented predicates

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

 ensure_atom(Arg1, Arg2)
 ensure_string(Arg1, Arg2)
 ensure_atoms(Arg1, Arg2)
 lcase(Arg1, Arg2)
 regex(Arg1, Arg2)
 concat(Arg1, Arg2, Arg3, Arg4)
 count(Arg1, Arg2)
 group_concat(Arg1, Arg2, Arg3)
 rdf_path(Arg1, Arg2, Arg3)
 if(Arg1, Arg2, Arg3, Arg4)
 eval_to_atom(Arg1, Arg2)