Using Instances instead of hard-coded classes:

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

Using Instances instead of hard-coded classes:

DoubtsDoubts
Hi,
Take the following scenario:
Class A has two subclasses, A1 and A2. Class B also has two subclasses, B1 and B2. Let class A has a property has_A, and class B has a property has_B. We are defining property restrictors here; C1 and C2 with the equivalant_to notation in owlready2.
To define the property restrictors (C1 and C2 in our case), all the items inside should be a class or subclass. In our application, it would be better if we had more freedom in it, like using class instances rather than subclasses. We would like to use instances of class A, let's say a1 and a2 and instances of class B, b1 and b2 in the property restrictors. For eg.,
                c1 = equivalant_to([D & has_A.value(a1) & has_B.value(b1)])
Right now, if we use this approach with hermit reasoner, the first case with pre-defined classes will output the property constraint, but while using instances instead, it's always pointing to the default class, D in our case.
Is there any way to use instances rather than classes/subclasses in property restrictors? Or any other approach, where we need to use restrictors, but remove/reduce the hard coding and use class instances instead?
Reply | Threaded
Open this post in threaded view
|

Re: Using Instances instead of hard-coded classes:

Jiba
Administrator
Hi,

You can "transform" an instance (or a set of instances) into a class using a "OneOf" construct. The syntax is OneOf([instance1, ...]) in Owlready and { instance1,... } in Protege.

OneOf constructs can then be used in place of classes, e.g. :

with onto:
    class A(Thing):
        equivalent_to = [D & has_A.some(OneOf([a1]))]

Jiba