Search code examples
owlontologyowl-api

Getting the number of individuals in ontology with OWL API


How can I get the number of individuals in ontology regardless to the classes or subclasses they belong to, only by using OWL API (not SPARQL or other tools). I was trying this:

NodeSet<OWLNamedIndividual> inds = reasoner.getInstances(subClass, false);
int numofInd = inds.getNodes().size();

Where subClass is a subclass of Thing. But how could I get the whole number of individuals in ontology.


Solution

  • OWLOntology::getIndividualsInSignature(boolean includeImportsClosure) returns all individuals including the imports closure, see the Javadocs