RDFLib with RDF 1.1: BNode skolemization facilities

98 views
Skip to first unread message

Ivan Herman

unread,
Nov 5, 2012, 11:35:37 AM11/5/12
to Gunnar Aastrand Grimnes, rdfli...@googlegroups.com, Niklas Lindström, rdf...@googlecode.com, Dan Brickley
These are described in

http://www.w3.org/TR/rdf11-concepts/#section-skolemization

the executive summary is that there is an (additional and, actually, optional) facility RDF environments may provide, namely to pair a recognizable URI pattern to BNodes, thereby, if necessary, change a graph replacing that BNode to a 'real' URI. The general pattern is defined in the spec, with some adaptation per library. It is to be expected, that if a graph is skolemized and then de-skolemized by the same environment, then this would constitute a round-tripping, modulo the exact BNode id-s.

To implement this, I have added a bunch of classes and methods to term.py; here they are:

class Genid(URIRef)
--------------------

all URIRef classes are assigned this class at creation time if the corresponding URI is of the form

{scheme+host}/.well-known/genid/{rest}

(This is the general form of a skolem URI per RDF 1.1.)

class RDFLibGenid(Genid)
--------------------------

all URIRef classes are assigned this class at creation time, if the corresponding URI is of the form

{scheme+host}/.well-known/genid/rdflib/{rest}

where {rest} has no fragment or query part either.

By introducing the /rdflib/ into the path, we can expect that the skolem/genid has been generated by RDFLib.

BNode.skolemize( authority = "http://rdflib.net") :
---------------------------------------------------
Generate a URIRef of the form {authority}/.well-known/genid/rdflib/{BNode identifier}, ie, an RDFLibGenid instance as above.

URIRef.de_skolemize()
---------------------
returns a BNode. If it is a RDFLibGenid, it uses the identifier part directly (ie, if only RDFLib is used, these are inverse functions), otherwise new BNodes are created. An exception is raised if the node is not a Genid instance.

Graph.skolemize(new_graph = None, bnode = None)
-----------------------------
If bnode is None, all triples in the graph are copied to new_graph, with all occurences of BNodes skolemized; if bnode is not None, then only that bnode is skolemized when copying. If new_graph is None, a new graph is created on the fly; in all cases new_graph is returned.

Graph.de_skolemize(uriref = None)
---------------------------------
like the skolemize() method, except that de_skolemization occurs on all graphs.

Note that there is no separate method for skolemization on Datasets; if effect, (de)skolemization will work on all triples regardless of graph names and a flat graph will be returned. This is because, depending on the semantics used, it may or may not be o.k. for the user to change a named graph, ie, it is not clear where the skolemized triples should be added (into the dataset with the same URI as graph name? a new dataset with the same URI as in the original? create a new URI but then what?)


Ivan


----
Ivan Herman
4, rue Beauvallon, clos St Joseph
13090 Aix-en-Provence
France
http://www.ivan-herman.net

Markus...@tu-dresden.de

unread,
Jan 17, 2013, 3:56:49 AM1/17/13
to rdfli...@googlegroups.com
Hello Ivan,

I am very interested in this topic. I need to skolemize some graphs with the help of rdflib and thus I discovered this topic. Is there any possibility to obtain the code you've written?

Best regards,
Markus

--
Dipl.-Ing. Markus Graube
PhD Student

Dresden University of Technology
Faculty of Electrical and Computer Engineering
Chair of Distributed Control Systems Engineering
01062 Dresden, Germany

Phone : +49 (351) 463-33387
Fax : +49 (351) 463-39681
E-Mail: markus...@tu-dresden.de
WWW: http://www.et.tu-dresden.de/ifa/?id=mg

Ivan Herman

unread,
Jan 17, 2013, 5:56:53 AM1/17/13
to rdfli...@googlegroups.com
Markus,

there is a separate branch

https://github.com/RDFLib/rdflib/tree/rdf11

where I uploaded my current code. Unfortunately, the discussion died out a bit which is a pity:-(

Anyway, you are free to download that!

Ivan
> --
> You received this message because you are subscribed to the Google Groups "rdflib-dev" group.
> To post to this group, send email to rdfli...@googlegroups.com.
> To unsubscribe from this group, send email to rdflib-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msg/rdflib-dev/-/Mw43ve9FQqoJ.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


----
Ivan Herman
4, rue Beauvallon, clos St Joseph
13090 Aix-en-Provence
France
http://about.me/ivan_herman

Markus Graube

unread,
Jan 17, 2013, 9:08:25 AM1/17/13
to rdfli...@googlegroups.com
Hello Ivan,

thank you. The code is working great. Hopefully the code can be
integrated in the main branch.

Markus

Am 17.01.2013 11:56, schrieb Ivan Herman:
> Markus,
>
> there is a separate branch
>
> https://github.com/RDFLib/rdflib/tree/rdf11
>
> where I uploaded my current code. Unfortunately, the discussion died out a bit which is a pity:-(
>
> Anyway, you are free to download that!
>
> Ivan
>


--
Dipl.-Ing. Markus Graube
Wissenschaftlicher Mitarbeiter

Technische Universität Dresden
Fakultät Elektrotechnik und Informationstechnik
Institut für Automatisierungstechnik
Professur für Prozessleittechnik
01062 Dresden

Tel. : +49 (351) 463-33387
signature.asc

Graham Higgins

unread,
Jan 21, 2013, 5:40:43 PM1/21/13
to rdfli...@googlegroups.com
On Thu, 2013-01-17 at 15:08 +0100, Markus Graube wrote:
> Hopefully the code can be
> integrated in the main branch.

Some preparatory work is necessary: applying PEP8 to the code, adding a
Python 3 port and extending test coverage so that the current level of
coverage is at least maintained.

I've pushed what I have got so far to the repos and I've added the
branch to the Travis-CI build to expose the current failures reported by
the existing tests.

https://travis-ci.org/RDFLib/rdflib/builds/4290210


--
Graham Higgins

http://bel-epa.com/gjh/
signature.asc

imran.s...@gmail.com

unread,
Jun 16, 2013, 1:04:33 PM6/16/13
to rdfli...@googlegroups.com, Gunnar Aastrand Grimnes, Niklas Lindström, rdf...@googlecode.com, Dan Brickley

Hello lvan
I am working on Querying RDF document and working on the Bnode problem.Is there possible to to use Named graph and Skolmization to handel the Bnode Problem at query time.

Ivan Herman

unread,
Jun 17, 2013, 2:30:53 AM6/17/13
to rdfli...@googlegroups.com, Gunnar Aastrand Grimnes, Niklas Lindström, rdf...@googlecode.com, Dan Brickley
I do not think so. More exactly (and if I understand your question correctly):
skolemization helps if the server/query engine plays with. The client side only
cannot do this I believe.

But I think it would be better to ask these types of questions on the
semant...@w3.org mailing list; it is not necessarily related to RDFLib.

Sincerely

Ivan
Reply all
Reply to author
Forward
0 new messages