best practice for rdfs:subClassOf closure #1549
-
I'm working with @Gnomus042 on SHACL/ShEx topics and we had need to update a Graph to explicitly add all the implied rdfs:subClassOf arcs. We found two approaches, one using transitiveClosure(), and the other using SPARQL .query(): Working examples - https://colab.research.google.com/drive/1DWrR-VKus4elIJ2lpHy7BXw7Jhk5qmDH?usp=sharing Can you advise on which is preferred, or whether there is some other built-in or nearby extension to perform such tasks (and related inference e.g. subPropertyOf etc). I searched around but couldn't find clear guidance. Thanks for any pointers! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@danbri I see in your examples you're using PySHACL. Note, pySHACL has |
Beta Was this translation helpful? Give feedback.
@danbri
The owl-rl project can operate in RDFS mode, which will expand a graph to inference all RDFS axioms including
subClassOf
andsubPropertyOf
. To answer your first question, I believe all graph expanders built on rdflib use thetransitiveClosure()
mechanism.I see in your examples you're using PySHACL. Note, pySHACL has
owl-rl
built in, you can expand your graph before validation automatically usinginference="rdfs"
when callingvalidate()
.