Re: destroy_entity not working when i try to destroy a class

Posted by REPMEDDY on
URL: http://owlready.306.s1.nabble.com/destroy-entity-not-working-when-i-try-to-destroy-a-class-tp2614p2621.html

Hi, yes i can send you the code.
Basically there's a file called input_from_file.py where everything starts (that's the file you need to run).
The main inside that file at the moment is like this:

if __name__ == '__main__':
    ontology_manager = OntologyManager()
    build_ontology(ontology_manager)
    increased_ontology.prova(ontology_manager)
    #increased_ontology.compute_rational_closure_of_tbox(ontology_manager)
    """increased_ontology.compute_probability_for_typical_members(ontology_manager)
    increased_ontology.set_probability_for_each_scenario(
        increased_ontology.generate_scenarios(ontology_manager),
        ontology_manager)
    ontology_manager.show_scenarios()
    query_result = reasoning_on_scenarios.is_logical_consequence(ontology_manager)
    query_result.show_query_result()"""

If you go to the method prova (implemented in file increased_ontology.py) you'll se the invocation of the
method destroy_class (implemented in file OntologyManager.py).

Here's the output that i get when i run the program:

PRIMA
Penguin is_a [owl.Thing, onto.Bird]
Bird is_a [owl.Thing]
Fly is_a [owl.Thing]
Not(Fly) is_a [owl.Thing]
Bird1 is_a [owl.Thing, onto.r1.only(Not(onto.Bird) & onto.Bird1)]
IntersectionBirdBird1 is_a [owl.Thing, onto.Fly]
NotBird1 is_a [owl.Thing, onto.r1.some(onto.Bird & onto.Bird1)]
Penguin1 is_a [owl.Thing, onto.r1.only(Not(onto.Penguin) & onto.Penguin1)]
IntersectionPenguinPenguin1 is_a [owl.Thing, onto.Not(Fly)]
NotPenguin1 is_a [owl.Thing, onto.r1.some(onto.Penguin & onto.Penguin1)]
x is_a Bird
x is_a Fly
x is_a Bird1
x is_a IntersectionBirdBird1
DOPO
onto.x x
onto.Bird1 Bird1
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation
Traceback (most recent call last):
  File "/Users/gabrielesoriano/Università/progetto-tesi-magistrale/input_from_file.py", line 95, in <module>
    increased_ontology.prova(ontology_manager)
  File "/Users/gabrielesoriano/Università/progetto-tesi-magistrale/increased_ontology.py", line 63, in prova
    OntologyManager.destroy_class(ontology_manager, class_identifier)
  File "/Users/gabrielesoriano/Università/progetto-tesi-magistrale/OntologyManager.py", line 43, in destroy_class
    destroy_entity(class_identifier)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/prop.py", line 839, in destroy_entity
    e.namespace.world.graph.destroy_entity(e.storid, destroyer, relation_updater)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/triplelite.py", line 833, in destroy_entity
    destroyer(storid)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/prop.py", line 809, in destroyer
    subclass.is_a.remove(class_construct)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/owlready2/util.py", line 79, in remove
    def remove(self, x):          old = list(self); super().remove(x)         ; self._callback(self._obj, old)
ValueError: list.remove(x): x not in list

As you can see from the output i'm trying to delete the member x from the ontology (that actually happens) but i get the error when i try to delete the class Bird1.

I'm using Python3.7 and Owlready2 0.14