semanticarts / ontology-toolkit

Tools to update and export ontology RDF.
Apache License 2.0
34 stars 6 forks source link

Add function to generate explicit subclass assertions #101

Open rjyounes opened 2 years ago

rjyounes commented 2 years ago

See gist issue #714 for discussion.

The idea is that many tools support subClassOf assertions that are not able to infer the relationship. We would like to be able to generate these and store them in a separate file for use as desired.

bpelakh commented 2 years ago

That makes sense, and I have run into this problem before. So, two possible approaches -

  1. Run a simple query for the sort of patterns we use in gist, which is what is used to generate schema graphs in onto_tool, i.e
    select ?class ?parent where {
        ?class (owl:equivalentClass|rdfs:subClassOf)/(owl:unionOf|owl:intersectionOf)/rdf:rest*/rdf:first ?parent .
        ?parent a owl:Class
        filter (!isblank(?class) && !isblank(?parent))
    }
  2. Run a full OWL2 reasoner, as suggested by @justin2004, and then just extract subClassOf triples from the output into a generated .ttl.
rjyounes commented 2 years ago

I think we'd want to exclude subclasses that are already explicitly asserted in the ontology. Not that the redundancy does any harm, but it seems sloppy. In that case option 1 would be simpler - we could just remove the rdfs:subClassOf disjunct. On the other hand, 2 is more general and will catch everything, even if it doesn't follow the gist pattern. Maybe we just live with the redundancies.

@justin2004 Thoughts?

rjyounes commented 1 year ago

@dylan-sa Has written a script to generate the subclass assertions for gist. The idea here is to build it in as an onto_tool action.

sa-bpelakh commented 1 year ago

@dylan-sa Has written a script to generate the subclass assertions for gist. The idea here is to build it in as an onto_tool action.

That's a pretty cool script, but seems a little too specific for a general utility like onto-tool. How about the following solution:

  1. Add a reason bundle command that would take some input(s) and run the reasoner, storing the output as specified
  2. Use the existing sparql bundle command to CONSTRUCT the ontology, grabbing the subClassOf triples only and adding the ontology definition.
rjyounes commented 1 year ago

That sounds great.

rjyounes commented 1 year ago

Once this has done, we should revisit https://github.com/semanticarts/gist/issues/838.