Hermit tries to load imports from URL

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Hermit tries to load imports from URL

bonnevie
If I make three simple ontologies A,B,C with one single class (thing-<letter>) each, I can try and load all three ontologies and sync the reasoner:

import owlready2 as owl
import os

owl.onto_path.append(os.path.expanduser("~/Downloads"))
ontoA = owl.get_ontology("A.owl").load()
ontoB = owl.get_ontology("B.owl").load()
ontoC = owl.get_ontology("C.owl").load()
print("loaded", owl.default_world.ontologies)
print("imported by A", ontoA.imported_ontologies)
print("imported by B", ontoB.imported_ontologies)
print("imported by C", ontoC.imported_ontologies)
owl.sync_reasoner_hermit()



the print statements report:

loaded {'A.owl#': get_ontology("http://www.abc.net/ontologies/A#"), 'http://www.abc.net/ontologies/A#': get_ontology("http://www.abc.net/ontologies/A#"), 'B.owl#': get_ontology("http://www.abc.net/ontologies/B#"), 'http://www.abc.net/ontologies/B#': get_ontology("http://www.abc.net/ontologies/B#"), 'http://www.abc.net/ontologies/C#': get_ontology("http://www.abc.net/ontologies/C#"), 'C.owl#': get_ontology("http://www.abc.net/ontologies/C#")}
imported by A []
imported by B [get_ontology("http://www.abc.net/ontologies/A#"), get_ontology("http://www.abc.net/ontologies/C#")]
imported by C []


which looks reasonable, but then the reasoner crashes horribly with the following error:

Exception in thread "main" org.semanticweb.owlapi.model.OWLRuntimeException: org.coode.owlapi.rdfxml.parser.TranslatedUnloadedImportException: org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <http://www.abc.net/ontologies/C> Cause: Problem parsing http://www.abc.net/ontologies/C
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser

I get different but similar errors with other IRIs, indicating that it tries to load ontology C from the URL instead of from onto_path/file.

This does not seem to depend on whether or not I add any axioms. It also does not appear to be a problem for Pellet, only for Hermit.
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Jiba
Administrator
Hi,

I tried with 3 ontologies that I created and that correspond to your description, but I cannot reproduce the problem.

Could you send me your 3 ontologies please?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

bonnevie
Here you go.
A.owl
B.owl
C.owl
This is with Owlready2 0.25 and Python 3.7.9.
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

bonnevie
In reply to this post by Jiba
I forgot to mention the subclass axioms! They were in a previous draft, but I was unsure about whether they were necessary - later determined they are, so critical that I forgot to reinclude them, sorry. Basically, in ontology B, I have subclass axioms to the effect of thing-B has-subclass thing-A has-subclass thing-C. Importantly, it has to be three levels, couldn't reproduce the error with thing-A and thing-C being siblings.
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Jiba
Administrator
I tried after adding subclass axiom, but I am still unable to reproduce the problem.

Could you send me the 3 ontologies with the axioms, please?

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

bonnevie
Hi Jiba, I double-repiied before, so there should be links to all three ontologies, are they not working?
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Jiba
Administrator
I have the link to the three ontologies, but there is no subclass-of axioms in them.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

bonnevie
Oh, you're right, I'm sorry about that! Must have saved one of the other variants I was testing by mistake.
Redid ontology B with the appropriate axioms - can reproduce the error and the file now has axioms.

B.owl
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Jiba
Administrator
I finally manage to reproduce the problem.

It seems that hermit tries to imports the ontologies by itself, even if they are already included in the data sent by Owlready.

I fixed the problem in the development version of Owlready on Bitbucket, by removing imports before calling HermiT.

Alternatively, it seems that adding ".owl" at the end of the ontology IRI also fixes the problem (this weird behaviour depends on HermiT !).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

bonnevie
Very weird error, yes.
Did a merged ontology as a temporary fix, but it's a bit inconvenient when you have a modular design.
Great to know you have it fixed - I'll try the .owl suffix or wait for next version :) Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Mehmed
In reply to this post by Jiba
Hi Jean-Babtiste et al!

I thing,  I have the same problem. In my case I have two ontologies (fundamentals and system_modelling) and one contains (imports) the other one.

system_modelling.imported_ontologies
>>> [get_ontology("https://w3id.org/yxl/ontologies/fundamentals#")

I can load both ontologies,
fundamentals = fundamentals_world.get_ontology("https://w3id.org/yxl/ontologies/fundamentals.owl").load(only_local = True)
system_modelling = system_world.get_ontology("https://w3id.org/yxl/ontologies/system_modelling.owl").load(only_local = True)

..... but reason only the sub ontology "fundamentals" correctly,
sync_reasoner(fundamentals_world)

If I try to reason the the system_modelling ontology, it gives back a parsing error message for fundamentals:
sync_reasoner(system_world)
>>>................
OwlReadyJavaError                         Traceback (most recent call last)
<ipython-input-9-39587ae12b62> in <module>
----> 1 sync_reasoner(system_world)

~/anaconda3/lib/python3.8/site-packages/owlready2/reasoning.py in sync_reasoner_hermit(x, infer_property_values, debug, keep_tmp_file)
    139         raise OwlReadyInconsistentOntologyError()
    140       else:
--> 141         raise OwlReadyJavaError("Java error message is:\n%s" % (e.stderr or e.output or b"").decode("utf8"))
    142
    143     output = output.decode("utf8").replace("\r","")

OwlReadyJavaError: Java error message is:
Exception in thread "main" org.semanticweb.owlapi.model.OWLRuntimeException: org.coode.owlapi.rdfxml.parser.TranslatedUnloadedImportException: org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <https://w3id.org/yxl/ontologies/fundamentals> Cause: Problem parsing https://w3id.org/yxl/ontologies/fundamentals
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.


How can I declare for a locally imported ontology that it does not need to search the web.

Thank you in advance!
Regards,
Mehmed
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Jiba
Administrator
Hi,

Did you try the development version of Owlready on BitBucket? It includes a fix that normally remove import statement before sending the ontology to HermiT, so it should solve your problem.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Hermit tries to load imports from URL

Mehmed
Thank you Jean-Baptiste, it works fine.