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

橙三吉。 提交于 2021-02-07 04:25:37

问题


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.


回答1:


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);
  }
}



回答2:


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>


来源:https://stackoverflow.com/questions/33150182/how-to-get-an-explanation-for-an-inconsistency-using-the-owlexplanation-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!