Search code examples
pythondnsowlontologyowlready

How to define multiple domains in owlready2?


I'm new with owlread2. I'm want to implement a relationship like

Car has Color
Bike has Color
House has Color

so far i tried it like this:

class has_color(ObjectProperty):
   domain = [Car,Bike,House]
   range = [Color]

and

cass has_color(ObjectProperty):
    domain = [Car| Bike| House]
    range = [Color]

but both these methods don't seem to work. I would be happy if someone can tell me how to make this work


Solution

  • After i kept digging, i found the solution. the Or() statement needs to be in brackets.

    class has_color(ObjectProperty):
           domain = [Or([Car,Bike,House])]
           range = [Color]
    

    works like a charm.

    domain = [Car | Bike | House]
    

    also works, but some IDEs mark the vertical bar as deprecated