This answer is instructed from Ignazio Palmisano:
If there is no current solution from pellet, we can write our own.
- Select your starting point, i.e., the first individual in your
transitive chain
- Retrieve all fillers for the property you're after
- For each filler, retrieve all fillers as in the previous step
- Take care of avoiding cycles
(The reason to have both a set and a list is to be able to iterate in
a predictable way while adding elements, and retain fast containment
checks - at the cost of a little memory)
OWLDataFactory factory = manager.getOWLDataFactory();
Set<OWLNamedIndividual> found= new HashSet<>();
List<OWLNamedIndividual> list= new ArrayList<>();
List<OWLNamedIndividual> SeaIcelist= new ArrayList<>();
PrefixManager pm = new DefaultPrefixManager("http://www.semanticweb.org/SeaIceOntology#");
OWLNamedIndividual root = factory.getOWLNamedIndividual(":thickness", pm);
OWLObjectProperty p = factory.getOWLObjectProperty(IRI
.create("http://www.semanticweb.org/SeaIceOntology#similarTo"));
OWLReasoner r= new StructuralReasonerFactory().createNonBufferingReasoner(loadMODIS);
found.add(root);
list.add(root);
while(i < list.size()){
for(Node<OWLNamedIndividual> ind:r.getObjectPropertyValues
(list.get(i), (OWLObjectPropertyExpression)p)){
for(OWLNamedIndividual nind:ind){
if(found.add(nind)){
list.add(nind);
/* select specific individuals to the SeaIcelist */
for(OWLClassExpression ex : nind.getTypes(loadMODIS)) {
while(ex.asOWLClass().getSuperClasses(loadMODIS).iterator().hasNext()){
for(OWLClassExpression cl:ex.asOWLClass().getSuperClasses(loadMODIS)) {
if (cl.equals(factory.getOWLClass
(IRI.create("http://www.semanticweb.org/SeaIceOntology#EarthScienceProperty"))) ){
SeaIcelist.add(nind);
break;
}
}
ex = ex.asOWLClass().getSuperClasses(loadMODIS).iterator().next();
}
}
/* select specific individuals to the SeaIcelist */
}
}
}
i ++;
}
for (int j = 1; j < i; j ++){
System.out.println("These are all the terms which has similar meanings." + list.get(j).toStringID());
}
int size = SeaIcelist.size();
for (int j = 0; j < size; j ++){
System.out.println("These are all the standard terms which has similar meanings." + SeaIcelist.get(j).toStringID());
}