AttributeError when saving ontologies

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

AttributeError when saving ontologies

jayson
Hello together,

I tried to save (multiple) ontologies (which are in different files) and received the error:

AttributeError: module 'test_onto' has no attribute 'storid'

In the following the exemplary code:

File 1
#============================================================
from owlready2 import *

causes_onto = get_ontology("http://test.org/test_onto.owl")

with test_onto:

    class Test(Thing):
        pass
#============================================================


Main File
#============================================================
from owlready2 import *

import test_onto

overall = get_ontology("http://test.org/overall.owl")

overall.imported_ontologies.append(test_onto)

overall .save(file="overall _onto", format="rdfxml")
#============================================================

What did I do wrong or understood wrongly? Is it possible to store all ontologies separately?

Thanks in advance for your help.
jayson
Reply | Threaded
Open this post in threaded view
|

Re: AttributeError when saving ontologies

Jiba
Administrator
Hello,

With Owlready, ontologies are not modules (although they somehow behave like module as they contain classes), so you should not get the error "module 'test_onto' has no attribute 'storid'".

Maybe there is a confusion between a Python module named "test_onto" and an ontology with the same name ? "import test_onto" imports a Python module, therefore, test_onto is NOT an ontology.

If you want to access test_onto.owl in two files, you can use "get_ontology("http://test.org/test_onto.owl")" in both, it will return the same ontology (not two different ones).

Jiba