protected Set<OWLAxiom> turnHierarchyIntoAxioms(OWLReasoner r) { long t = System.currentTimeMillis(); // from Ernesto List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); gens.add(new InferredSubClassAxiomGenerator()); gens.add(new InferredEquivalentClassAxiomGenerator()); OWLOntology inferredOntology; try { inferredOntology = manager.createOntology(); InferredOntologyGenerator iog = null; iog = new InferredOntologyGenerator(r, gens); iog.fillOntology(manager, inferredOntology); t = System.currentTimeMillis() - t; LogOutput.print(t + "ms for the hierarchy rewriting"); return inferredOntology.getAxioms(); } catch (OWLOntologyCreationException e) { e.printStackTrace(); return null; } }
/** * Adds 'inferred axioms' to an ontology using the generators that have been registered with * this {@code InferredAxiomGenerator}. * * @param df data factory. * @param ontology The ontology which the inferred axioms will be added to * @throws OWLOntologyChangeException If there was a problem adding the inferred axioms to the * specified ontology. */ public void fillOntology(OWLDataFactory df, OWLOntology ontology) { checkNotNull(df, "df cannot be null"); checkNotNull(ontology, "ontology cannot be null"); axiomGenerators.stream().flatMap(g -> generate(df, g)) .filter(ax -> !ontology.containsAxiom(ax, INCLUDED, IGNORE_AXIOM_ANNOTATIONS)) .forEach(ontology::add); }
/** * @param reasoner the reasoner to use */ public InferredOntologyGenerator(OWLReasoner reasoner) { this(reasoner, generators()); }
InferredOntologyGenerator ontGen = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>()); ontGen.addGenerator(new InferredSubClassAxiomGenerator()); ontGen.addGenerator(new InferredClassAssertionAxiomGenerator()); ontGen.addGenerator(new InferredSubObjectPropertyAxiomGenerator()); ontGen.addGenerator(new InferredSubDataPropertyAxiomGenerator()); ontGen.fillOntology(man, inferredOnt);
InferredOntologyGenerator generator = new InferredOntologyGenerator(reasoner, gens); logger.info("Using these axiom generators:"); for (InferredAxiomGenerator<?> inf : generator.getAxiomGenerators()) { logger.info(" " + inf); generator.fillOntology(dataFactory, newAxiomOntology);
public ExportTask(ExportInferredOntologyWizard wizard) throws OWLOntologyCreationException { this.wizard = wizard; inferredAxiomGenerators = wizard.getInferredAxiomGenerators(); outputManager = OWLManager.createOWLOntologyManager(); inferredOntologyGenerator = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), inferredAxiomGenerators); exportedOntology = outputManager.createOntology(wizard.getOntologyID()); taskCount = inferredAxiomGenerators.size() + 1; if (wizard.isIncludeAnnotations()) { taskCount += 1; } if (wizard.isIncludeAssertedLogicalAxioms()) { taskCount += 1; } taskCount += 3; // classify, apply changes and save the ontology... }
precompute(); inferredOntologyGenerator.fillOntology(outputManager.getOWLDataFactory(), exportedOntology);
InferredOntologyGenerator ontGen = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), new ArrayList<>()); ontGen.addGenerator(new InferredSubClassAxiomGenerator()); ontGen.addGenerator(new InferredClassAssertionAxiomGenerator()); ontGen.addGenerator(new InferredSubObjectPropertyAxiomGenerator()); ontGen.addGenerator(new InferredSubDataPropertyAxiomGenerator()); ontGen.fillOntology(man.getOWLDataFactory(), inferredOnt);
public ExportTask(ExportInferredOntologyWizard wizard) throws OWLOntologyCreationException { this.wizard = wizard; inferredAxiomGenerators = wizard.getInferredAxiomGenerators(); outputManager = OWLManager.createOWLOntologyManager(); inferredOntologyGenerator = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), inferredAxiomGenerators); exportedOntology = outputManager.createOntology(wizard.getOntologyID()); taskCount = inferredAxiomGenerators.size() + 1; if (wizard.isIncludeAnnotations()) { taskCount += 1; } if (wizard.isIncludeAssertedLogicalAxioms()) { taskCount += 1; } taskCount += 3; // classify, apply changes and save the ontology... }
precompute(); inferredOntologyGenerator.fillOntology(outputManager.getOWLDataFactory(), exportedOntology);
public void printHierarchy(File outputFile) throws FileNotFoundException, OWLOntologyCreationException, OWLOntologyStorageException { classifyClasses(); // To generate an inferred ontology we use implementations of inferred // axiom generators List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); gens.add(new InferredSubClassAxiomGenerator()); gens.add(new InferredEquivalentClassAxiomGenerator()); // Put the inferred axioms into a fresh empty ontology. OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology infOnt = man.createOntology(); InferredOntologyGenerator iog = null; iog = new InferredOntologyGenerator(owl2reasoner, gens); iog.fillOntology(man, infOnt); // Save the inferred ontology. OWLOntologyFormat format = new OWLFunctionalSyntaxOntologyFormat(); man.saveOntology(infOnt, format, IRI.create(outputFile.toURI())); }
InferredOntologyGenerator ontGen = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), new ArrayList<>()); ontGen.addGenerator(new InferredSubClassAxiomGenerator()); ontGen.addGenerator(new InferredClassAssertionAxiomGenerator()); ontGen.addGenerator(new InferredSubObjectPropertyAxiomGenerator()); ontGen.addGenerator(new InferredSubDataPropertyAxiomGenerator()); ontGen.fillOntology(man.getOWLDataFactory(), inferredOnt);
public ExportTask(ExportInferredOntologyWizard wizard) throws OWLOntologyCreationException { this.wizard = wizard; inferredAxiomGenerators = wizard.getInferredAxiomGenerators(); outputManager = OWLManager.createOWLOntologyManager(); inferredOntologyGenerator = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), inferredAxiomGenerators); exportedOntology = outputManager.createOntology(wizard.getOntologyID()); taskCount = inferredAxiomGenerators.size() + 1; if (wizard.isIncludeAnnotations()) { taskCount += 1; } if (wizard.isIncludeAssertedLogicalAxioms()) { taskCount += 1; } taskCount += 3; // classify, apply changes and save the ontology... }
precompute(); inferredOntologyGenerator.fillOntology(outputManager, exportedOntology);
/** * @param reasoner the reasoner to use */ public InferredOntologyGenerator(OWLReasoner reasoner) { this(reasoner, generators()); }
/** * Adds 'inferred axioms' to an ontology using the generators that have been registered with * this {@code InferredAxiomGenerator}. * * @param df data factory. * @param ontology The ontology which the inferred axioms will be added to * @throws OWLOntologyChangeException If there was a problem adding the inferred axioms to the * specified ontology. */ public void fillOntology(OWLDataFactory df, OWLOntology ontology) { checkNotNull(df, "df cannot be null"); checkNotNull(ontology, "ontology cannot be null"); axiomGenerators.stream().flatMap(g -> generate(df, g)) .filter(ax -> !ontology.containsAxiom(ax, INCLUDED, IGNORE_AXIOM_ANNOTATIONS)) .forEach(ontology::add); }
public void printHierarchy(File outputFile) throws FileNotFoundException, OWLOntologyCreationException, OWLOntologyStorageException { classifyClasses(); // To generate an inferred ontology we use implementations of inferred // axiom generators List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); gens.add(new InferredSubClassAxiomGenerator()); gens.add(new InferredEquivalentClassAxiomGenerator()); // Put the inferred axioms into a fresh empty ontology. OWLOntologyManager man = OWLManager.createOWLOntologyManager(); OWLOntology infOnt = man.createOntology(); InferredOntologyGenerator iog = null; switch (classified) { case classifiedWithElk: iog = new InferredOntologyGenerator(lReasoner, gens); break; case classifiedWithOWL2Reasoner: iog = new InferredOntologyGenerator(owl2reasoner, gens); break; default: LogOutput.printAlways("Classification not yet computed"); } iog.fillOntology(man, infOnt); // Save the inferred ontology. OWLOntologyFormat format = new OWLFunctionalSyntaxOntologyFormat(); man.saveOntology(infOnt, format, IRI.create(outputFile.toURI())); }
InferredOntologyGenerator ontGen = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>()); ontGen.addGenerator(new InferredSubClassAxiomGenerator()); ontGen.addGenerator(new InferredClassAssertionAxiomGenerator()); ontGen.addGenerator(new InferredSubObjectPropertyAxiomGenerator()); ontGen.addGenerator(new InferredSubDataPropertyAxiomGenerator()); ontGen.fillOntology(man, inferredOnt);
public ExportTask(ExportInferredOntologyWizard wizard) throws OWLOntologyCreationException { this.wizard = wizard; inferredAxiomGenerators = wizard.getInferredAxiomGenerators(); outputManager = OWLManager.createOWLOntologyManager(); inferredOntologyGenerator = new InferredOntologyGenerator(getOWLModelManager().getReasoner(), inferredAxiomGenerators); exportedOntology = outputManager.createOntology(wizard.getOntologyID()); taskCount = inferredAxiomGenerators.size(); if (wizard.isIncludeAnnotations()) { taskCount += 1; } if (wizard.isIncludeAssertedLogicalAxioms()) { taskCount += 1; } taskCount += 3; // classify, apply changes and save the ontology... }
precompute(); inferredOntologyGenerator.fillOntology(outputManager, exportedOntology);