Created
February 24, 2018 18:20
-
-
Save jindrichmynarz/c2e332d5ab35b47d95f17bb78dfccc07 to your computer and use it in GitHub Desktop.
Recursive concise bounded description
This file contains 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
# SPARQL 1.1 implementation of concise bounded description (<https://www.w3.org/Submission/CBD>). | |
PREFIX : <http://example.com/> | |
PREFIX non: <http://non/> | |
CONSTRUCT { | |
:resource ?p1 ?r1 . | |
?r2 ?p2 ?r3 . | |
} | |
WHERE { | |
# :resource is the IRI of the resource we want to describe. | |
:resource ?p1 ?r1 . | |
OPTIONAL { | |
# Since variables cannot be used in SPARQL 1.1 property paths | |
# we can ask for any but a (presumably) non-existent property. | |
# We use zero or more quantifier (i.e. "*") to recursively | |
# expand to blank node neighbourhood. | |
?r1 (!non:existent)* ?r2 . | |
FILTER (isBlank(?r1) && isBlank(?r2)) | |
?r2 ?p2 ?r3 . | |
} | |
} |
This file contains 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 : <http://example.com/> . | |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
:resource a :C ; | |
:p1 [ | |
a :D ; | |
:p2 [ | |
a :E | |
] | |
] . | |
:C a rdfs:Class . | |
:D a rdfs:Class . | |
:E a rdfs:Class . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We plan to use PATH for that but from what I know we cannot use it in sub-selects right now