long before = System.currentTimeMillis();
log.info("Guessing ontology ID. Read limit = {} triples; offset = {} triples.", limit,
versionIriOffset);
BufferedInputStream bIn = new BufferedInputStream(content);
bIn.mark(limit * 512); // set an appropriate limit
OntologyLookaheadMGraph graph = new OntologyLookaheadMGraph(limit, versionIriOffset);
try {
parser.parse(graph, bIn, format);
} catch (RuntimeException e) {
log.error("Parsing failed for format {}. Returning null.", format);
}
OWLOntologyID result;
if (graph.getOntologyIRI() == null) { // No Ontology ID found
log.warn(" *** No ontology ID found, ontology has a chance of being anonymous.");
result = new OWLOntologyID();
} else {
// bIn.reset(); // reset set the stream to the start
IRI oiri = IRI.create(graph.getOntologyIRI().getUnicodeString());
result = graph.getVersionIRI() == null ? new OWLOntologyID(oiri) : new OWLOntologyID(oiri,
IRI.create(graph.getVersionIRI().getUnicodeString()));
log.info(" *** Guessed ID : {}", result);
}
log.info(" ... Triples scanned : {}; filtered in : {}", graph.getScannedTripleCount(), graph.size());
log.info(" ... Time : {} ms", System.currentTimeMillis() - before);
return result;
}