Search code examples
ontologyowl-api

check whether a class is disjoint or not with the given class using owl API


I want to check class disjoint axioms using owl API.here my problem.suppose I have two classes ChickenTopping and HamTopping.ChickenTopping class has a subclass of axiom hasSpiciness some Hot and HamTopping class has a subclass of axiom hasSpiciness some Mild. these Hot and Mild classes are disjointed ones. due to that subclass of axioms, ChickenTopping and HamTopping classes are disjointed. so how can check whether the given HamTopping class is disjoint with Chicken class or not?


Solution

  • Galigator already mentioned a few reasoners you could use.

    To check if a class is disjoint with another known class, once you create an OWLReasoner, you can use the following code:

    OWLClass a = ...
    OWLClass b = ...
    OWLReasoner reasoner = ...
    OWLDataFactory df = ...
    OWLAxiom axiom = df.getOWLDisjointClassesAxiom(Arrays.asList(a, b));
    boolean classesAreDisjoint = reasoner.isEntailed(axiom);