Hello everyone,
i'm trying to delete a class in my ontology with the destroy_entity method as shown in the documentation but i keep getting this error: ValueError: list.remove(x): x not in list Here is a snippet of my code: def destroy_class(self, class_identifier): with self.onto: destroy_entity(class_identifier) class_identifier = ontology_manager.onto["Bird1"] OntologyManager.destroy_class(ontology_manager, class_identifier) So basically, in a file called OntologyManager i created a class called in the same way and the method destroy_class is defined inside that class. In another file i try to delete the class Bird1 as shown above but as said i keep getting that error. |
Administrator
|
Hi,
Could you send me your ontology, please ? Or at least a portion of it that would allow me to reproduce the problem ? I need to experiment for finding the problem. Jiba |
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 |
Administrator
|
Hi,
For reproducing the problem, I need the ontology in addition to the code. Please also try a more recent version of Owlready (you mentioned version 0.14, but 0.34 is out !). Jiba |
Free forum by Nabble | Edit this page |