Open marc-portier opened 6 months ago
in case you get bitten by this bug too: a dirty hack around this is just serializing to another format and use another rdflib parser that does not have this problem
def reparse(g: Graph, format="nt"):
"""This is a dirty hack workaround for issue https://github.com/RDFLib/rdflib/issues/2760
It reproduces the graph by serializing and parsing it again
Via an intermediate format (not jsonld!) that is known to work
:param g: the graph to reparse
:param format: the intermediate format to use
"""
return Graph().parse(data=g.serialize(format=format), format=format)
Parsing this turtle:
leads to the bnode local-identifiers (correctly) being replaced with generated uuid
and (also correct) new ones at every run
While parsing the equivalent json-ld:
will lead to
Which actually extends the reach and life-time of these local identifiers far beyond their intended scope.
In practice: loading two distinct json-ld files which happen to use the same local bnode-identifiers into the same graph will effectively mix up the nodes from both.
Note: A similar issue was identified and fixed in rdflib.js --> https://github.com/linkeddata/rdflib.js/issues/555