I'm trying to get an object property from a class, in particular: I'm trying to understand when a class is a part of some other class (the construct used could be seen in the screenshot).
I've already tried to use the OWL-api function getObjectPropertiesInSignature()
on a OWLClass
object (the object is "e").
//display delle object property
Set<OWLObjectProperty> proprietà = e.getObjectPropertiesInSignature();
System.out.println("Object Property:");
if(proprietà.isEmpty()) {
System.out.println("\tQuesta classe non ha object property");
}
else {
for(OWLObjectProperty prop : proprietà) {
System.out.println("\t"+ prop);
}
}
The output of the snippet is Questa classe non ha object property
, so the function returns an empty Set, But In this case, it should return a Set with one object property: the part-Of object property.
What you are trying to find out is whether a class is included in the domain of an object property (classes do not 'have' object properties in OWL), or whether the class is a subclass of a restriction. The signature of a class object contains object properties only when a class expression mentions a property, for example a qualified cardinality restriction or an existential restriction, as in your example.
In order to see whether a class has a superclass that uses partOf
, you can create a class expression representing the right hand side of your subclass axiom and ask for its subclasses.
OWLDataFactory df = ...
OWLClassExpression c = df.getOWLObjectSomeValuesFrom(partOf, car);
NodeSet subClasses = hermit.getSubClasses(c, false);
For classes in the domain of partOf, you have to look for subclasses of the intersection of the domain expressions:
OWLClassExpression domain = df.getOWLObjectIntersectionOf(ontology.objectPropertyDomainAxioms(partOf));
NodeSet subClassesInDomain = hermit.getSubClasses(domain, false);