Non functional properties treated as functional ones

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

Non functional properties treated as functional ones

KayJay
Hello,

Let's say that I have the object property "hasIndicator" which is not functional since an object can have multiple indicators. If I restrict a given class with "hasIndicator only Indicator1 and hasIndicator exactly 1 Indicator1", then when I want to populate the ontology I cannot anymore write in Python "givenClass.hasIndicator.append(individual)". Indeed, it seems that the library considers that because of the restriction I should write givenClass.hasIndicator = individual. That is very annoying since as I said, my property is not functional and if in the given class it is restricted to 1 indicator, it is not the case in other classes.
I can solve temporary the issue by checking givenClass.hasIndicator value (None or []) to know how to pass my argument.

Am I using the library incorrectly or is it an unheard bug?

Thank you
KayJay
Reply | Threaded
Open this post in threaded view
|

Re: Non functional properties treated as functional ones

Jiba
Administrator
Hi,

You are right: Owlready detects classes with restrictions that made a property "functional" for that class. This was intented to be a feature and not a bug... Although I agree it is some time annoying, so maybe it should be removed...

As a workaround, you can use the property[entity] syntax that always returns a list (even for functional properties).

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Non functional properties treated as functional ones

KayJay
Ok thank you.

KayJay
Reply | Threaded
Open this post in threaded view
|

Re: Non functional properties treated as functional ones

Jiba
Administrator
Hi,

I finally decided to remove this functionnality in future release of Owlready -- Actually, I find it more annoying that usefull, too.

However, the previous behaviour can be restored for compatibility,  as follows:

import owlready2.prop
owlready2.prop.RESTRICTIONS_AS_FUNCTIONAL_PROPERTIES = True

Best regards,
Jiba