stochastic "UnboundLocalError" when loading ontology

Posted by cknoll on
URL: http://owlready.306.s1.nabble.com/stochastic-UnboundLocalError-when-loading-ontology-tp2775.html

Hi,

I have an ontology file which can sometimes be loaded with owlready and sometimes I get an
UnboundLocalError
. The ontology file originally comes from an n-triples file which I converted to rdf/xml with rdflib. It might be the case that something is wrong with that file, but I find it strange that sometimes there is an error and sometimes not.

Here is the code that reproduces the error:

import owlready2 as owl2
onto = owl2.get_ontology("ontology_data/base.rdf.xml").load()

See also this notebook for the informative traceback:
https://nbviewer.ipython.org/github/cknoll/demo-material/blob/main/expertise_system/owlready_demo3.ipynb

This is the corresponding data file:

https://github.com/cknoll/demo-material/blob/main/expertise_system/ontology_data/base.rdf.xml

Any ideas how to prevent or mitigate this behavior?