/** * Performs lookahead with a 100 kB limit. * * @param content * @param parser * @param format * @return * @throws IOException */ public static OWLOntologyID guessOntologyID(InputStream content, Parser parser, String format) throws IOException { return guessOntologyID(content, parser, format, _LOOKAHEAD_LIMIT_DEFAULT); }
OWLOntologyID guessed = OWLUtils.guessOntologyID(content, Parser.getInstance(), f);
public static OWLOntologyID guessOntologyID(InputStream content, Parser parser, String format, int limit, int versionIriOffset) throws IOException { 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 OntologyLookaheadGraph graph = new OntologyLookaheadGraph(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);
log.debug("Creating ontology input source..."); b4buf = System.currentTimeMillis(); OWLOntologyID guessed = OWLUtils.guessOntologyID(content, Parser.getInstance(), f); if (guessed != null && !guessed.isAnonymous() && ontologyProvider.hasOntology(guessed)) {
OWLOntologyID guessed = OWLUtils.guessOntologyID(content, Parser.getInstance(), f); log.debug("guessed ontology id: {}", guessed); if (guessed != null && !guessed.isAnonymous()