Posted by
Jiba on
URL: http://owlready.306.s1.nabble.com/Inferring-Object-Properties-for-Individuals-Based-on-Asserted-SomeValuesFrom-tp527p561.html
Hi,
The equivalent_to relation is not sufficient to "replace" Bitter (class) by bitter (individual), because it does not prevent Bitter to be equivalent to another individual, e.g. bitter2, bitter3,...
If the property is asserted at the class level, I prefer to stay at that level -- changing level would require a true reasoning, but .indirect() does not do that, it just resolves transitive property and (now) gets the value asserted at the class level.
In my opinion, kale.has_taste should not be though as "triple" but rather as a Python attribute. In that sense, having classes in it is not a problem.
I tested the following program, and I obtain the expected results (= [t.Bitter]). Are you obtaining something else?
Best regards,
Jiba
----8<--------
from owlready2 import *
onto_path.append('/tmp')
onto = get_ontology('
http://test.org/t.owl')
with onto:
class Ingredient(Thing): pass
class Kale(Ingredient): pass
class Bitter(Ingredient): pass
class has_taste(Thing >> Thing): pass
kale = Kale("kale")
bitter = Bitter("bitter")
Bitter.equivalent_to.append(OneOf([bitter]))
Kale.equivalent_to.append(OneOf([kale]))
AllDifferent([bitter, kale])
Kale.is_a.append(has_taste.some(Bitter))
close_world(Ingredient)
print(list(kale.has_taste.indirect()))