PropertyChain creation and deletion

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

PropertyChain creation and deletion

maelle.a
This post was updated on .
Hello,

I would like to create a transitive PropertyChain (here PChain) which chains property A and property B.
I use this code to create it :

      class PChain(owl.ObjectProperty, owl.TransitiveProperty): pass

      impacts.property_chain.append(owl.PropertyChain([A, B]))


Later in the execution, I would like to clean the whole ontology by destroying every of its entities with this function :

    def empty_ontology() -> None:
        """Empty the ontology by destroying individuals, properties and classes."""
        for indiv in ontology.individuals():
            owl.destroy_entity(indiv)
        for prop in ontology.properties():
            owl.destroy_entity(prop)
        for class_ in ontology.classes():
            owl.destroy_entity(class_)


I have three questions about this :
- Is it the right way to create my PropertyChain ? It seems to work when I run the reasoner (Relation is created when needed and axioms from transitivity are inferred) after creating it but I not sure it's the proper way to do it.
- Is there a better way to destroy all entities of an ontology ? Maybe a function that already exists in owlready ?
- When I create the PropertyChain and then try to empty the ontology, I have an error that I don't know how to fix : AttributeError: 'PropertyChain' object has no attribute 'subclasses'. If I save my ontology after creating the PropertyChain, then stop the execution, reload the ontology in another execution, and try to empty it, I don't have the same message and everything seems to work.

Thanks in advance for any answer !
Reply | Threaded
Open this post in threaded view
|

Re: PropertyChain creation and deletion

Jiba
Administrator
Hello,

Indeed, there was a bug in the destroying of property involved in property chains. I just fixed the bug in the development version of Owlready, on BitBucket.

Your way for creating the property chain is right.

Regarding the method for emptying an ontology, the easiest way is usually to completely destroy it and then to recreate it.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: PropertyChain creation and deletion

maelle.a
Hello,

Thanks for the answer. Indeed, it works with the development version.

Have a good day !
Maelle