-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import ontology from jar #621
Comments
There is no ready made utility for this but you should be able to load this kind of ontology subclassing a StreamDocumentSource. Currently it's not possible to achieve this with an IRI mapper - jar paths are not understood as resolvable IRIs. |
IRI mapper returns null if it cannot resolve the document IRI. I created a workaround that seems to work. It allows the document to be resolved whether it is in the file system or as a resource in the application jar. It uses URLClassLoader, which can access members of a jar.
|
Allow the content of a zip file to be mapped to ontology IRIs as an IRI mapper for use in an ontology manager. Also extend AutoIRIMapper to do the same. owlzip.properties and catalog*.xml supported to find ontology IRIs without parsing the actual files. Lacking these index files, same logic as AutoIRIMapper applies. Also implements Import ontology from jar #621 where AutoIRIMapper can now map the contents of a jar or zip file.
AutoIRIMapper can now do this. |
@ignazio1977 could you provide a bit more detail how to do it using AutoIRIMapper.
This does not seem to work for me. I get (with OWL API v 5.1.4):
And below:
My jar contains an ontology in functional-style syntax with the required IRI. If necessary I can create a complete test, but I wanted to double check if this is a proper way to load imports from jar. |
I also tried to give the AutoIRIMapper as an argument the directory in which the jar is located with the same result. The documentation of AutoIRIMapper also does not seem to mention jar files. |
Can you attach the jar you're using? The error message shows a fragment of HTML page - I suspect there might be an unresolvable import. |
Here you go: owlapi5-tryout.zip |
Interesting, if I replace the ontology IRIs from
to
Then I get a different error message:
Here is the update project: owlapi5-tryout.zip |
The @donmendelson solution does not seem to work for me either.
I get:
|
OK, I checked the source code and I think the changes to AutoIRIMapper have not been released yet. |
OK, one workaround would be to create a custom OWLOntologyFactory which would load ontologies from the jar file using their IRIs. Here is an example:
Here is the example project which now works: owlapi5-tryout.zip |
Another way would be to cherry pick the changes to AutoIRIMapper, factory and zip mapper from the commits for #375. It is not finished yet as there are a few other requirements on the YAML format, but I wasn't planning on backporting those - people sneer at extra dependencies. |
@ignazio1977 It would be nice if it were documented how to use AutoIRIMapper to load ontologies from JAR files:
Does it now look for ontologies also in the jar/zip files in the provided rootDirectory? Or the rootDirectory must be a jar/zip file? |
It works pointed directly at a zip/jar file or to a folder containing zip/jar files. I'll update the javadoc. |
I would like to distribute an application to create or edit ontologies that would import an ontology that I supply. I expect that the base ontology would be provided as a resource in a distributed jar file. My application works if the imported ontology resides as a flat file, but I am unable to load it from the jar. I've tried providing a file:// protocol on the document IRI in SimpleIRIMapper, but that doesn't work. Usually such resources are accessed by
InputStream ClassLoader.getResourceAsStream(String name)
I can't find a way to adapt that to the API. Any suggestions?
The text was updated successfully, but these errors were encountered: