|Did you know ...||Search Documentation:|
|Packs (add-ons) for SWI-Prolog|
|Title:||Prolog RDF Library|
|Rating:||Not rated. Create the first rating!|
|Author:||Wouter Beek <email@example.com>|
|Maintainer:||Wouter Beek <firstname.lastname@example.org>|
|Packager:||Wouter Beek <email@example.com>|
No reviews. Create the first review!.
This library provides advanced support for working with RDF in Prolog.
Run the following command in SWI-Prolog:
Libraries can be loaded in the following way:
This library uses the following extended Prolog types in the documentation headers of predicates:
|An atom that starts with `_:`.|
|Either a term of type |
|An atom that can be decomposed with |
|A compound term of the form |
|An RDF name (IRI or literal).|
|A compound term of the form |
|An RDF term (blank node, IRI, or literal).|
|A compound term of the form |
|A term of type |
This section enumerates the various modules that are included in this library.
This module contains data cleaning predicates that were previously part of LOD Laundromat. They can be used to clean RDF tuples that are streamed from an RDF source. See module [[semweb/rdf_deref]] for creating streams over RDF sources.
In order to use this module, library
must be installed.
The parsers in the Semantic Web standard library emit blank node labels that contain characters that are not allowed in standards-compliant output formats (e.g., forward slashes). This is unfortunate, since writing the data into standard-compliant formats requires maintaining a state that ensures that Prolog internal blank node labels are consistently emitted by the same standard-compliant external blank node label. See this Github issue for context.
Besides the above considerations, blank nodes form a scalability issue in general. Since blank node labels are only guaranteed to be unique within the context of an RDF document, combining data from multiple documents requires a check of all blank node labels in the to be combined documents. Furthermore, all blank node labels that appear in more than one RDF document must be consistently renamed prior to combining the data.
Since Pro-RDF focusses on scalability, it cannot rely on maintaining
an internal state that consistently maps internal Prolog blank node
labels to external standards-compliant blank node labels. For the
same reasons, it also cannot rely on full document inspection and
blank node relabeling approaches. For these reasons, the data
cleaning prediates in
library(rdf_clean) replace blank nodes with
well-known IRIs, in line with the RDF 1.1 standard. This means that
every data cleaning predicate must bind a valid well-known IRI to the
BNodePrefix argument. It also means that Prolog internal blank node
labels are hashed using the MD5 algorithm to provide the local names
for the generated well-known IRIs. The latter ensures consistent
relabeling without maintaining an internal state.
The parsers from the Semantic Web standard library denote the default
graph with atom
user. This is translated to atom
named graphs, this library checks whether they are well-formed IRIs.
IRI cleaning is the most difficult part of syntactic RDF data cleaning. To date, the IRI grammar (RFC 3987) has not yet been implemented. Since this grammar was published over a decade ago, we must anticipate a future in which the main syntactic component of the Semantic Web cannot be validated.
While there are implementations of the URI grammar (RFC
3986), the one provided by the
SWI-Prolog standard library (
library(uri)) is incorrect.
Because of the above two reasons we currently only check the following:
For language-tagged strings, cleaning involves downcasing the language tag. While there are implementations of the language tag grammar (RFC 5646), we are not yet using these.
Simple literals, i.e., literals with neither language tag not datatype
IRI, are translated to typed literals with datatype IRI
For typed literals, cleaning involves:
rdf_literal_value/3, which is part of library
This module provides the following predicates.
rdf_clean_quad(+Site:uri, +Dirty:rdf_quad, -Clean:rdf_quad)
Cleans quadruple compound terms.
rdf_clean_triple(+Site:uri, +Dirty:rdf_triple, -Clean:rdf_triple)
Cleans triple compound terms.
rdf_clean_tuple(+Site:uri, +Dirty:rdf_tuple, -Clean:rdf_tuple)
Cleans quadruple and/or triple compound terms.
This module implements RDF dereferencing, i.e., the act of obtaining interpreted RDF statements based on a given RDF document, stream, or HTTP(S) URI.
This library provides the following predicates.
Calls RDF dereferencing on local RDF documents. Uses heuristics in order to determine the RDF serialization of the file.
Performs RDF dereferencing on an input stream containing one of the standardized RDF serialization formats.
Performs RDF dereferencing on a URI, typically an HTTP(S) URI. Uses heuristics in order to determine the RDF serialization of the reply body.
This library provides primitives for generating GraphViz DOT exports of RDF terms and tuples.
This module requires library
This module writes RDF data in a simple and standards-compliant serialization format. It contains the following predicates:
This module peeks at the beginning of a file, stream, or string in order to heuristically guesstimate the RDF serialization formats (if any) containing in that input:
This module provides support for the standardized RDF serialization format Media Types:
Guesses the RDF serialization format based on the file name extension alone.
Enumerates all standardized RDF Media Types.
Succeeds if the former argument is an RDF Media Type that syntactically encompasses the latter argument (e.g., TriG > Turtle > N-Triples, N-Quads > N-Triples).
Gives a standard file name extension for RDF serializations that are not RDFa (which is part of HTML or XHTML content).
Succeeds for RDFa Media Types.
This module provides extended support for working with RDF prefix declarations:
Enumerates the currently declared RDF prefix declarations.
Succeeds for (alias,local-name) pairs and full IRIs.
Provide the corresponding popular Prolog predicates, but apply RDF prefix notation expansion on their arguments.
RDF prefix expansion must be specifically declared for arguments in predicates. In the SWI-Prolog standard libraries, such declarations have only been added for predicates in the Semantic Web libraries, but not for predicates in other standard libraries. For example, the following will not check whether P is bound to either of the four RDFS properties, because the prefix notation is not expanded:
With the SWI-Prolog standard library, the above call must be spelled
rdf_equal/2 in the following way:
( rdf_equal(P, rdfs:domain) -> true ; rdf_equal(P, rdfs:range) -> true ; rdf_equal(P, rdfs:subClassOf) -> true ; rdf_equal(P, rdfs:subPropertyOf) -> true )
library(rdf_prefix) is loaded, the above can be written as
This module provides DCG rules for printing RDF terms and tuples.
This module provides advanced support for composing, decomposing, parsing, and generating RDF terms.
Pack contains 12 files holding a total of 101K bytes.