Created
July 13, 2021 19:06
-
-
Save gtfierro/0c8cf80225c0cddc2169a801e56a6c40 to your computer and use it in GitHub Desktop.
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
import brickschema | |
g = brickschema.Graph() | |
g.parse("https://raw.githubusercontent.com/BrickSchema/Brick/master/shacl/BrickEntityShapeBase.ttl", format="ttl") | |
q = """SELECT ?cls ?path ?allowed WHERE { | |
?sh a sh:NodeShape . | |
?sh sh:targetClass ?cls . | |
?sh sh:property ?prop . | |
?prop sh:path ?path . | |
{ | |
?prop sh:class ?allowed | |
} | |
UNION | |
{ | |
?prop sh:or/rdf:rest*/rdf:first/sh:class ?allowed | |
} | |
}""" | |
for row in g.query(q): | |
print(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment