Created
March 6, 2024 17:10
-
-
Save balhoff/7010180149e21b3fd7cb2597f3a8a4c6 to your computer and use it in GitHub Desktop.
A SPARQL update to replace blank nodes with IRIs
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
PREFIX ex: <http://example.org/> | |
INSERT { | |
?node ex:skolem ?iri . | |
} | |
WHERE { | |
{ | |
SELECT DISTINCT ?node | |
WHERE { | |
{ ?node ?p1 ?o1 . } | |
UNION | |
{ ?s2 ?p2 ?node . } | |
FILTER(isBlank(?node)) | |
} | |
} | |
BIND (UUID() AS ?iri) | |
} | |
; | |
DELETE { | |
?node ?p ?o . | |
} | |
INSERT { | |
?iri ?p ?o . | |
} | |
WHERE { | |
?node ex:skolem ?iri . | |
?node ?p ?o . | |
FILTER(?p != ex:skolem) | |
} | |
; | |
DELETE { | |
?s ?p ?node . | |
} | |
INSERT { | |
?s ?p ?iri . | |
} | |
WHERE { | |
?node ex:skolem ?iri . | |
?s ?p ?node . | |
FILTER(?p != ex:skolem) | |
} | |
; | |
DELETE WHERE { | |
?node ex:skolem ?iri . | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment