Correctly destroying an ontology

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

Correctly destroying an ontology

AlGerl
Dear Forum,

I have a question regarding the destroying of an ontology.

I run the code in Spyder IDE, where I want to make multiple executions of the code. While starting a new execution of the code (in the same python instance), I always create the ontology with: owl.get_ontology( "http://test-ontology.de/pml#" ).

What I could observe was that after the first run, the ontology was extended and not newly created. Therefore, I always have to start the spyder console new.

For the next approach, I tried to destroy the ontology in the last line of the code with:

[In the beginning of the code] >> onto_temp = owl.get_ontology( "http://test-ontology.de/pml#" )
[Last code line]                >> onto_temp.destroy()

The problem with this approach is, that the code somehow does not work properly within the second execution and the ontology can not be returned after the creation.

Therefore, I wanted to ask how I could correctly implement the destroy function for multiple executions within the same python instance.
Currently, I am bound to an NDA and can not provide any specific code samples.

Thank you and all the best!
Reply | Threaded
Open this post in threaded view
|

Re: Correctly destroying an ontology

Jiba
Administrator
Hi,

The normal way to destroy an ontology is Ontology.destroy(), as you did. Without it, multiple call to get_ontology() will return the same ontology object.

Ontology.destroy() removes all RDF triples from the ontology, and remove all cached entities from that ontology. However, it DOES NOT modify previously loaded entities. In particular, if you kept reference to entities, you can still access them and obtain error if you modify them.

Similarly, if the ontology destroyed modifies entities belonging to another ontology, those modification may not be removed after destroying the ontology. You can use Ontology.destroy(update_relation = True) to update relations on individuals belonging to another ontology. However, there is currently no such ability to update classes or properties.

I am sorry, I cannot help you more without additional information on the exact problem you encounter during the second execution.

Jiba

Jiba