0

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

krapottke
  • 1
  • 1
  • Either `Or([Class1, Class2])` or `Class1 | Class2` are the correct syntax for the union of classes. "Don't seem to work" is also not meaningful ... what does this mean? – UninformedUser Nov 22 '21 at 07:12

1 Answers1

0

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

krapottke
  • 1
  • 1