Search in sources :

Example 1 with InferredAxiomGenerator

use of org.semanticweb.owlapi.util.InferredAxiomGenerator in project goci by EBISPOT.

the class DefaultGWASOWLPublisher method saveGWASDataInferredView.

public void saveGWASDataInferredView(OWLReasoner reasoner, File outputFile) throws OWLConversionException {
    try {
        // create new ontology to hold inferred axioms
        OWLOntology inferredOntology = getConverter().createConversionOntology();
        getLog().info("Saving inferred view...");
        List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
        // we require all inferred stuff except for disjoints...
        gens.add(new InferredClassAssertionAxiomGenerator());
        gens.add(new InferredDataPropertyCharacteristicAxiomGenerator());
        gens.add(new InferredEquivalentClassAxiomGenerator());
        gens.add(new InferredEquivalentDataPropertiesAxiomGenerator());
        gens.add(new InferredEquivalentObjectPropertyAxiomGenerator());
        gens.add(new InferredInverseObjectPropertiesAxiomGenerator());
        gens.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
        gens.add(new InferredPropertyAssertionGenerator());
        gens.add(new InferredSubClassAxiomGenerator());
        gens.add(new InferredSubDataPropertyAxiomGenerator());
        gens.add(new InferredSubObjectPropertyAxiomGenerator());
        // now create the target ontology and save
        OWLOntologyManager inferredManager = inferredOntology.getOWLOntologyManager();
        InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens);
        iog.fillOntology(inferredManager, inferredOntology);
        inferredManager.saveOntology(inferredOntology, IRI.create(outputFile));
        getLog().info("Inferred view saved ok");
    } catch (OWLOntologyStorageException e) {
        throw new OWLConversionException("Failed to save GWAS data (inferred view)", e);
    }
}
Also used : InferredSubClassAxiomGenerator(org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator) InferredDataPropertyCharacteristicAxiomGenerator(org.semanticweb.owlapi.util.InferredDataPropertyCharacteristicAxiomGenerator) InferredEquivalentDataPropertiesAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentDataPropertiesAxiomGenerator) InferredPropertyAssertionGenerator(org.semanticweb.owlapi.util.InferredPropertyAssertionGenerator) InferredObjectPropertyCharacteristicAxiomGenerator(org.semanticweb.owlapi.util.InferredObjectPropertyCharacteristicAxiomGenerator) InferredInverseObjectPropertiesAxiomGenerator(org.semanticweb.owlapi.util.InferredInverseObjectPropertiesAxiomGenerator) InferredAxiomGenerator(org.semanticweb.owlapi.util.InferredAxiomGenerator) ArrayList(java.util.ArrayList) InferredSubDataPropertyAxiomGenerator(org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator) InferredEquivalentClassAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentClassAxiomGenerator) OWLConversionException(uk.ac.ebi.spot.goci.exception.OWLConversionException) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) InferredClassAssertionAxiomGenerator(org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) InferredSubObjectPropertyAxiomGenerator(org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator) InferredEquivalentObjectPropertyAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentObjectPropertyAxiomGenerator) InferredOntologyGenerator(org.semanticweb.owlapi.util.InferredOntologyGenerator) OWLOntologyStorageException(org.semanticweb.owlapi.model.OWLOntologyStorageException)

Example 2 with InferredAxiomGenerator

use of org.semanticweb.owlapi.util.InferredAxiomGenerator in project stanbol by apache.

the class HermitReasoningServiceTest method testRun.

private void testRun(String testID, String expectedID) {
    log.info("Testing the run() method");
    OWLOntologyManager manager = TestData.manager;
    // We prepare the input ontology
    try {
        OWLOntology testOntology = manager.createOntology();
        OWLOntologyID testOntologyID = testOntology.getOntologyID();
        log.debug("Created test ontology with ID: {}", testOntologyID);
        AddImport addImport = new AddImport(testOntology, TestData.factory.getOWLImportsDeclaration(IRI.create(testID)));
        manager.applyChange(addImport);
        // We just test class assertions
        List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
        gens.add(new InferredClassAssertionAxiomGenerator());
        // Maybe we want to see what is in before
        if (log.isDebugEnabled())
            TestUtils.debug(manager.getOntology(testOntologyID), log);
        // Now we test the method
        log.debug("Running HermiT");
        Set<OWLAxiom> inferred = this.theinstance.run(manager.getOntology(testOntologyID), gens);
        // Maybe we want to see the inferred axiom list
        if (log.isDebugEnabled()) {
            TestUtils.debug(inferred, log);
        }
        // These are the set of expected axioms
        Set<OWLLogicalAxiom> expectedAxioms = manager.getOntology(IRI.create(expectedID)).getLogicalAxioms();
        Set<OWLAxiom> missing = new HashSet<OWLAxiom>();
        for (OWLAxiom expected : expectedAxioms) {
            if (!inferred.contains(expected)) {
                log.error("missing expected axiom: {}", expected);
                missing.add(expected);
            }
        }
        log.info("Are all expected axioms in the result (true)? {}", missing.isEmpty());
        assertTrue(missing.isEmpty());
        // We want to remove the ontology from the manager
        manager.removeOntology(testOntology);
    } catch (OWLOntologyCreationException e) {
        log.error("An {} have been thrown while creating the input ontology for test", e.getClass());
        assertTrue(false);
    } catch (org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException e) {
        log.error("An {} have been thrown while executing the reasoning", e.getClass());
        assertTrue(false);
    } catch (org.apache.stanbol.reasoners.servicesapi.InconsistentInputException e) {
        log.error("An {} have been thrown while executing the reasoning", e.getClass());
        assertTrue(false);
    }
}
Also used : OWLLogicalAxiom(org.semanticweb.owlapi.model.OWLLogicalAxiom) InferredAxiomGenerator(org.semanticweb.owlapi.util.InferredAxiomGenerator) ArrayList(java.util.ArrayList) AddImport(org.semanticweb.owlapi.model.AddImport) ReasoningServiceException(org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException) OWLOntologyCreationException(org.semanticweb.owlapi.model.OWLOntologyCreationException) OWLOntology(org.semanticweb.owlapi.model.OWLOntology) OWLOntologyID(org.semanticweb.owlapi.model.OWLOntologyID) InconsistentInputException(org.apache.stanbol.reasoners.servicesapi.InconsistentInputException) InferredClassAssertionAxiomGenerator(org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator) OWLOntologyManager(org.semanticweb.owlapi.model.OWLOntologyManager) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) HashSet(java.util.HashSet)

Example 3 with InferredAxiomGenerator

use of org.semanticweb.owlapi.util.InferredAxiomGenerator in project stanbol by apache.

the class AbstractOWLApiReasoningService method getClassifyAxiomGenerators.

/**
 * {@see InferredAxiomGenerator}s to use for the classify() reasoning method.
 *
 * Subclasses may want to change this.
 *
 * @return
 */
protected List<InferredAxiomGenerator<? extends OWLAxiom>> getClassifyAxiomGenerators() {
    List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
    gens.add(new InferredClassAssertionAxiomGenerator());
    gens.add(new InferredSubClassAxiomGenerator());
    gens.add(new InferredEquivalentClassAxiomGenerator());
    gens.add(new InferredDisjointClassesAxiomGenerator());
    return gens;
}
Also used : InferredSubClassAxiomGenerator(org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator) InferredAxiomGenerator(org.semanticweb.owlapi.util.InferredAxiomGenerator) ArrayList(java.util.ArrayList) InferredClassAssertionAxiomGenerator(org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) InferredDisjointClassesAxiomGenerator(org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator) InferredEquivalentClassAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentClassAxiomGenerator)

Example 4 with InferredAxiomGenerator

use of org.semanticweb.owlapi.util.InferredAxiomGenerator in project stanbol by apache.

the class AbstractOWLApiReasoningService method getEnrichAxiomGenerators.

/**
 * {@see InferredAxiomGenerator}s to use for the enrich() reasoning method.
 *
 * Subclasses may want to change this.
 *
 * @return
 */
protected List<InferredAxiomGenerator<? extends OWLAxiom>> getEnrichAxiomGenerators() {
    List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
    // Classes
    gens.add(new InferredClassAssertionAxiomGenerator());
    gens.add(new InferredSubClassAxiomGenerator());
    gens.add(new InferredEquivalentClassAxiomGenerator());
    gens.add(new InferredDisjointClassesAxiomGenerator());
    // data properties
    gens.add(new InferredDataPropertyCharacteristicAxiomGenerator());
    gens.add(new InferredEquivalentDataPropertiesAxiomGenerator());
    gens.add(new InferredSubDataPropertyAxiomGenerator());
    // object properties
    gens.add(new InferredEquivalentObjectPropertyAxiomGenerator());
    gens.add(new InferredInverseObjectPropertiesAxiomGenerator());
    gens.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
    gens.add(new InferredSubObjectPropertyAxiomGenerator());
    // individuals
    gens.add(new InferredClassAssertionAxiomGenerator());
    gens.add(new InferredPropertyAssertionGenerator());
    return gens;
}
Also used : InferredSubClassAxiomGenerator(org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator) InferredDataPropertyCharacteristicAxiomGenerator(org.semanticweb.owlapi.util.InferredDataPropertyCharacteristicAxiomGenerator) InferredEquivalentDataPropertiesAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentDataPropertiesAxiomGenerator) InferredPropertyAssertionGenerator(org.semanticweb.owlapi.util.InferredPropertyAssertionGenerator) InferredObjectPropertyCharacteristicAxiomGenerator(org.semanticweb.owlapi.util.InferredObjectPropertyCharacteristicAxiomGenerator) InferredInverseObjectPropertiesAxiomGenerator(org.semanticweb.owlapi.util.InferredInverseObjectPropertiesAxiomGenerator) InferredAxiomGenerator(org.semanticweb.owlapi.util.InferredAxiomGenerator) ArrayList(java.util.ArrayList) InferredDisjointClassesAxiomGenerator(org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator) InferredSubDataPropertyAxiomGenerator(org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator) InferredEquivalentClassAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentClassAxiomGenerator) InferredClassAssertionAxiomGenerator(org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator) OWLAxiom(org.semanticweb.owlapi.model.OWLAxiom) InferredSubObjectPropertyAxiomGenerator(org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator) InferredEquivalentObjectPropertyAxiomGenerator(org.semanticweb.owlapi.util.InferredEquivalentObjectPropertyAxiomGenerator)

Aggregations

ArrayList (java.util.ArrayList)4 OWLAxiom (org.semanticweb.owlapi.model.OWLAxiom)4 InferredAxiomGenerator (org.semanticweb.owlapi.util.InferredAxiomGenerator)4 InferredClassAssertionAxiomGenerator (org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator)4 InferredEquivalentClassAxiomGenerator (org.semanticweb.owlapi.util.InferredEquivalentClassAxiomGenerator)3 InferredSubClassAxiomGenerator (org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator)3 OWLOntology (org.semanticweb.owlapi.model.OWLOntology)2 OWLOntologyManager (org.semanticweb.owlapi.model.OWLOntologyManager)2 InferredDataPropertyCharacteristicAxiomGenerator (org.semanticweb.owlapi.util.InferredDataPropertyCharacteristicAxiomGenerator)2 InferredDisjointClassesAxiomGenerator (org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator)2 InferredEquivalentDataPropertiesAxiomGenerator (org.semanticweb.owlapi.util.InferredEquivalentDataPropertiesAxiomGenerator)2 InferredEquivalentObjectPropertyAxiomGenerator (org.semanticweb.owlapi.util.InferredEquivalentObjectPropertyAxiomGenerator)2 InferredInverseObjectPropertiesAxiomGenerator (org.semanticweb.owlapi.util.InferredInverseObjectPropertiesAxiomGenerator)2 InferredObjectPropertyCharacteristicAxiomGenerator (org.semanticweb.owlapi.util.InferredObjectPropertyCharacteristicAxiomGenerator)2 InferredPropertyAssertionGenerator (org.semanticweb.owlapi.util.InferredPropertyAssertionGenerator)2 InferredSubDataPropertyAxiomGenerator (org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator)2 InferredSubObjectPropertyAxiomGenerator (org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator)2 HashSet (java.util.HashSet)1 InconsistentInputException (org.apache.stanbol.reasoners.servicesapi.InconsistentInputException)1 ReasoningServiceException (org.apache.stanbol.reasoners.servicesapi.ReasoningServiceException)1