|
Hi,
I have made a small ontology to test Owlready2 for a robotic project in my lab. I have defined a Resource class, and a UnaryResource subclass, with the has_capacity int property. I have declared UnaryResource to be equivalent to Resource and has_capacity.value(1). After a call to sync_reasoner, an instance declared as a Resource with 1 capacity is correctly reparented to UnaryResource, but I would also expect the inverse, i.e. an instance declared as a UnaryResource to have a capacity set to 1! What am I missing?
A code snapshot is following. (and my .owl file is initially empty)
Thanks,
Charles
onto = get_ontology("file://./{}.owl".format(name))
onto.load()
with onto:
class Resource(Thing):
pass
class UnaryResource(Resource):
pass
class has_capacity(DataProperty, FunctionalProperty):
domain = [Resource]
range = [int]
UnaryResource.equivalent_to = [Resource & has_capacity.value(1)]
motor1 = onto.Resource("motor1")
motor1.has_capacity = 1
motor1.is_shareable = False
battery = onto.Resource("battery")
battery.has_capacity = 24
battery.is_shareable = True
motor2 = onto.UnaryResource("motor2")
close_world(onto)
sync_reasoner()
print(onto.UnaryResource.get_class_properties())
print(battery, battery.has_capacity)
print(motor1, motor1.has_capacity)
print(motor2, motor2.has_capacity)
|