简体   繁体   中英

How to get an explanation for an inconsistency using the owlexplanation project

I have a question regarding the owlexplanation project by Matthew Horridge on GitHub.

In the README file there is the following code :

import org.semanticweb.owl.explanation.api.*;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;

OWLReasonerFactory rf = ; // Get hold of a reasoner factory
OWLOntology ont = ; // Reference to an OWLOntology

// Create the explanation generator factory which uses reasoners provided by the specified
// reasoner factory
ExplanationGeneratorFactory<OWLAxiom> genFac = ExplanationManager.createExplanationGeneratorFactory(rf);

// Now create the actual explanation generator for our ontology
ExplanationGenerator<OWLAxiom> gen = genFac.createExplanationGenerator(ont);

// Ask for explanations for some entailment
OWLAxiom entailment ; // Get a reference to the axiom that represents the entailment that we want explanation for

// Get our explanations.  Ask for a maximum of 5.
Set<Explanation<OWLAxiom>> expl = gen.getExplanations(entailment, 5);

Please could somebody explain what exactly is the type of the parameter entailment ? I do not quite understand about what thing we get explanations. I am searching for code that gives me explanations when my ontology is inconsistent.

The entailment parameter is the axiom for which you are trying to determine how the entailment happened.

For explaining an inconsistency, you can follow the suggestion in the README to use a different factory. I've written an example that uses version 1.1.2 of OWLExplanation and version 1.2.1 of JFact (I needed a reasoner to test this; any reasoner will do).

import java.io.File;
import java.util.Set;
import org.semanticweb.owl.explanation.api.Explanation;
import org.semanticweb.owl.explanation.api.ExplanationGenerator;
import org.semanticweb.owl.explanation.impl.blackbox.checker.InconsistentOntologyExplanationGeneratorFactory;
import org.semanticweb.owlapi.apibinding.OWLManager;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.reasoner.OWLReasonerFactory;
import uk.ac.manchester.cs.jfact.JFactFactory;
public class TestExplanation {
  public static void main(String[] args) throws Exception {
    OWLReasonerFactory rf = new JFactFactory();
    OWLOntology ont = OWLManager.createOWLOntologyManager().createOntology();
    OWLOntologyManager m = ont.getOWLOntologyManager();
    OWLDataFactory df = m.getOWLDataFactory();
    OWLClass class1 = df.getOWLClass(IRI.create("urn:test:class1"));
    OWLClass class2 = df.getOWLClass(IRI.create("urn:test:class2"));
    OWLIndividual i = df.getOWLNamedIndividual(IRI.create("urn:test:i"));
    // create an inconsistent ontology by declaring an individual member of two disjoint classes
    m.addAxiom(ont, df.getOWLDisjointClassesAxiom(class1, class2));
    m.addAxiom(ont, df.getOWLClassAssertionAxiom(class1, i));
    m.addAxiom(ont, df.getOWLClassAssertionAxiom(class2, i));
    // create the explanation generator
    ExplanationGenerator<OWLAxiom> explainInconsistency = new InconsistentOntologyExplanationGeneratorFactory(rf,
        1000L).createExplanationGenerator(ont);
    // Ask for an explanation of `Thing subclass of Nothing` - this axiom is entailed in any inconsistent ontology
    Set<Explanation<OWLAxiom>> explanations = explainInconsistency.getExplanations(df.getOWLSubClassOfAxiom(df
        .getOWLThing(), df.getOWLNothing()));
    System.out.println("TestExplanation.main() " + explanations);
  }
}

The Maven dependency shown at https://github.com/matthewhorridge/owlexplanation does not seem to currently exist. Is there an accurate Maven entry available?

Here is what the above page says to use but can't be found:

<dependency>
    <groupId>net.sourceforge.owlapitools</groupId>
    <artifactId>owlexplanation</artifactId>
    <version>1.0.0</version>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM