Auto-generated blank node labels are syntactically invalid · Issue #68 · SWI-Prolog/packages-semweb · GitHub
Skip to content

Auto-generated blank node labels are syntactically invalid #68

Open

Description

@wouterbeek

When a dataset that contains blank nodes is processed in the Semantic Web standard libraries, blank nodes are assigned auto-generated labels. The URI representation of the file path from which the data is loaded forms part of these generated labels (see the example below). Unfortunately, forward slashes are not allowed in Turtle-family blank node label syntax. This means that Prolog blank node labels cannot be directly emitted in the process of generating a Turtle-family export or a SPARQL result set.

?- [library(semweb/rdf11)].
?- [library(semweb/turtle)].
?- rdf_load('vocab.trig', [format(trig)]).
?- rdf(S, P, O).
S = '_:file:///home/wbeek/git/Triply/cshapes/vocab.trig1',
P = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#first',
O = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' ;

The predicates that performed batch exports, i.e., that export complete files at once, do turn these internal blank node labels into standards-compliant serialization output.

The problem remains with applications that stream through the data. Specifically, it is currently not possible to 'recode' an RDF dataset from one format into another using a statement-wide window. Renaming internal blank node labels to standard-compliant external blank node label requires an in-memory mapping (turtle.c uses a hash map for this) which can become arbitrarily long for arbitrary long data streams.

Activity

  1. JanWielemaker commented on Oct 26, 2017

    @JanWielemaker
    Member

    Well, the Turtle writer will rename Prolog's blank nodes into nice and short ones. I'm not a big fan of hashes a they make debugging hard. I see various options: make sure they never leak through standard protocols, use an encoding that can be reverted (e.g, the url-friendly base64 variant), so
    we can use portray or other tools to make them readable again or use a hash.

  2. wouterbeek commented on Oct 26, 2017

    @wouterbeek
    ContributorAuthor

    Indeed, the writers fix this. I was writing atoms (bnodes and IRIs) to N-Triples directly, but that is a recipe for disaster :) Thanks for pointing that out.

  3. wouterbeek commented on Oct 26, 2017

    @wouterbeek
    ContributorAuthor

    I've updated then issue to make clearer that blank node renaming is currently not implemented for streamed writers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions