UnloadableImportException: Failed to load imported ontology

I have an ontology created in Protege 4.3.0 and stored in an OWL file. To download this ontology using the OWL API , I use the following code example.

public class MySampleClass { private final OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); private final OWLDataFactory df = manager.getOWLDataFactory(); private final OWLReasonerFactory rf = new StructuralReasonerFactory(); private final OWLOntology ontology; private final OWLOntologyID id; private final IRI iri; private final PrefixManager pm; private final OWLReasoner reasoner; /** * * @param file */ public MySampleClass(File file) { try { ontology = manager.loadOntologyFromOntologyDocument(file); } catch (OWLOntologyInputSourceException | OWLOntologyCreationException ex) { // throw custom exception } id = ontology.getOntologyID(); iri = id.getOntologyIRI(); pm = new DefaultPrefixManager(iri.toString().concat("#")); reasoner = rf.createReasoner(ontology); reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_ASSERTIONS); } } 

However, if I try to load an ontology that includes one or more imports if these importers are not available, an UnloadableImportException is thrown as the following example:

org.semanticweb.owlapi.model.UnloadableImportException: Failed to load imported ontology: http://www.w3.org/2004/02/skos/core Reason: connection timeout

How to solve this problem? If the imported ontology is available offline, how do I import this ontology while loading my ontology?

+5
source share
1 answer

You can use AutoIRIMapper to point to a local folder containing local copies of ontologies.

 AutoIRIMapper mapper=new AutoIRIMapper(folder, true); manager.addIRIMapper(mapper); 

Do this before starting to download ontologies.

+3
source

All Articles