Value restriction on properties and reasoning

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

Value restriction on properties and reasoning

lesire
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)
Reply | Threaded
Open this post in threaded view
|

Re: Value restriction on properties and reasoning

Jiba
Administrator
Hi,

If you want to infer data property values, you need to use the Pellet reasoner (Hermit does not support this) and to add the "infer_data_property_values" optional argument (by default Owlready performs only classification). For example:

sync_reasoner_pellet(infer_property_values = True, infer_data_property_values = True)

I've tested it successfully with your example,
Jiba