Deleting classes from ontologies

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

Deleting classes from ontologies

rami_dhouib
Hi , im trying to delete classes from my Ontology and im having different errors , one of them is this code :

import os
from owlready2 import *
onto = get_ontology("GENIALOntBFO.owl").load()
a1 = get_namespace("http://w3id.org/gbo#")
with onto:
    destroy_entity(a1.harware_component)

And with the error:
 File "C:\Users\ramid\OneDrive\Desktop\Konclude-v0.7.0-1135-Windows-x64-MSVC-Dynamic-Qt5.15.2\reasoning.py", line 11, in <module>
    destroy_entity(a1.harware_component)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\prop.py", line 986, in destroy_entity
    e.namespace.world.graph.destroy_entity(e.storid, destroyer, relation_updater, undoer_objs, undoer_datas)
AttributeError: 'NoneType' object has no attribute 'namespace'

Any Idea whats the Problem? Im just deleting 1 class which is weird why its not deleting correctly ,
you will find the Ontology here :
https://github.com/wawrzik/GENIALOntologies/blob/master/OntologyModuleSuite/GENIAL!BasicOntology/GENIALOntBFO.owl
I had different Errors with different Ontologies , like :
TypeError: '<' not supported between instances of 'NoneType' and 'int' .
Reply | Threaded
Open this post in threaded view
|

Re: Deleting classes from ontologies

Jiba
Administrator
Hi,

You just forgotten the "d" in hardware, in this line:

destroy_entity(a1.harware_component)

Consequently, a1.harware_component (without d) returns None, causing an error in destroy_entity().

With the proper entity name, it seems to work.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Deleting classes from ontologies

rami_dhouib
This post was updated on .
Yeah thanks. I just did a mistake here but i still have issues deleting classes , usually I use a bigger Ontology ca 3200 classes .With this Ontology I had no errors . Here is the test Ontology https://github.com/RAMIDhouib1998/ontology
Code:
import os
from owlready2 import *
onto = get_ontology("test.owl").load()
a1 = get_namespace("http://w3id.org/gbo#")
with onto:
    destroy_entity(a1.system)

Error:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

FullError:
  File "C:\Users\ramid\OneDrive\Desktop\Konclude-v0.7.0-1135-Windows-x64-MSVC-Dynamic-Qt5.15.2\reasoning.py", line 9, in <module>
    destroy_entity(a1.system)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\prop.py", line 986, in destroy_entity
    e.namespace.world.graph.destroy_entity(e.storid, destroyer, relation_updater, undoer_objs, undoer_datas)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\triplelite.py", line 974, in destroy_entity
    relation_updater(destroyed_storids, s, ps)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\prop.py", line 946, in relation_updater
    update_relation(destroyed_storids, storid, relations)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\prop.py", line 954, in update_relation
    o.is_a.reinit([i for i in parents if not i is None and not i is NamedIndividual])
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\util.py", line 76, in reinit
    def reinit(self, l):          old = list(self); super().__init__(l)       ; self._callback(self._obj, old)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\entity.py", line 241, in _class_is_a_changed
    old = frozenset(old)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\class_construct.py", line 322, in __hash__
    def __hash__(self): return hash((self.type, self.property, self.value, self.cardinality))
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\class_construct.py", line 359, in __getattr__
    v = self.__dict__["value"] = self.ontology.world._to_python(v, None, default_to_none = True)
  File "C:\Users\ramid\AppData\Local\Programs\Python\Python37\lib\site-packages\owlready2\namespace.py", line 274, in _to_python
    if   o < 0: return self._parse_bnode(o)
TypeError: '<' not supported between instances of 'NoneType' and 'int'
Reply | Threaded
Open this post in threaded view
|

Re: Deleting classes from ontologies

Jiba
Administrator
Hi,

I finally manage to reproduce the problem. It should now be fixed in the development version of Owlready on Bitbucket!

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Deleting classes from ontologies

rami_dhouib
This post was updated on .
py -m pip install git+https://bitbucket.org/jibalamy/owlready2.git installed 0.39 not 0.40 .Thought I urgently need the version that has no Errors , what to do?
But I think the error is fixed so maybe a mistake from cmd message.
Reply | Threaded
Open this post in threaded view
|

Re: Deleting classes from ontologies

Jiba
Administrator
I think the version was still labeled 0.39 in the repository.

I've just published a new release, 0.40, so you can install it with pip as usual.

Jiba