Reputation: 115
When we wanna create or load an ontology we use this line of code IRI ontologyIRI = IRI.create("http://owl.man.ac.uk/2005/07/sssw/ontologyName");
So, what should I use to get it as an output?
I tried with this function IRI documentIRI = manager.getOntologyDocumentIRI(ontology);
but it retunrs the location of the ontology file, something like this file:/Users/.../Desktop/ontologyname.owl
.
Instead of it, I need the one written like this :
http://owl.man.ac.uk/2005/07/sssw/ontologyName
Please, If you have any ideas... Thank you
Upvotes: 2
Views: 1759
Reputation: 4382
With OWLAPI-5, you can get the ontology IRI using the method:
ont.getOntologyID().getOntologyIRI().get()
Here you are an example:
OWLOntologyManager man = OWLManager.createOWLOntologyManager();
OWLOntology ont = man.loadOntologyFromOntologyDocument(IRI.create("file:/Users/.../Desktop/ontologyname.owl"));
IRI yourIRI = ont.getOntologyID().getOntologyIRI().get();
String yourOntoURI = yourIRI.toString();
Example source from owlapi: owlapi-github-examples (line 1115)
Upvotes: 1
Reputation: 10659
OWLOntology o = ...
IRI iri = o.getOWLOntologyID().getOntologyIRI().get();
This returns the IRI that the ontology is identified with; note - this might not be the same IRI that you loaded the ontology from. The resolvable IRI in your example might point at an ontology declaring a different IRI for itself (it is, in that sense, a document IRI).
Upvotes: 2