简体   繁体   中英

load ontology from ontology document using OWL API

I downloaded OWL API maven project and opened OWL API Default Implementation. I just want to load an ontology but it gives me an error.

public static final IRI example_iri2 = IRI.create("http://mged.sourceforge.net/ontologies/MGEDOntology.owl");

public static void main(String[] arg) throws OWLOntologyCreationException {
    OWLDataFactoryImpl factoryImpl = new OWLDataFactoryImpl();
    ReadWriteLock readWriteLock = new NoOpReadWriteLock();
    OWLOntologyManagerImpl managerImpl = new OWLOntologyManagerImpl(factoryImpl, readWriteLock);
    OWLOntology ontology = managerImpl.loadOntology(example_iri2);
}

The output is:

        SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Exception in thread "main" org.semanticweb.owlapi.model.OWLOntologyFactoryNotFoundException: Could not find an appropriate factory to load ontology from ontology document: <http://mged.sourceforge.net/ontologies/MGEDOntology.owl>
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:1048)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:935)
        at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:891)
        at com.main.main.main(main.java:33)
    ------------------------------------------------------------------------
    BUILD FAILURE

How can I fix this? I tried this and it's not working.

File file = new File("pizza3.owl");
OWLOntology ontology = managerImpl.loadOntologyFromOntologyDocument(file);

The manager you created needs setup.

The recommended way is through OWLManager, in the apibinding module.

The recommended dependencies to use are the distribution or osgidistribution modules.

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