OWL API V5 reads ontology from local file

in the current documentation example, follow the link: https://github.com/owlcs/owlapi/blob/version5/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java There is no example how to download the ontology from the local file. There is only one way to load it from a string.

In the past, when I used owl-up version 3, the following code worked fine:

    OWLOntologyManager manager =OWLManager.createOWLOntologyManager();
    File file = new File (path);
    OWLOntology ont = manager.loadOntologyFromOntologyDocument(IRI.create(file));

however, in this version, the last line of the previous code:

manager.loadOntologyFromOntologyDocument(IRI.create(file));

returns this error:

    Exception in thread "main" java.lang.NoSuchMethodError: 
    org.semanticweb.owlapi.util.SAXParsers.initParserWithOWLAPIStandards(Lorg/xml/sax/ext/DeclHandler;)Ljavax/xml/parsers/SAXParser; 
        at 
org.semanticweb.owlapi.rdf.rdfxml.parser.RDFParser.parse(RDFParser.java:148)
    at org.semanticweb.owlapi.rdf.rdfxml.parser.RDFXMLParser.parse(RDFXMLParser.java:62)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.loadOWLOntology(OWLOntologyFactoryImpl.java:173)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.load(OWLOntologyManagerImpl.java:954)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:918)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntologyFromOntologyDocument(OWLOntologyManagerImpl.java:859)
    at glass.main.ontology_Test_main2.readOntology(ontology_Test_main2.java:49)
    at glass.main.ontology_Test_main2.main(ontology_Test_main2.java:38)

Do not forget to note the attachment, a small test Java project, the link:

dropbox.com/s/3787a3gsk2bwc26/test.tar.gz?dl=0

I'm sorry I'm doing wrong, I'm sure this code

, https://github.com/owlcs/owlapi/blob/version5/contract/src/test/java/org/semanticweb/owlapi/examples/Examples.java

.

+4
2

:

final OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
final OWLOntology ontology = manager.loadOntologyFromOntologyDocument(new File("/home/galigator/myLocalDir/aura.owl"));

IRI.create

+4

:

, : Hermit 1.3.8.500, OWL-API 5.0.5 .

: Hermit 1.3.8.510 OWL-API 5.1.0.

, - . .

+1

Source: https://habr.com/ru/post/1673763/


All Articles