Import ontology from file (In which the ontology itself imports several other files)

StackOverflow https://stackoverflow.com/questions/18702953

  •  28-06-2022
  •  | 
  •  

In Jena I'm loading an ontology into a Model, using this code:

Model model =  FileManager.get().loadModel("/path/myontology.owl");

My problem is that "myontology.owl" imports another ontology with owl:imports. In pseudo code lets just say that "Myontology.owl" imports other files to complete the ontology, since several individuals are declared in external files, e.g.:

  • In myontology.owl
  • Import → myontologywithindividuals.owl

My problem is that I can't import the ontology with its individuals into a single Model in Jena. That is,

Model model =  FileManager.get().loadModel("/path/myontology.owl");

doesn't seem to work. Any idea why? How can I import this correctly?

有帮助吗?

解决方案

Plain models in Jena don't do any processing of owl:imports, because plain RDF doesn't have any notion of importing other documents. Ontology imports are an OWL concept, and you'll need to use an OntModel if you want imports processing. You may need to use setDynamicImports() to enable import processing. If the imports statements refer to ontologies using their ontology IRI, but you want to retrieve them from a local file, you may also need to setup the OntModel's OntDocumentManager and FileManager to take care of the appropriate mapping from IRIs to local files.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top