reasoner.classify();
// If classification worked properly then Endocarditis should be
// classified not only as an Inflammation but also as a HeartDisease
// and a CriticalDisease
Ontology t = reasoner.getClassifiedOntology();
// We use the same id that was used to create the concept to look for
// the corresponding node in the taxonomy
Node endocarditisNode = t.getNode("Endocarditis");
System.out.println("Node for endocarditis:\n "+
endocarditisNode.getEquivalentConcepts());
// We can now print the equivalent concepts in the node and the parent
// nodes
Set<Node> parentNodes = endocarditisNode.getParents();
System.out.println("Parents of endocarditis:");
for(Node parentNode : parentNodes) {
System.out.println(" "+parentNode.getEquivalentConcepts());
}
// We can now add more axioms to the ontology and re-run the
// classification
Set<Axiom> additionalAxioms = new HashSet<Axiom>();
Concept heartInflammation = f.createNamedConcept("HeartInflammation");
lhs = heartInflammation;
rhs = inflammation;
additionalAxioms.add(f.createConceptInclusion(lhs, rhs));
lhs = endocarditis;
rhs = f.createConjunction(
heartInflammation,
f.createExistential(hasLoc, endocardium)
);
additionalAxioms.add(f.createConceptInclusion(lhs, rhs));
// Subsequent invocations will trigger an incremental classification
System.out.println("Running incremental classification:");
reasoner.loadAxioms(additionalAxioms);
reasoner.classify();
// Now Endocarditis should be a HeartInflammation instead of an
// Inflammation
t = reasoner.getClassifiedOntology();
endocarditisNode = t.getNode("Endocarditis");
System.out.println("Node for endocarditis:\n "+
endocarditisNode.getEquivalentConcepts());
parentNodes = endocarditisNode.getParents();
System.out.println("Parents of endocarditis:");