Hello !
I have been struggling with the following usecase:
I am extending some existing ontology by adding among other new subclasses, the resulting ontology is then imported in some more fundamental one.
Problem: the following won't work
with newOnto:
someClass = IRIS['some IRI Of The Higher Ontology']
class someSubClass(someClass):
blabla
newOnto.save(path)
which makes sense as newOnto does not know about someClass.
So currently I have to do the following:
with newOnto:
class someClass(Thing):
pass
someClass.iri = 'some IRI Of The Higher Ontology'
class someSubClass(someClass):
blabla
newOnto.save(path)
import rdflib
from rdflib.namespace import RDFS, RDF, OWL
g = rdflib.Graph()
g.parse(path)
someClass2 = rdflib.URIRef('some other IRI Of The Higher Ontology')
identifier = rdflib.URIRef('some IRI Of The Higher Ontology')
g.add((identifier,RDFS.subClassOf, someClass2))
g.remove((rdflib.URIRef('some IRI Of The Higher Ontology'),
RDFS.subClassOf,
OWL.Thing))
[save updated graph]
Or something similar depending on the case, ie. manually editing the graph which is cumbersome.
Is there a better way of doing this?
Cheers,
GP