简体   繁体   中英

Import ontology with same IRI

I have one ontology which consists on two separate files:

  • tbox.owl
  • abox.owl

(The latter contains only the instances)

My idea is to use the Manchester OWL API 5 to read the Abox and get all the object properties in signature (for example).

The Abox uses owl:imports to include the Tbox. But -from my understanding- first I have to map the remote IRI of the Tbox (eg, http://mywebsite.com/ontology/artists.owl ) to the local file in my system.

This is what I tried:

// Create an ontology manager
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

// Manually map imports
IRI remoteIRI = IRI.create("http://mywebsite.com/ontology/tbox.owl");
IRI localIRI = IRI.create(new File("tbox.owl"));

SimpleIRIMapper mapper = new SimpleIRIMapper(remoteIRI, localIRI);
manager.getIRIMappers().add(mapper);

// Read individuals (i.e. ABox)
File file = new File("abox.owl");
OWLOntology ABox = manager.loadOntologyFromOntologyDocument(file);

And this is the exception it raises:

Exception in thread "main" org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException: Ontology already exists. OntologyID(OntologyIRI(<http://mywebsite.com/ontology/tbox.owl>) VersionIRI(<null>))
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:1122)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1057)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1007)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:1020)
    at examples.PopulateDatabaseWithPropIndividuals.main(PopulateDatabaseWithPropIndividuals.java:71)
Caused by: org.semanticweb.owlapi.model.OWLOntologyRenameException: Could not rename ontology. An ontology with this ID already exists: OntologyID(OntologyIRI(<http://mywebsite.com/ontology/tbox.owl>) VersionIRI(<null>))

Any ideas?

The two ontologies cannot have the same IRI, because this creates ambiguity both in the manager holding them and, more in general, from a reuse viewpoint. It would not be possible for another ontology to univocally identify which of your ontologies it imports, if your ontologies were to be made public or even if they were kept private but you wished to use them in some other project.

My recommended workaround would be to modify the abox ontology IRI and add an owl:imports statement to it, importing the tbox ontology. It could be done in the other direction (the tbox could import the abox), although this is not the most common pattern; you could also add a third ontology whose purpose is only to aggregate the two ontologies, and containing only two imports statements, towards your abox and tbox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM