0

I'm doing some SWRL rules in OWL ontology like this:

..., hasHazardCode(?a, H350) -> DangerousProduct(?a)
..., hasHazardCode(?a, H350i) -> DangerousProduct(?a)
..., hasHazardCode(?a, H400) -> DangerousProduct(?a)
..., hasHazardCode(?a, H401) -> DangerousProduct(?a)
......

H350, H350i, H400 and H401 are some named individuals. As we can see that the pattern of these SWRL rules are similar. So I think maybe we can replace these rules with only one rule that goes like:

..., hasHazardCode(?a, {H350, H350i, H400, H401}) -> DangerousProduct(?a)

I tried this syntax in the Rules tab in Protege, but it didn't work. Does SWRL have support for individual enumeration statement like that?

1 Answers1

0

This is possible with an OWL Class Expression of type "Range".

let myClass = the class of thing that have some hasHazardCode in range [H350, H350i, ... ] in hasHazardCode(?a, ?HValue) /\ Class(myClass, ?HValue) -> Class(DangerousProduct,?a)

Using the pellet java syntax, here how your example could be re-write:

    OWLObjectProperty myProperty = OWL.ObjectProperty("hasHazardCode");
    OWLObjectOneOf myRange = OWL.oneOf(OWL.Individual("H350"), OWL.Individual("H350i"), OWL.Individual("H400"), OWL.Individual("H401"));
    OWLClassExpression myClass = OWL.some(OWL.ObjectProperty("hasHazardCode"), myRange);

    SWRL.rule(
        SWRL.antecedent(
           SWRL.propertyAtom(myProperty, SWRL.variable("?a"), SWRL.variable("?HValue")),
           SWRL.classAtom(myClass, SWRL.variable("?HValue"))
        ),
        SWRL.consequent(SWRL.classAtom(OWL.Class("DangerousProduct"), SWRL.variable("?a")))
    );
Galigator
  • 8,957
  • 2
  • 25
  • 39