Destroy entity not working properly

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

Destroy entity not working properly

Neha
hello,

I have a function which purpose is to delete the concepts from an ontology. The concepts to be deleted are the ones not present in the parameter (concepts) provided.

    def del_concepts(self, file_name, concepts):
        onto = get_ontology(self.link).load()

        all_classes=list(onto.classes())
        print(concepts)
        for i in (all_classes):
            if i not in concepts:
                destroy_entity(i)
        onto.save(file=file_name, format="rdfxml")

However, when it reaches a certain concept, I get this error message:

File "C:\Program Files\Python39\lib\site-packages\owlready2\prop.py", line 941, in destroy_entity
    e.namespace.world.graph.destroy_entity(e.storid, destroyer, relation_updater, undoer_objs, undoer_datas)
  File "C:\Program Files\Python39\lib\site-packages\owlready2\triplelite.py", line 933, in destroy_entity
    relation_updater(destroyed_storids, s, ps)
  File "C:\Program Files\Python39\lib\site-packages\owlready2\prop.py", line 907, in relation_updater
    update_relation(destroyed_storids, storid, relations)
  File "C:\Program Files\Python39\lib\site-packages\owlready2\prop.py", line 925, in update_relation
    if o._equivalent_to._indirect:
AttributeError: 'NoneType' object has no attribute '_indirect'

Can someone tell me what I am doing wrong?
Reply | Threaded
Open this post in threaded view
|

Re: Destroy entity not working properly

Jiba
Administrator
Hello,

This is typically the kind of bugs that is very difficult to fix without a working example. Could you please send me your ontology, or at least a part of it that is sufficient to reproduce the problem ?

Thank you,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Destroy entity not working properly

w4ng
 

Hello,

I get the same problem,  I get some err information as
'''
'NoneType' object has no attribute '_indirect'
'NoneType' object has no attribute '_indirect'
'<' not supported between instances of 'NoneType' and 'int'
'NoneType' object has no attribute '_indirect'
'<' not supported between instances of 'NoneType' and 'int'
'<' not supported between instances of 'NoneType' and 'int'
'<' not supported between instances of 'NoneType' and 'int'
'<' not supported between instances of 'NoneType' and 'int'
'<' not supported between instances of 'NoneType' and 'int'
'<' not supported between instances of 'NoneType' and 'int'
'''
I think that is Duplicate Deletions and References problem, If you want to delete this concept, but this concept has other relationship. e.g. is_a or subclass of other class node, it will return the error information.
about answer:
I save the mult-class-node as a list, at end I del all mult-class, it works.

Wang
L
Reply | Threaded
Open this post in threaded view
|

Re: Destroy entity not working properly

L
In reply to this post by Jiba
if  a class who  has  subclass, when you delete the class ,its  subclass will be deleted at the same time.  You can't delete the subclass  twice , so that some error happen.
Reply | Threaded
Open this post in threaded view
|

Re: Destroy entity not working properly

Jiba
Administrator
Hi,

I tried what you described (delete a class, then its subclass) but I am not able to reproduce your problem. Here is my code:

from owlready2 import *

onto = get_ontology ("https://test.org/test.owl")

with onto:
    class C(Thing): pass
    class D(C): pass

default_world.graph.dump()
print()

destroy_entity(C)

default_world.graph.dump()
print()

destroy_entity(D)

default_world.graph.dump()
print()

Could you provide me a similar example that show the problem?

Jiba