Individual type relations

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

Individual type relations

Lukas99
Hi Jiba,

I have a question about the type relations of individuals.

I have attached a small ontology with one individual which
has two types HasEggs and Animal. Note that, HasEggs is a
subclass of Animal but the Animal type is explicitly set for the
individual anyway.

If we now remove the HasEggs type from the individual, the
Animal type is gone too (See the code below).
However, since the Animal type was explicitly set, it should still be there.
Saving the ontology and loading it again does behave correctly.

I guess, the is_a attribute would have to be updated then after the
removal of the first type?
Or if that’s already possible what would be the best way to
update it?
 
Thanks!

animals.owl
################################
from owlready2 import get_ontology

onto = get_ontology("file://animals.owl").load()
ind = list(onto.individuals())[0]

print(ind.is_a)                    # HasEggs
print(ind.INDIRECT_is_a)    # HasEggs, Animal, Thing

haseggs = ind.is_a[0]
ind.is_a.remove(haseggs)

print(ind.is_a)                    # Thing
print(ind.INDIRECT_is_a)    # Thing
#################################[hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Individual type relations

Jiba
Administrator
Hi,

There was a bug with a confusion between the list of OWL classes of the individual and the actual Python class of the individual. I've just fixed it in the development version of Owlready, and your example now works as expected.

Thanks,
Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Individual type relations

Lukas99
Thanks for the quick answer!