javaowl-apihermit

Get part-Of class from OWL Ontology


I have an ontology made with protègè, I defined an ObjectProperty named part-Of. enter image description here

I'm parsing an OWLClass trying to find out whether or not the subclasses are part-Of the parsed class. In this case, I am parsing At_Home when the subclasses, ANA and PHE, have the following subclass of signature as in this picture enter image description here I've already tried with:

OWLDataFactory df = manager.getOWLDataFactory();
    OWLObjectProperty partOf = df.getOWLObjectProperty("part-Of");
    OWLClassExpression c = df.getOWLObjectSomeValuesFrom(partOf, target);
    NodeSet<OWLClass> subClasses = hermit.getSubClasses(c, true);
    if(subClasses.isEmpty()) {
        //System.out.println("\tQuesta classe non ha parti");
        res[0] = null;
    }
    else {
        for(Node<OWLClass> parte : subClasses) {
            risultato.add(parte.getRepresentativeElement().getIRI().getFragment());
        }
        res[0] = risultato;
    }

where target is the At_Home OWLClass, but the method continues to return an empty NodeSet, so it means that At_Home has no parts even if ANA and PHE are its parts.
The wanted result should be a NodeSet with the OWLClass "ANA" and "PHE"


Solution

  • df.getOWLObjectProperty("part-Of");

    This is the problem. You need to use the full IRI of your property, not just the fragment; this won't match the property as stated in your ontology.