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