0

For a specific task, I want to load an ontology from several different files. In another words, I want to include all axioms from different files into an integrated ontology.
And since those files can be in different format, for example, some of them are .owl files and some others can be .nt file, thus I cannot simply copy all the contents into a single file.

It is pretty easy to load an ontology from a single file, according to the documents of OWL API, you can manage it as follows:

OWLOntologyManager m=OWLManager.createOWLOntologyManager();

File inputOntologyFile = new File("XXXXXXXXX");

OWLOntology o = m.loadOntologyFromOntologyDocument(inputOntologyFile);


So my question is: how to load an ontology from several different files? Is it possible for me to manage that in an incremental style?

Yu Gu
  • 2,382
  • 5
  • 18
  • 33
  • 2
    1) You can load each ontology and simply "merge" the axioms into a new fresh axiom or 2) simply use the [`OWLOntologyMerger`](https://owlcs.github.io/owlapi/apidocs_5/org/semanticweb/owlapi/util/OWLOntologyMerger.html) which basically does exactly the same. – UninformedUser Jun 15 '18 at 06:11
  • @AKSW Thanks! You can post your answer and then I will accept it. – Yu Gu Jun 15 '18 at 07:31
  • If the files are independent ontologies that might change at a later date, you can create one ontology that imports the ontologies you wish to load and then use it as is - this works with reasoners and other imports closure aware tools like Protege. If you need the axioms from all ontologies to be merged together, you can follow the same approach and, after the root ontology has been loaded, create a new ontology and add all axioms from the root ontology to the new flattened ontology. The method OWLOntology::axioms(ImportsClosure.INCLUDED) will return all axioms from the imports closure. – Ignazio Jun 15 '18 at 13:01

0 Answers0