Hi,
There are several errors in your code example :
1) you need to create the classes inside an ontology, e.g. :
onto = get_ontology('
http://test.org/test.owl')
with onto:
class Food(Thing): pass
2) the Fruit class is not defined, I suppose it should be the Food class instead
3) has_taste is defined as a DataProperty, but its range is a class (Taste), and then you use strings as value for the property.
If you want to use strings, defined range as follow: range = [str]
Otherwise, use Taste individual as value, and define has_taste as an ObjectProperty.
Here is a working example:
from owlready2 import *
onto = get_ontology('
http://test.org/test.owl')
with onto:
class Food(Thing): pass
class Taste(Thing): pass
class has_taste(ObjectProperty):
domain = [Food]
range = [Taste]
apple = Food('apple')
orange = Food('orange')
apple.has_taste.append(Taste('sweet'))
apple.has_taste.append(Taste('juicy'))
orange.has_taste.append(Taste('sweet'))
orange.has_taste.append(Taste('juicy'))
Jiba