1

I am using OWL API 3.4.3 and Hermit 1.3.8.1 (reasoner) on standard Pizza ontology.

I try to extract Direct superclasses of a class.

The tutorial provided here does not consider the extraction of Direct superclasses. For example, Food has two superclasses namely,

  1. owl:Thing and
  2. DomainConcept.

A simple code snippet is shown to extract the above mentioned Direct superclasses (i.e. DomainConcept).

 public Set<OWLClass> getDirectSuperClasses(String classExpressionString, boolean direct) {
        if (classExpressionString.trim().length() == 0) {
            return Collections.emptySet();
        }
        OWLClassExpression classExpression = parser
                .parseClassExpression(classExpressionString);
        //NodeSet<OWLClass> subClasses = reasoner.getSubClasses(classExpression, direct);
        NodeSet<OWLClass> directSuperClasses = **reasoner.get_________?????**
        return directSuperClasses.getFlattened();
    }

I am not able to find any relevant method which can be called using reasoner object.

Any tricks to get the desired output directly?

Thanks in advance :)

Community
  • 1
  • 1
R_Bro
  • 21
  • 1

1 Answers1

1

The method you are after is OWLReasoner::getSuperClasses(OWLClassExpression, boolean)

The source code, including javadoc, is available here

Ignazio
  • 10,504
  • 1
  • 14
  • 25
  • I think the tutorial (https://github.com/owlcs/owlapi/wiki/DL-Queries-with-a-real-reasoner) provides a method Set getSuperClasses(String classExpressionString, boolean direct) – R_Bro Oct 16 '16 at 11:07
  • (Continuing..). The tutorial method internally uses the method you are talking about (i.e OWLReasoner::getSuperClasses(OWLClassExpression, boolean) ). If I am not wrong, this method returns ALL the SUPER CLASSES, NOT the DIRECT SuPERCLASS! @Ignazio – R_Bro Oct 16 '16 at 11:13
  • The boolean flag triggers direct (true) or indirect (false) superclasses. If that does not work for you, we need to see the ontology and know which reasoner you're using, as it would be a bug to not obey the flag. – Ignazio Oct 16 '16 at 11:49