Last active
May 23, 2023 07:57
-
-
Save sandervd/2fee4c403d5a492e6b1b235d3bbaae48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE { | |
?s ?p1 ?bn . | |
?bn ?p2 ?o . | |
} | |
INSERT { | |
?s ?p1 ?nbn . | |
?nbn ?p2 ?o . | |
} | |
WHERE { | |
{ | |
SELECT ?bn (count(?s) as ?number) | |
WHERE { | |
?s ?p ?bn | |
FILTER isBlank(?bn) | |
} | |
GROUP BY(?bn) | |
} | |
FILTER (?number > 1) | |
{ | |
{ | |
?s ?p1 ?bn . | |
BIND (BNODE() as ?nbn) | |
} | |
?bn ?p2 ?o | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In order to be able to represent a graph as a set of key-value pairs, blank nodes should only occur once in the object position.
This SPARQL construct duplicates the blank nodes, so that they occur only once as object.