pythonontologyrestrictionowlready

How to add a superclass to a class with owlready python?


I'm using owlready to enrich an ontology with property restrictions. As we can see in the owlready documentation, it is possible to define restrictions on properties https://owlready2.readthedocs.io/en/latest/restriction.html#restrictions-on-a-property. The authors explained only how to define classes equivalent to restrictions as illustrated in the following picture.

class equivalent to a restriction

I want to add a restriction to an existing class with owlready (I want to replace the equivalent_to by subClass_of). Is it possible? How can I do it?

Thank you


Solution

  • I got the answer from @Jean-Baptiste, the developer of owlready2

    It is possible to add superclasses to an existing class with the following syntax:

       Class.is_a.append(SuperClass).
    

    The superClass may be a Class or a property restriction, for example

       Classe.is_a.append(property.some(Value))